kopia lustrzana https://github.com/corrscope/corrscope
Reformat CLI main()
The bug causing me to turn off Black formatting for the Click main function (https://github.com/ambv/black/issues/560) has been resolved.pull/382/head
rodzic
27e5194204
commit
7af7680afe
|
@ -97,16 +97,16 @@ CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
||||||
@click.option('--profile', is_flag=True, help=
|
@click.option('--profile', is_flag=True, help=
|
||||||
'Debug: Write CProfiler snapshot')
|
'Debug: Write CProfiler snapshot')
|
||||||
@click.version_option(corrscope.__version__)
|
@click.version_option(corrscope.__version__)
|
||||||
# fmt: on is ignored, because of https://github.com/ambv/black/issues/560
|
# fmt: on
|
||||||
def main(
|
def main(
|
||||||
files: Tuple[str],
|
files: Tuple[str],
|
||||||
# cfg
|
# cfg
|
||||||
audio: Optional[str],
|
audio: Optional[str],
|
||||||
# gui
|
# gui
|
||||||
write: bool,
|
write: bool,
|
||||||
play: bool,
|
play: bool,
|
||||||
render: bool,
|
render: bool,
|
||||||
profile: bool,
|
profile: bool,
|
||||||
):
|
):
|
||||||
"""Intelligent oscilloscope visualizer for .wav files.
|
"""Intelligent oscilloscope visualizer for .wav files.
|
||||||
|
|
||||||
|
@ -149,8 +149,9 @@ def main(
|
||||||
if len(files) > 1:
|
if len(files) > 1:
|
||||||
# Warning is technically optional, since wav_prefix has been removed.
|
# Warning is technically optional, since wav_prefix has been removed.
|
||||||
raise click.ClickException(
|
raise click.ClickException(
|
||||||
f'Cannot supply multiple arguments when providing folder {path}')
|
f"Cannot supply multiple arguments when providing folder {path}"
|
||||||
matches = sorted(path.glob('*.wav'))
|
)
|
||||||
|
matches = sorted(path.glob("*.wav"))
|
||||||
wav_list += matches
|
wav_list += matches
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -158,7 +159,8 @@ def main(
|
||||||
# Load a YAML file to cfg, and skip template_config().
|
# Load a YAML file to cfg, and skip template_config().
|
||||||
if len(files) > 1:
|
if len(files) > 1:
|
||||||
raise click.ClickException(
|
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_or_path = path
|
||||||
cfg_dir = str(path.parent)
|
cfg_dir = str(path.parent)
|
||||||
break
|
break
|
||||||
|
@ -170,7 +172,8 @@ def main(
|
||||||
matches = [path]
|
matches = [path]
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
raise click.ClickException(
|
raise click.ClickException(
|
||||||
f'Supplied nonexistent file or wildcard: {path}')
|
f"Supplied nonexistent file or wildcard: {path}"
|
||||||
|
)
|
||||||
wav_list += matches
|
wav_list += matches
|
||||||
|
|
||||||
if not cfg_or_path:
|
if not cfg_or_path:
|
||||||
|
@ -184,13 +187,15 @@ def main(
|
||||||
# width_ms...trigger=default,
|
# width_ms...trigger=default,
|
||||||
# amplification...render=default,
|
# amplification...render=default,
|
||||||
)
|
)
|
||||||
cfg_dir = '.'
|
cfg_dir = "."
|
||||||
|
|
||||||
assert cfg_or_path is not None
|
assert cfg_or_path is not None
|
||||||
assert cfg_dir is not None
|
assert cfg_dir is not None
|
||||||
if show_gui:
|
if show_gui:
|
||||||
|
|
||||||
def command():
|
def command():
|
||||||
from corrscope import gui
|
from corrscope import gui
|
||||||
|
|
||||||
return gui.gui_main(cast(CfgOrPath, cfg_or_path))
|
return gui.gui_main(cast(CfgOrPath, cfg_or_path))
|
||||||
|
|
||||||
if profile:
|
if profile:
|
||||||
|
@ -200,7 +205,7 @@ def main(
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if not files:
|
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):
|
if isinstance(cfg_or_path, Config):
|
||||||
cfg = cfg_or_path
|
cfg = cfg_or_path
|
||||||
|
@ -237,4 +242,3 @@ def main(
|
||||||
except MissingFFmpegError as e:
|
except MissingFFmpegError as e:
|
||||||
# Tell user how to install ffmpeg (__str__).
|
# Tell user how to install ffmpeg (__str__).
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
# fmt: on
|
|
||||||
|
|
Ładowanie…
Reference in New Issue