SignalBoxes

A class for collecting signal box prefix codes.

SignalBoxes.collect_signal_box_prefix_codes(initial) Collect signal box prefix codes for the given initial from source web page.
SignalBoxes.fetch_signal_box_prefix_codes([…]) Fetch signal box prefix codes from local backup.
SignalBoxes.collect_non_national_rail_codes([…]) Collect signal box prefix codes of non-national rail from source web page.
SignalBoxes.fetch_non_national_rail_codes([…]) Fetch signal box prefix codes of non-national rail from local backup.
class pyrcs.other_assets.SignalBoxes(data_dir=None, update=False)[source]

A class for collecting signal box prefix codes.

Parameters:
  • data_dir (str, None) – name of data directory, defaults to None
  • update (bool) – whether to check on update and proceed to update the package data, defaults to False

Example:

from pyrcs.other_assets import SignalBoxes

sb = SignalBoxes()

print(sb.Name)
# Signal box prefix codes

print(sb.SourceURL)
# http://www.railwaycodes.org.uk/signal/signal_boxes0.shtm
collect_signal_box_prefix_codes(initial, update=False, verbose=False)[source]

Collect signal box prefix codes for the given initial from source web page.

Parameters:
  • initial (str) – initial letter of signal box name (for specifying a target URL)
  • update (bool) – whether to check on update and proceed to update the package data, defaults to False
  • verbose (bool, int) – whether to print relevant information in console as the function runs, defaults to False
Returns:

data of signal box prefix codes for the given initial and date of when the data was last updated

Return type:

dict

Example:

from pyrcs.other_assets import SignalBoxes

sb = SignalBoxes()

update = False

initial = 'a'
signal_boxes_a = sb.collect_signal_box_prefix_codes(initial, update)

print(signal_boxes_a)
# {'A': <codes>,
#  'Last updated date': <date>}
fetch_signal_box_prefix_codes(update=False, pickle_it=False, data_dir=None, verbose=False)[source]

Fetch signal box prefix codes from local backup.

Parameters:
  • update (bool) – whether to check on update and proceed to update the package data, defaults to False
  • pickle_it (bool) – whether to replace the current package data with newly collected data, defaults to False
  • data_dir (str, None) – name of package data folder, defaults to None
  • verbose (bool, int) – whether to print relevant information in console as the function runs, defaults to False
Returns:

data of location codes and date of when the data was last updated

Return type:

dict

Example:

from pyrcs.other_assets import SignalBoxes

sb = SignalBoxes()

update = False
pickle_it = False
data_dir = None

signal_box_prefix_codes = sb.fetch_signal_box_prefix_codes(update, pickle_it, data_dir)

print(signal_box_prefix_codes)
# {'Signal boxes': <codes>,
#  'Latest update date': <date>}
collect_non_national_rail_codes(confirmation_required=True, verbose=False)[source]

Collect signal box prefix codes of non-national rail from source web page.

Parameters:
  • confirmation_required (bool) – whether to require users to confirm and proceed, defaults to True
  • verbose (bool, int) – whether to print relevant information in console as the function runs, defaults to False
Returns:

signal box prefix codes of non-national rail

Return type:

dict, None

Example:

from pyrcs.other_assets import SignalBoxes

sb = SignalBoxes()

confirmation_required = True

non_national_rail_codes_data = sb.collect_non_national_rail_codes(confirmation_required)
# To collect signal box data of non-national rail? [No]|Yes:
# >? yes

print(non_national_rail_codes_data)
# {'Non-national rail': <codes>,
#  'Last updated date': <date>}
fetch_non_national_rail_codes(update=False, pickle_it=False, data_dir=None, verbose=False)[source]

Fetch signal box prefix codes of non-national rail from local backup.

Parameters:
  • update (bool) – whether to check on update and proceed to update the package data, defaults to False
  • pickle_it (bool) – whether to replace the current package data with newly collected data, defaults to False
  • data_dir (str, None) – name of package data folder, defaults to None
  • verbose (bool, int) – whether to print relevant information in console as the function runs, defaults to False
Returns:

signal box prefix codes of non-national rail

Return type:

dict

Example:

from pyrcs.other_assets import SignalBoxes

sb = SignalBoxes()

update = False
pickle_it = False
data_dir = None

non_national_rail_codes_data = sb.fetch_non_national_rail_codes(update, pickle_it, data_dir)

print(non_national_rail_codes_data)
# {'Non-national rail': <codes>,
#  'Last updated date': <date>}