Skip to content

Commit

Permalink
Reformat CLI main()
Browse files Browse the repository at this point in the history
The bug causing me to turn off Black formatting for the Click main
function (psf/black#560) has been resolved.
  • Loading branch information
nyanpasu64 committed Jun 30, 2021
1 parent 2ad1b62 commit 1ac0905
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions corrscope/cli.py
Expand Up @@ -97,16 +97,16 @@ def get_file_stem(cfg_path: Optional[Path], cfg: Config, default: T) -> Union[st
@click.option('--profile', is_flag=True, help=
'Debug: Write CProfiler snapshot')
@click.version_option(corrscope.__version__)
# fmt: on is ignored, because of https://github.com/ambv/black/issues/560
# fmt: on
def main(
files: Tuple[str],
# cfg
audio: Optional[str],
# gui
write: bool,
play: bool,
render: bool,
profile: bool,
files: Tuple[str],
# cfg
audio: Optional[str],
# gui
write: bool,
play: bool,
render: bool,
profile: bool,
):
"""Intelligent oscilloscope visualizer for .wav files.
Expand Down Expand Up @@ -149,16 +149,18 @@ def main(
if len(files) > 1:
# Warning is technically optional, since wav_prefix has been removed.
raise click.ClickException(
f'Cannot supply multiple arguments when providing folder {path}')
matches = sorted(path.glob('*.wav'))
f"Cannot supply multiple arguments when providing folder {path}"
)
matches = sorted(path.glob("*.wav"))
wav_list += matches
break

elif path.suffix in YAML_EXTS:
# Load a YAML file to cfg, and skip template_config().
if len(files) > 1:
raise click.ClickException(
f'Cannot supply multiple arguments when providing config {path}')
f"Cannot supply multiple arguments when providing config {path}"
)
cfg_or_path = path
cfg_dir = str(path.parent)
break
Expand All @@ -170,7 +172,8 @@ def main(
matches = [path]
if not path.exists():
raise click.ClickException(
f'Supplied nonexistent file or wildcard: {path}')
f"Supplied nonexistent file or wildcard: {path}"
)
wav_list += matches

if not cfg_or_path:
Expand All @@ -184,13 +187,15 @@ def main(
# width_ms...trigger=default,
# amplification...render=default,
)
cfg_dir = '.'
cfg_dir = "."

assert cfg_or_path is not None
assert cfg_dir is not None
if show_gui:

def command():
from corrscope import gui

return gui.gui_main(cast(CfgOrPath, cfg_or_path))

if profile:
Expand All @@ -200,7 +205,7 @@ def command():

else:
if not files:
raise click.UsageError('Must specify files or folders to play')
raise click.UsageError("Must specify files or folders to play")

if isinstance(cfg_or_path, Config):
cfg = cfg_or_path
Expand Down Expand Up @@ -237,4 +242,3 @@ def command():
except MissingFFmpegError as e:
# Tell user how to install ffmpeg (__str__).
print(e, file=sys.stderr)
# fmt: on

0 comments on commit 1ac0905

Please sign in to comment.