_cmdline module
- exception pyflyby._cmdline.AbortActions
- exception pyflyby._cmdline.ConfigurationError
Exception class indicating a configuration error.
- exception pyflyby._cmdline.Exit1
- class pyflyby._cmdline.Modifier(modifier, filename)
- _tempfile()
- Return type:
Tuple[Any,Filename]
- filename: Filename
- property input_content_filename: Filename
- property output_content_filename: Filename
- pyflyby._cmdline._default_on_error(filename)
- Return type:
None
- pyflyby._cmdline._get_pyproj_toml_config()
Return the toml contents of the current pyproject.toml.
If no pyproject.toml can be found in cwd or parent directories, None is returned.
- Return type:
Optional[Dict[str,Any]]
- pyflyby._cmdline._get_pyproj_toml_file()
Try to find the location of the current project pyproject.toml in cwd or parents directories.
If no pyproject.toml can be found, None is returned.
- Return type:
Optional[Path]
- pyflyby._cmdline._sigpipe_handler(*args)
- Return type:
None
- pyflyby._cmdline.action_changedexit1(m)
Exit with code 1 if there were changes.
- Return type:
None
- pyflyby._cmdline.action_exit1(m)
- Return type:
NoReturn
- pyflyby._cmdline.action_ifchanged(m)
- Return type:
None
- pyflyby._cmdline.action_nothing(m)
- Return type:
None
- pyflyby._cmdline.action_print(m)
- Return type:
None
- pyflyby._cmdline.action_replace(m)
- Return type:
None
- pyflyby._cmdline.filename_args(args, on_error=<function _default_on_error>)
Return list of filenames given command-line arguments.
- Return type:
List[Filename]listof Filename
- pyflyby._cmdline.hfmt(s)
- Return type:
str
- pyflyby._cmdline.maindoc()
- Return type:
str
- pyflyby._cmdline.parse_args(addopts=None, modify_action_params=False)
Do setup for a top-level script and parse arguments.
Performs common setup for pyflyby command-line tools: installs a SIGPIPE handler, builds an optparse.OptionParser, registers the standard options (
--debug,--verbose,--quiet,--version), optionally adds groups of action and/or pretty-printing options, parsessys.argv, and post-processes the result.The
--uniform/--unalignedshortcuts and the default--symlinksvalue are applied after parsing, and (whenimport_format_paramsis set) the import-formatting options are collected into an ImportFormatParams instance attached asoptions.params.- Parameters:
addopts (
callableorNone) – Optional callback invoked asaddopts(parser)to register additional, script-specific options on the parser before arguments are parsed.import_format_params (
bool) – If true, add the “Pretty-printing options” group (e.g.--align-imports,--from-spaces,--width,--black,--hanging-indent,--uniform,--unaligned) and attach the resulting ImportFormatParams asoptions.params.modify_action_params (
bool) – If true, add the “Action options” group (e.g.--actions,--print,--diff,--replace,--interactive) and the--symlinksoption, which control what is done with files that would be modified.
- Return type:
tupleof (optparse.Values,listofstr)- Returns:
A
(options, args)pair, whereoptionsholds the parsed option values andargsis the list of remaining positional arguments (typically filenames).
- pyflyby._cmdline.print_version_and_exit(extra=None)
- Return type:
NoReturn
- pyflyby._cmdline.process_actions(filenames, actions, modify_function, reraise_exceptions=(), exclude=())
- Return type:
NoReturn
- pyflyby._cmdline.symlink_callback(option, opt_str, value, parser)
- pyflyby._cmdline.symlink_error(m)
- Return type:
None
- pyflyby._cmdline.symlink_follow(m)
- Return type:
None
- pyflyby._cmdline.symlink_replace(m)
- Return type:
None
- pyflyby._cmdline.symlink_skip(m)
- Return type:
None
- pyflyby._cmdline.symlink_warn(m)
- Return type:
None
- pyflyby._cmdline.syntax(message=None, usage=None)
- Return type:
NoReturn