uwtools.api.file
API access to uwtools file-management tools.
- class uwtools.api.file.Copier(config=None, target_dir=None, cycle=None, leadtime=None, keys=None, dry_run=False)
Stage files by copying.
Handle files.
- Parameters:
config (dict | Path | str | None) – YAML-file path, or dict (read stdin if missing or None).
cycle (datetime | None) – A datetime object to make available for use in the config.
leadtime (timedelta | None) – A timedelta object to make available for use in the config.
keys (list[str] | None) – YAML keys leading to file dst/src block.
dry_run (bool) – Do not copy files.
- Raises:
UWConfigError if config fails validation.
- go()
Copy files.
- class uwtools.api.file.Linker(config=None, target_dir=None, cycle=None, leadtime=None, keys=None, dry_run=False)
Stage files by linking.
Handle files.
- Parameters:
config (dict | Path | str | None) – YAML-file path, or dict (read stdin if missing or None).
cycle (datetime | None) – A datetime object to make available for use in the config.
leadtime (timedelta | None) – A timedelta object to make available for use in the config.
keys (list[str] | None) – YAML keys leading to file dst/src block.
dry_run (bool) – Do not copy files.
- Raises:
UWConfigError if config fails validation.
- go()
Link files.
- uwtools.api.file.copy(config=None, target_dir=None, cycle=None, leadtime=None, keys=None, dry_run=False, stdin_ok=False)
Copy files.
- Parameters:
config (dict | Path | str | None) – YAML-file path, or
dict(readstdinif missing orNone).cycle (datetime | None) – A datetime object to make available for use in the config.
leadtime (timedelta | None) – A timedelta object to make available for use in the config.
keys (list[str] | None) – YAML keys leading to file dst/src block.
dry_run (bool) – Do not copy files.
stdin_ok (bool) – OK to read from
stdin?
- Returns:
Trueif all copies were created.- Return type:
- uwtools.api.file.link(config=None, target_dir=None, cycle=None, leadtime=None, keys=None, dry_run=False, stdin_ok=False)
Link files.
- Parameters:
config (dict | Path | str | None) – YAML-file path, or
dict(readstdinif missing orNone).cycle (datetime | None) – A datetime object to make available for use in the config.
leadtime (timedelta | None) – A timedelta object to make available for use in the config.
keys (list[str] | None) – YAML keys leading to file dst/src block.
dry_run (bool) – Do not link files.
stdin_ok (bool) – OK to read from
stdin?
- Returns:
Trueif all links were created.- Return type: