get_catalogue

pyrcs.utils.get_catalogue(url, update=False, confirmation_required=True, json_it=True, verbose=False)

Get the catalogue for a class.

Parameters
  • url (str) – URL of the main page of a code category

  • update (bool) – whether to do an update check (for the package data), defaults to False

  • confirmation_required (bool) – whether to confirm before proceeding, defaults to True

  • json_it (bool) – whether to save the catalogue as a JSON file, defaults to True

  • verbose (bool or int) – whether to print relevant information in console, defaults to False

Returns

catalogue in the form {‘<title>’: ‘<URL>’}

Return type

dict or None

Examples:

>>> from pyrcs.utils import get_catalogue

>>> cat = get_catalogue(url='http://www.railwaycodes.org.uk/elrs/elr0.shtm')
>>> type(cat)
dict
>>> list(cat.keys())[:5]
['Introduction', 'A', 'B', 'C', 'D']

>>> cat = get_catalogue(url='http://www.railwaycodes.org.uk/linedatamenu.shtm')
>>> list(cat.keys())[:5]
['Line data']

>>> line_data_cat = cat['Line data']
>>> type(line_data_cat)
dict
>>> list(line_data_cat.keys())
['ELRs and mileages',
 'Electrification masts and related features',
 'CRS, NLC, TIPLOC and STANOX Codes',
 'Line of Route (LOR/PRIDE) codes',
 'Line names',
 'Track diagrams']