utils

Provide a number of helper functions.

Validate inputs

is_home_connectable()

Check whether the Railway Codes website is connectable.

is_str_float(x)

Check if a string-type variable can express a float-type value.

validate_initial(x[, as_is])

Get a valid initial letter as an input.

validate_page_name(cls, page_no, valid_page_no)

Get a valid page name.

collect_in_fetch_verbose(data_dir, verbose)

Create a new parameter that indicates whether to print relevant information in console (used only if it is necessary to re-collect data when trying to fetch the data).

fetch_all_verbose(data_dir, verbose)

Create a new parameter that indicates whether to print relevant information in console (used only when trying to fetch all data of a cluster).

Save and retrieve pre-packed data

init_data_dir(cls_instance, data_dir, category)

Specify an initial data directory for (an instance of) a class for a data cluster.

make_file_pathname(cls, data_name[, ext, ...])

Make a pathname for saving data as a file of a certain format.

fetch_location_names_errata([k, regex, ...])

Create a dictionary for rectifying location names.

save_data_to_file(cls, data, data_name, ext)

Save the collected data as a file, depending on the given parameters.

fetch_data_from_file(cls, method, data_name, ...)

Fetch/load desired data from a backup file, depending on the given parameters.