Skip to content

Commit e2656a5

Browse files
authored
Update metadata and packaging files (#23)
1 parent 2b331f9 commit e2656a5

19 files changed

+131
-181
lines changed

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ formats:
2424
# Optionally declare the Python requirements required to build the docs
2525
python:
2626
install:
27-
- requirements: docs/source/rtd-req.txt
27+
- requirements: docs/source/requirements.txt

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# PyRCS
22

3-
[![PyPI](https://img.shields.io/pypi/v/pyrcs)](https://pypi.org/project/pyrcs/)
4-
[![Python Version](https://img.shields.io/pypi/pyversions/pyrcs)](https://www.python.org/downloads/)
5-
[![Documentation Status](https://readthedocs.org/projects/pyrcs/badge/?version=latest)](https://pyrcs.readthedocs.io/en/latest/?badge=latest)
6-
[![License](https://img.shields.io/pypi/l/pyrcs)](https://github.com/mikeqfu/pyrcs/blob/master/LICENSE)
7-
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/7369679225b14eaeb92ba40c12c339d5)](https://app.codacy.com/gh/mikeqfu/pyrcs/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
8-
[![Zenodo](https://zenodo.org/badge/92501006.svg)](https://zenodo.org/badge/latestdoi/92501006)
3+
[![PyPI - Version](https://img.shields.io/pypi/v/pyrcs)](https://pypi.org/project/pyrcs/)
4+
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyrcs)](https://www.python.org/downloads/)
5+
[![License](https://img.shields.io/github/license/mikeqfu/pyrcs)](https://github.com/mikeqfu/pyrcs/blob/master/LICENSE)
6+
[![Read the Docs - Documentation](https://readthedocs.org/projects/pyrcs/badge/?version=latest)](https://pyrcs.readthedocs.io/en/latest/?badge=latest)
7+
[![Codacy - Code Quality](https://app.codacy.com/project/badge/Grade/7369679225b14eaeb92ba40c12c339d5)](https://app.codacy.com/gh/mikeqfu/pyrcs/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
8+
[![DOI](https://zenodo.org/badge/92501006.svg)](https://zenodo.org/badge/latestdoi/92501006)
99

1010
PyRCS is an open-source Python package designed to simplify the collection and management of diverse codes used in different systems within the UK rail industry. It serves as a practical toolkit for researchers, practitioners, and individuals who frequently interact with the [Railway Codes](http://www.railwaycodes.org.uk/index.shtml) website and work extensively with railway codes in the UK. Leveraging the capabilities of the Python programming language, PyRCS enables efficient access to and manipulation of railway code data, enhancing productivity and effectiveness in working with these codes.
1111

@@ -35,24 +35,25 @@ For a concise guide on how to use PyRCS, check out the [Quick Start](https://pyr
3535

3636
The complete PyRCS Documentation is available in [HTML](https://pyrcs.readthedocs.io/en/latest/) and [PDF](https://pyrcs.readthedocs.io/_/downloads/en/latest/pdf/) formats.
3737

38-
It is hosted on [ReadTheDocs](https://readthedocs.org/projects/pyrcs/) and includes detailed usage examples.
38+
It is hosted on [Read the Docs](https://app.readthedocs.org/projects/pyrcs/), and the HTML version is also accessible via [GitHub Pages](https://mikeqfu.github.io/pyrcs/). The documentation includes detailed examples, tutorials and comprehensive references to help users get the most out of PyRCS.
3939

4040
## Cite as
4141

4242
Fu, Q. (2020). PyRCS: an open-source tool for collecting railway codes used in different UK rail industry systems. Zenodo. [doi:10.5281/zenodo.4026744](https://doi.org/10.5281/zenodo.4026744)
4343

4444
```bibtex
45-
@software{qian_fu_pyrcs_4026744,
46-
author = {Qian Fu},
45+
@software{Fu_PyRCS_2020,
46+
author = {Fu, Qian},
4747
title = {{PyRCS: An open-source tool for collecting railway codes used in different UK rail industry systems}},
4848
year = 2020,
4949
publisher = {Zenodo},
5050
doi = {10.5281/zenodo.4026744},
51-
url = {https://doi.org/10.5281/zenodo.4026744}
51+
license = {MIT},
52+
url = {https://github.com/mikeqfu/pyrcs}
5253
}
5354
```
5455

55-
For specific version references of PyRCS, please refer to [Zenodo](https://zenodo.org/search?q=conceptrecid%3A%224026744%22&f=allversions%3Atrue&l=list&p=1&s=10&sort=version).
56+
For specific version references, please refer to [Zenodo](https://zenodo.org/search?q=conceptrecid%3A%224026744%22&f=allversions%3Atrue&l=list&p=1&s=10&sort=version).
5657

5758
## License
5859

docs/source/conf.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
release = version # The full version, including alpha/beta/rc tags
2424

2525
# == General configuration =========================================================================
26-
import inspect
27-
import requests
28-
import warnings
29-
import pyrcs
30-
3126
extensions = [ # Sphinx extension module names, which can be named 'sphinx.ext.*' or custom ones:
3227
'sphinx.ext.autodoc',
3328
'sphinx.ext.autosummary',
@@ -47,13 +42,6 @@
4742
# "IPython.sphinxext.ipython_directive",
4843
]
4944

50-
# Validate URL for 'linkcode'
51-
main_url_ = f'https://github.com/mikeqfu/{__pkgname__}/blob'
52-
main_url = f'{main_url_}/{pyrcs.__version__}/{__pkgname__}'
53-
response = requests.get(main_url)
54-
if response.status_code == 404:
55-
main_url = f"{main_url_}/master"
56-
5745

5846
def linkcode_resolve(domain, info):
5947
"""
@@ -62,6 +50,18 @@ def linkcode_resolve(domain, info):
6250
(Adapted from https://github.com/pandas-dev/pandas/blob/main/doc/source/conf.py)
6351
"""
6452

53+
import inspect
54+
import requests
55+
import warnings
56+
import pyrcs
57+
58+
# Validate URL for 'linkcode'
59+
main_url_ = f'https://github.com/mikeqfu/{__pkgname__}/blob'
60+
main_url = f'{main_url_}/{pyrcs.__version__}/{__pkgname__}'
61+
response = requests.get(main_url)
62+
if response.status_code == 404:
63+
main_url = f"{main_url_}/master"
64+
6565
if domain != 'py' or not info['module']:
6666
return None
6767

@@ -145,6 +145,7 @@ def linkcode_resolve(domain, info):
145145
# Automatically documented members are sorted by source order ('bysource'):
146146
autodoc_member_order = 'bysource'
147147

148+
148149
# == Options for HTML and HTMLHelp output ==========================================================
149150
html_theme = 'furo' # The theme to use for HTML & HTML Help pages # 'sphinx_rtd_theme'
150151
html_title = __project__
@@ -241,8 +242,8 @@ def __init__(self, **options):
241242
# Grouping the document tree into LaTeX files:
242243
latex_documents = [
243244
('latexindex', # source start file
244-
__pkgname__ + '.tex', # target name
245-
__project__ + ' Documentation', # title
245+
f'{__pkgname__}.tex', # target name
246+
f'{__project__} Documentation', # title
246247
__author__, # author
247248
'manual', # document class ['howto', 'manual', or own class]
248249
1 # toctree only

docs/source/index.rst

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,34 @@
22
PyRCS
33
#####
44

5-
|PyPI| |Python| |Documentation| |License| |Codacy grade| |DOI|
5+
|PyPI - Version| |PyPI - Python Version| |Read the Docs - Documentation| |License| |Codacy - Code Quality| |DOI|
66

7-
.. |PyPI| image:: https://img.shields.io/pypi/v/pyrcs
8-
:alt: PyPI - Release
7+
.. |PyPI - Version| image:: https://img.shields.io/pypi/v/pyrcs
8+
:alt: PyPI - Version
99
:target: https://pypi.org/project/pyrcs/
10-
.. |Python| image:: https://img.shields.io/pypi/pyversions/pyrcs
11-
:alt: Python version
10+
.. |PyPI - Python Version| image:: https://img.shields.io/pypi/pyversions/pyrcs
11+
:alt: PyPI - Python Version
1212
:target: https://www.python.org/downloads/
13-
.. |Documentation| image:: https://readthedocs.org/projects/pyrcs/badge/?version=latest
14-
:alt: Documentation status
13+
.. |Read the Docs - Documentation| image:: https://img.shields.io/readthedocs/pyrcs?logo=readthedocs
14+
:alt: Read the Docs - Documentation
1515
:target: https://pyrcs.readthedocs.io/en/latest/?badge=latest
16-
.. |License| image:: https://img.shields.io/pypi/l/pyrcs
16+
.. |License| image:: https://img.shields.io/github/license/mikeqfu/pyrcs
1717
:alt: License
1818
:target: https://github.com/mikeqfu/pyrcs/blob/master/LICENSE
19-
.. |Codacy grade| image:: https://app.codacy.com/project/badge/Grade/7369679225b14eaeb92ba40c12c339d5
20-
:alt: Codacy grade (Code quality)
19+
.. |Codacy - Code Quality| image:: https://app.codacy.com/project/badge/Grade/7369679225b14eaeb92ba40c12c339d5
20+
:alt: Codacy - Code Quality
2121
:target: https://www.codacy.com/gh/mikeqfu/pyrcs/dashboard?utm_source=github.com&utm_medium=referral&utm_content=mikeqfu/pyrcs&utm_campaign=Badge_Grade
22-
.. |DOI| image:: https://zenodo.org/badge/92501006.svg
23-
:alt: Zenodo - DOI
24-
:target: https://zenodo.org/badge/latestdoi/92501006
22+
.. |DOI| image:: https://img.shields.io/badge/10.5281%2Fzenodo.4026744-blue?label=doi
23+
:alt: DOI
24+
:target: https://doi.org/10.5281/zenodo.4026744
2525

26-
| **Author**: Qian Fu
26+
| **Author**: Qian Fu |ORCID|
2727
| **Email**: [email protected]
2828
29+
.. |ORCID| image:: https://info.orcid.org/wp-content/uploads/2019/11/orcid_16x16.png
30+
:alt: ORCID
31+
:target: https://orcid.org/0000-0002-6502-9934
32+
2933
PyRCS is an open-source Python package designed to simplify the collection and management of diverse codes used in different systems within the UK rail industry. It serves as a practical toolkit for researchers, practitioners, and individuals who frequently interact with the `Railway Codes <http://www.railwaycodes.org.uk/index.shtml>`_ website and work extensively with railway codes in the UK. Leveraging the capabilities of the Python programming language, PyRCS enables efficient access to and manipulation of railway code data, enhancing productivity and effectiveness in working with these codes.
3034

3135
During :doc:`installation`, PyRCS includes a set of pre-packaged data. When users request data from a specific category listed on the `Railway Codes <http://www.railwaycodes.org.uk/index.shtml>`_ website, PyRCS automatically loads the corresponding pre-packaged data for that category by default. Additionally, it provides functionality that enables direct access to the latest data from the data source website, ensuring users can stay updated with the most current information. Furthermore, PyRCS users can conveniently update the relevant pre-packaged data, keeping their data resources synchronized with the latest developments.

docs/source/installation.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.. _pyrcs-installation:
2-
31
============
42
Installation
53
============

docs/source/modules.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.. _pyrcs-modules:
2-
31
=======
42
Modules
53
=======

docs/source/quick-start.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ Alternatively, we can create the instance using the :class:`~pyrcs.collector.Lin
4747
- The instance ``ld`` encompasses all classes within the `line data`_ category.
4848
- ``lid_`` is equivalent to ``lid``.
4949

50-
.. _quickstart-location-identifiers-given-initial:
50+
.. _quickstart-location-identifiers-by-initial-letter:
5151

52-
Location identifiers for a specific initial letter
53-
--------------------------------------------------
52+
Location identifiers by initial letter
53+
--------------------------------------
5454

55-
We can retrieve codes (in `pandas.DataFrame`_ format) for all locations starting with a specific letter using the :meth:`LocationIdentifiers.collect_codes_by_initial()<pyrcs.line_data.LocationIdentifiers.collect_codes_by_initial>` method. This method is case-insensitive. For example, to get the codes for locations whose names begin with the letter ``'A'`` (or ``'a'``):
55+
We can retrieve codes (in `pandas.DataFrame`_ format) for all locations starting with a specific letter using the :meth:`LocationIdentifiers.collect_codes_by_initial()<pyrcs.line_data.LocationIdentifiers.collect_codes_by_initial>` method. This input value for the parameter is case-insensitive. For example, to get the codes for locations whose names begin with the letter ``'A'`` (or ``'a'``):
5656

5757
.. code-block:: python
5858
@@ -92,7 +92,7 @@ A snapshot of the data contained in ``loc_a_codes`` is demonstrated below:
9292
>>> print("Last updated date: {}".format(loc_a_codes['Last updated date']))
9393
Last updated date: 2024-08-24
9494
95-
.. _quickstart-all-location-identifiers:
95+
.. _quickstart-all-available-location-identifiers:
9696

9797
All available location identifiers
9898
----------------------------------
@@ -222,7 +222,7 @@ The ``elrs_a_codes`` object is a dictionary with the following *keys*:
222222

223223
The corresponding *values* are:
224224

225-
- ``elrs_a_codes['A']`` - Data for ELRs that begin with ``'A'`` (referring to the table presented on the web page `ELRs beginning with A`_).
225+
- ``elrs_a_codes['A']`` - Data for ELRs that begin with ``'A'``, referring to the table presented on the `ELRs beginning with A`_ web page.
226226
- ``elrs_a_codes['Last updated date']`` - The date when the `ELRs beginning with A`_ web page was last updated.
227227

228228
Here is a snapshot of the data contained in ``elrs_a_codes``:
@@ -260,7 +260,7 @@ Similarly, ``elrs_codes`` is a dictionary with the following *keys*:
260260

261261
The corresponding *values* are:
262262

263-
- ``elrs_codes['ELRs and mileages']`` - Codes for all available ELRs (with the initial letters ranging from ``'A'`` to ``'Z'``);
263+
- ``elrs_codes['ELRs and mileages']`` - Codes for all available ELRs (with the initial letters ranging from ``'A'`` to ``'Z'``).
264264
- ``elrs_codes['Latest update date']`` - The most recent update date among all the ELR data.
265265

266266
Here is a snapshot of the data contained in ``elrs_codes``:
@@ -279,7 +279,7 @@ Here is a snapshot of the data contained in ``elrs_codes``:
279279
4579 ZZZ9 Dummy ELR for demonstrations and testing ... n/a
280280
[5 rows x 5 columns]
281281
282-
.. _quickstart-mileage-files-given-elr:
282+
.. _quickstart-mileage-file-of-a-given-elr:
283283
284284
Mileage file of a given ELR
285285
---------------------------
@@ -296,7 +296,7 @@ For example, to get the `mileage file for 'AAM'`_:
296296
>>> list(amm_mileage_file.keys())
297297
['ELR', 'Line', 'Sub-Line', 'Mileage', 'Notes']
298298
299-
The ``amm_mileage_file`` is also a dictionary and has the following *keys*:
299+
The ``amm_mileage_file`` object is also a dictionary and has the following *keys*:
300300
301301
- ``'ELR'``
302302
- ``'Line'``
@@ -364,10 +364,10 @@ Alternatively, we can also create the instance by using the :class:`~pyrcs.colle
364364
- The instance ``stn`` encompasses all classes within the `other assets`_ category.
365365
- ``stn_`` is equivalent to ``stn``.
366366

367-
.. _quickstart-railway-station-locations-given-initial:
367+
.. _quickstart-railway-stations-by-initial-letter:
368368

369-
Railway station locations given a specific initial letter
370-
---------------------------------------------------------
369+
Railway stations by initial letter
370+
----------------------------------
371371

372372
We can obtain railway station data based on the first letter (e.g. ``'A'`` or ``'Z'``) of the station's name using the :meth:`Stations.collect_locations_by_initial()<pyrcs.other_assets.Stations.collect_locations_by_initial>` method. For example, to get data for stations starting with ``'A'``:
373373

@@ -429,10 +429,10 @@ Here is a snapshot of the data contained in ``stn_loc_a``:
429429
>>> print("Last updated date: {}".format(stn_loc_a_codes['Last updated date']))
430430
Last updated date: 2024-09-23
431431
432-
.. _quickstart-all-railway-station-locations:
432+
.. _quickstart-all-available-railway-stations:
433433

434-
All available railway station locations
435-
---------------------------------------
434+
All available railway stations
435+
------------------------------
436436

437437
To retrieve data for all railway stations available in the `other assets`_ category, we can use the :meth:`Stations.fetch_locations()<pyrcs.other_assets.Stations.fetch_locations>` method:
438438

@@ -451,7 +451,7 @@ The dictionary ``stn_loc_codes`` includes the following *keys*:
451451

452452
The corresponding *values* are:
453453

454-
- ``stn_loc_codes['Mileages, operators and grid coordinates']`` - Data for all railway stations, with the initial letters ranging from ``'A'`` to ``'Z'``;
454+
- ``stn_loc_codes['Mileages, operators and grid coordinates']`` - Data for all railway stations, with the initial letters ranging from ``'A'`` to ``'Z'``.
455455
- ``stn_loc_codes['Latest update date']`` - The most recent update date among all the station data.
456456

457457
Here is a snapshot of the data contained in ``stn_loc_codes``:
File renamed without changes.

pyrcs/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
import json
77
import pkgutil
88

9-
from .collector import *
9+
from .collector import LineData, OtherAssets
10+
from .line_data import Bridges, ELRMileages, Electrification, LOR, LineNames, LocationIdentifiers, \
11+
TrackDiagrams
12+
from .other_assets import Depots, Features, SignalBoxes, Stations, Tunnels, Viaducts
1013

11-
metadata = json.loads(pkgutil.get_data(__name__, "data/metadata").decode())
14+
metadata = json.loads(pkgutil.get_data(__name__, "data/.metadata").decode())
1215

1316
__project__ = metadata['Project']
1417
__pkgname__ = metadata['Package']

pyrcs/collector.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99
"""
1010

1111
import time
12-
import urllib.parse
1312

1413
from pyhelpers.ops import confirmed
1514

16-
from .line_data import (Bridges, ELRMileages, Electrification, LOR, LineNames, LocationIdentifiers,
17-
TrackDiagrams)
15+
from .line_data import Bridges, ELRMileages, Electrification, LOR, LineNames, LocationIdentifiers, \
16+
TrackDiagrams
1817
from .other_assets import Depots, Features, SignalBoxes, Stations, Tunnels, Viaducts
1918
from .parser import get_category_menu
20-
from .utils import home_page_url, is_home_connectable, print_conn_err, print_inst_conn_err
19+
from .utils import is_home_connectable, print_conn_err, print_inst_conn_err
2120

2221

2322
class LineData:
@@ -31,10 +30,6 @@ class LineData:
3130
#: The name of the data.
3231
NAME: str = 'Line data'
3332

34-
#: The URL of the main web page for the data.
35-
URL: str = urllib.parse.urljoin(
36-
home_page_url(), '{}menu.shtm'.format(NAME.lower().replace(' ', '')))
37-
3833
def __init__(self, update=False, verbose=True):
3934
"""
4035
:param update: Whether to check for updates to the catalogue; defaults to ``False``.
@@ -101,7 +96,7 @@ def __init__(self, update=False, verbose=True):
10196
else:
10297
self.connected = True
10398

104-
self.catalogue = get_category_menu(url=self.URL, update=update, confirmation_required=False)
99+
self.catalogue = get_category_menu(self.NAME, update=update, confirmation_required=False)
105100

106101
# Relevant classes
107102
self.ELRMileages = ELRMileages(update=update, verbose=False)
@@ -205,10 +200,6 @@ class OtherAssets:
205200
#: The name of the data.
206201
NAME: str = 'Other assets'
207202

208-
#: The URL of the main web page for the data.
209-
URL: str = urllib.parse.urljoin(
210-
home_page_url(), '{}menu.shtm'.format(NAME.lower().replace(' ', '')))
211-
212203
def __init__(self, update=False, verbose=True):
213204
"""
214205
:param update: Whether to check for updates to the catalogue; defaults to ``False``.
@@ -271,7 +262,7 @@ def __init__(self, update=False, verbose=True):
271262
else:
272263
self.connected = True
273264

274-
self.catalogue = get_category_menu(url=self.URL, update=update, confirmation_required=False)
265+
self.catalogue = get_category_menu(self.NAME, update=update, confirmation_required=False)
275266

276267
# Relevant classes
277268
self.SignalBoxes = SignalBoxes(update=update, verbose=False)

pyrcs/data/metadata

Lines changed: 0 additions & 11 deletions
This file was deleted.

pyrcs/line_data/elec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ def _collect_notes(h3):
123123
while h3_ == h3:
124124
notes_2 = get_hypertext(hypertext_tag=next_p, hyperlink_tag_name='a')
125125
if notes_2:
126-
notes_2 = notes_2. \
127-
replace(' Section codes known at present are:', ''). \
128-
replace('Known prefixes are:', ' ')
126+
notes_2 = notes_2.replace(
127+
' Section codes known at present are:', '').replace(
128+
'Known prefixes are:', ' ')
129129
notes_.append(notes_2)
130130

131131
next_p = next_p.find_next('p')

0 commit comments

Comments
 (0)