Electrification.collect_independent_lines_codes

Electrification.collect_independent_lines_codes(confirmation_required=True, verbose=False, raise_error=False)[source]

Collect OLE section codes for independent lines from the source web page.

Parameters:
  • confirmation_required (bool) – Whether user confirmation is required; if confirmation_required=True (default), prompts the user for confirmation before proceeding with data collection.

  • verbose (bool | int) – Whether to print relevant information to the console. Defaults to False.

  • raise_error (bool) – Whether to raise the provided exception; if raise_error=False (default), the error will be suppressed.

Returns:

A dictionary of OLE section codes for independent lines, or None if not applicable.

Return type:

dict | None

Examples:

>>> from pyrcs.line_data import Electrification  # from pyrcs import Electrification

>>> elec = Electrification()

>>> indep_lines_codes = elec.collect_independent_lines_codes(verbose=True)
Proceed with collecting section codes for OLE installations: "Independent lines"?
 [No]|Yes: yes
Collecting the data ... Done.

>>> type(indep_lines_codes)
dict
>>> list(indep_lines_codes.keys())
['Independent lines', 'Last updated date']

>>> indep_lines_codes_dat = indep_lines_codes['Independent lines']
>>> type(indep_lines_codes_dat)
dict
>>> len(indep_lines_codes_dat)
24
>>> list(indep_lines_codes_dat.keys())[-5:]
['Snaefell Mountain Railway',
 'Summerlee, Museum of Scottish Industrial Life Tramway',
 'Tyne & Wear Metro',
 'West Midlands Metro [West Midlands]',
 'SPL Powerlines']

>>> indep_lines_codes_dat['Summerlee, Museum of Scottish Industrial Life Tramway']
{'Codes': None, 'Notes': 'Masts do not carry any labels.'}