webchanges.cli module
Module containing the entry point: the function main().
- webchanges.cli.python_version_warning()
Check if we’re running on the minimum Python version supported and if so print and issue a pending deprecation warning.
- Return type:
None
- webchanges.cli.migrate_from_legacy(legacy_package, config_file=None, jobs_file=None, hooks_file=None, ssdb_file=None)
Check for existence of legacy files for configuration, jobs and Python hooks and migrate them (i.e. make a copy to new folder and/or name). Original files are not deleted.
- Parameters:
legacy_package (str) – The name of the legacy package to migrate (e.g. urlwatch).
config_file (Path | None) – The new Path to the configuration file.
jobs_file (Path | None) – The new Path to the jobs file.
hooks_file (Path | None) – The new Path to the hooks file.
ssdb_file (Path | None) – The new Path to the snapshot database file.
- Return type:
None
- webchanges.cli.setup_logger(verbose=None, log_file=None)
Set up the logger.
- Parameters:
verbose (int | None) – the verbosity level (1 = INFO, 2 = ERROR, 3 = NOTSET).
log_file (Path | None)
- Return type:
None
- webchanges.cli.teardown_logger(verbose=None)
Clean up logging.
- Parameters:
verbose (int | None) – the verbosity level (1 = INFO, 2 = ERROR).
- Return type:
None
- webchanges.cli.locate_glob_files(filenames, default_path, ext=None, prefix=None)
- Parameters:
filenames (list[Path])
default_path (Path)
ext (str | None)
prefix (str | None)
- Return type:
list[Path]
- webchanges.cli.locate_storage_file(filename, default_path, ext=None, prefix=None)
Searches for file both as specified and in the default directory, then retries with ‘ext’ extension if defined.
- Parameters:
filename (Path) – The filename.
default_path (Path) – The default directory.
ext (str | None) – The extension, e.g. ‘.yaml’, to add for searching if first scan fails.
prefix (str | None) – The prefix, e.g. ‘config’, to add with a hypen (e.g. ‘config-’) for searching if first scan fails.
- Returns:
The filename, either original or one with path where found and/or extension.
- Return type:
Path
- webchanges.cli.locate_storage_files(filename_list, default_path, ext=None, prefix=None)
Searches for file both as specified and in the default directory, then retries with ‘ext’ extension if defined.
- Parameters:
filename_list (list[Path]) – The list of filenames.
default_path (Path) – The default directory.
ext (str | None) – The extension, e.g. ‘.yaml’, to add for searching if first scan fails.
prefix (str | None) – The prefix, e.g. ‘config’, to add with a hypen (e.g. ‘config-’) for searching if first scan fails.
- Returns:
The list filenames, either originals or ones with path where found and/or extension.
- Return type:
set[Path]
- webchanges.cli.first_run(command_config)
Create configuration and jobs files.
- Parameters:
command_config (CommandConfig) – the CommandConfig containing the command line arguments selected.
- Return type:
None
- webchanges.cli.load_hooks(hooks_file, is_default=False)
Load hooks file.
- Parameters:
hooks_file (Path)
is_default (bool)
- Return type:
None
- webchanges.cli.sync_bundled_schemas(command_config)
Deploy bundled JSON schemas next to the user’s
config.yamlandjobs.yaml.config.schema.jsonis written next to the--configfile;jobs.schema.jsonnext to the first--jobsfile. A sibling.*.sha256file records the deployed hash so subsequent runs can detect when the bundled schema has changed without re-hashing on every invocation.- Parameters:
command_config (CommandConfig)
- Return type:
None
- webchanges.cli.handle_unitialized_actions(urlwatch_config, default_config_file=None)
Handles CLI actions that do not require all classes etc. to be initialized (and command.py loaded). For speed purposes.
The editor commands (
--edit-jobs,--edit-config,--edit-hooks) are dispatched here too so that a malformed user file does not block the user from opening it.default_config_fileis the platform default so we can mirrormain()’sfirst_rungate.- Parameters:
urlwatch_config (CommandConfig)
default_config_file (Path | None)
- Return type:
None
- webchanges.cli.show_detailed_versions()
Prints the detailed versions, including of dependencies.
- Returns:
- Return type:
int
- webchanges.cli.main()
The entry point run when __name__ == ‘__main__’.
Contains all the high-level logic to instantiate all classes that run the program.
- Raises:
NotImplementedError – If a –database-engine is specified that is not supported.
RuntimeError – If –database-engine redis is selected but –cache with a redis URI is not provided.
- Return type:
None