Skip to content

rss2i.py: Rethink and Unify the -o output switch

There are several subcommands (download, restore, record, join, start, ...?) with an -o/--output switch available. However, they behave in a different way and I don't like any of them. Currently, the -o switch specifies an output folder for the start, download, restore and join subcommands. For the record subcommand, the -o switch specifies the complete output path. Instead, I would like the -o switch to define the prefix of the output path in all cases. The used output path should hence consist of the specified output prefix and some suffix. The individual suffixes depend on the subcommand and on time and date in some cases.

Furthermore, we should rename the mentioned suffixes as well as the file extensions in some cases, see below.

Current Behaviour

This creates the RSS data file path/to/file/0xy.tsv:

rss2i -a download -d xy -f conffile -o path/to/file

This saves the start addresses to the file path/to/file:

rss2i -a record -d xy -o path/to/file

However, the following saves the start addresses to the file path/to/file/start_addresses.txt:

rss2i -a start -d xy -o path/to/file

Desired Behaviour

In all cases, the -o should specify the prefix only. For the first example, this should lead to an RSS data file path/to/fileRSS_0xy.tsv. Note, that in contrast to the current behaviour, no file subdirectory should be created. Further note, that the suffix now also features the RSS keyword. In order to reproduce the current behaviour, i.e. creating the file subdirectory, the following command should be executed (Note the trailing slash):

rss2i -a download -d xy -f conffile -o path/to/file/

In the second and third case, the start addresses should be saved to a file path/to/filemem_addr.json. Note, that the suffix changed from start_addresses to mem_addr and that the file name extension changed from txt to json.

In all cases, the default behaviour should be -o ./<date>_<time>_, i.e. <date>_<time>_mem_addr.json and <date>_<time>_RSS_0xy.tsv.

To Do

  • Implement the desired behaviour.
  • Move the filename functionality (filename assembly, directory creation, optional date and time suffixes) into a separate function.
  • Update the argparse help text for all affected commands.