From 6d59158aba946fbdeabf33c347595c4cf4712ada Mon Sep 17 00:00:00 2001 From: Greg Kempe Date: Fri, 1 Sep 2023 13:56:27 +0200 Subject: [PATCH] pyproject.toml --- .github/workflows/publish.yml | 28 ++++ MANIFEST.in | 2 - README.md | 249 +++++++++++++++++++++++++++++++ README.rst | 272 ---------------------------------- VERSION | 1 - cobalt/__init__.py | 2 + pyproject.toml | 44 ++++++ setup.py | 83 +---------- 8 files changed, 325 insertions(+), 356 deletions(-) create mode 100644 .github/workflows/publish.yml delete mode 100644 MANIFEST.in create mode 100644 README.md delete mode 100644 README.rst delete mode 100644 VERSION create mode 100644 pyproject.toml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7148dfc --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,28 @@ +name: Publish to PyPI + +on: + release: + types: [created] + +jobs: + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/bluebell-akn + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Build distribution + run: python -m pip install build && python -m build + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 7c928d1..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include LICENSE README.rst VERSION -recursive-include cobalt *.py *.xsd diff --git a/README.md b/README.md new file mode 100644 index 0000000..f5a375e --- /dev/null +++ b/README.md @@ -0,0 +1,249 @@ +# Cobalt + +![image](https://laws.africa/img/icons/cobalt.png) + +[![image](https://badge.fury.io/py/cobalt.svg)](http://badge.fury.io/py/cobalt) + +Cobalt is a lightweight Python library for working with [Akoma Ntoso](http://www.akomantoso.org/) documents. It makes it +easy to work with Akoma Ntoso documents, metadata and FRBR URIs. + +It is lightweight because most operations are done on the XML document directly without intermediate objects. You still +need to understand how Akoma Ntoso works. + +Read the [full documentation at cobalt.readthedocs.io](http://cobalt.readthedocs.io/en/latest/). + +## Quickstart + +Install using: + + $ pip install cobalt + +Use it like this: + + >>> from cobalt import Act + >>> act = Act() + >>> act.title = "Act 10 of 1980" + >>> act.frbr_uri = "/za/act/1980-05-03/10" + >>> act.frbr_uri.year + '1980' + >>> act.frbr_uri.date + '1980-05-03' + >>> act.frbr_uri.number + '10' + >>> act.frbr_uri.doctype + 'act' + >>> print act.to_xml() + [ lots of xml ] + +## Contributing + +1. Clone the repo +2. Install development dependencies: + + pip install -e .[dev] + +3. Make your changes +4. Run tests: + + nosetests && flake8 cobalt + +5. Send a pull request + +## Releasing a New Version + +1. Run the tests! +2. Update VERSION appropriately +3. Update the Change Log section in README.rst +4. Commit and tag: + + git tag vX.X.X + git push -u origin --tags + +5. Build artefacts: + + rm -rf build dist && python setup.py sdist bdist_wheel + +6. Upload to PyPI: + + twine upload dist/* + +# License and Copyright + +Cobalt is licensed under the LPGL 3.0 license. + +Cobalt is Copyright 2015-2020 AfricanLII. + +## Change Log + +### 8.0.0 + +- Parser now accepts both strings and bytes, and will encode strings to bytes using UTF-8 + +### 7.0.0 + +- Rename `DebateReport` to `Debate` + +### 6.1.0 + +- Add new schemas.AkomaNtoso30 class with basic schema information + +### 6.0.0 + +- Add support for portions, such as `~chp_2` +- Remove non-standard support for expression component and + subcomponent +- Remove non-standard legacy support for work components without `!` + +### 5.0.0 + +- Allow slashes in FRBR URI work component names +- Setting expression and manifestation dates updates attachments and + other components +- Don\'t include Cobalt-specific `` element in attachments +- Cascade changes to FRBRlanguage into attachments +- Don\'t hardcode source +- Don\'t set `contains="originalVersion"` since it is the default + value for that attribute. +- Use `0001-01-01` as a placeholder date for publication, amendment + and repeal events with null dates + +### 4.1.1 + +- Change eIds of content produced by empty_document_content() + +### 4.1.0 + +- Allow setting of missing component names + +### 4.0.2 + +- Better error handling when parsing malformed XML. + +### 4.0.1 + +(replaced by 4.0.2) + +### 4.0.0 + +- Support AKN 3.0 namespaces +- Produce URIs with `akn` prefix by default (backwards compatibility + maintained) +- Support all Akoma Ntoso document types +- Start FRBR URI work component with `!` (eg. `!main`) +- FRBRcountry uses full country code from the FRBR URI +- FRBRnumber uses number portion from FRBR URI +- FRBRdate for FRBRWork contains the date portion of the FRBR URI +- Include AKN 3.0 schema and support for validating against the schema +- The elements returned by `components()` are now `attachment` or + `component` elements, not the inner `doc` + +### 3.1.1 + +- FIX issue where a four-digit number in an FRBR URI confuses the + parser + +### 3.1.0 + +- Replace arrow with iso8601, avoiding [arrow issue + 612](https://github.com/crsmithdev/arrow/issues/612) + +### 3.0.0 + +- Python 3.6 and 3.7 support +- Drop support for Python 2.x + +### 2.2.0 + +- FIX don\'t mistake numbers in uris with subtypes and numeric numbers + as actors +- FIX link to GitHub +- Unicode literals when parsing FRBR URIs + +### 2.1.0 + +- FIX don\'t strip empty whitespace during objectify.fromstring + +### 2.0.0 + +- FIX don\'t pretty-print XML, it introduces meaningful whitespace + +### 1.0.1 + +- FIX FrbrUri clone bug when a URI had a language. + +### 1.0.0 + +- Move table of contents, render and other locale (legal tradition) + specific functionality out of Cobalt. +- FIX bug that returned the incorrect language when extracting a + document\'s expression URI. + +### 0.3.2 + +- Inject original img src as data-src + +### 0.3.1 + +- Support for i18n in XSLT files, including all 11 South African + languages from myconstitution.co.za + +### 0.3.0 + +- Support for images +- Change how XSLT params are passed to the renderer +- Add expression_frbr_uri method to Act class + +### 0.2.1 + +- When rendering HTML, ensure primary container elements and schedules + have appropriate ids + +### 0.2.0 + +- When rendering HTML, scope component/schedule ids to ensure they\'re + unique + +### 0.1.11 + +- Render ref elements as HTML a elements +- Optionally prepend a resolver URL before a elements + +### 0.1.10 + +- Convert EOL elements to BR when changing XML to HTML + +### 0.1.9 + +- Support dates before 1900. Contributed by rkunal. + +### 0.1.8 + +- lifecycle and identification meta elements now have a configurable + source attribute + +### 0.1.7 + +- TOCElement items now include a best-effort title + +### 0.1.6 + +- Use HTML5 semantic elements section and article when generating HTML + for acts + +### 0.1.5 + +- FIX use schedule FRBRalias as heading + +### 0.1.4 + +- Transforming XML to HTML now includes all attributes as data- + attributes + +### 0.1.3 + +- Refactor TOC helpers into own file +- Fix .format in FrbrUri + +### 0.1.1 + +- first release diff --git a/README.rst b/README.rst deleted file mode 100644 index 8d9fd62..0000000 --- a/README.rst +++ /dev/null @@ -1,272 +0,0 @@ -Cobalt -====== - -.. image:: https://laws.africa/img/icons/cobalt.png - -.. image:: https://badge.fury.io/py/cobalt.svg - :target: http://badge.fury.io/py/cobalt - -Cobalt is a lightweight Python library for working with `Akoma Ntoso `_ documents. -It makes it easy to work with Akoma Ntoso documents, metadata and FRBR URIs. - -It is lightweight because most operations are done on the XML document directly without intermediate -objects. You still need to understand how Akoma Ntoso works. - -Read the `full documentation at cobalt.readthedocs.io `_. - -Quickstart ----------- - -Install using:: - - $ pip install cobalt - -Use it like this:: - - >>> from cobalt import Act - >>> act = Act() - >>> act.title = "Act 10 of 1980" - >>> act.frbr_uri = "/za/act/1980-05-03/10" - >>> act.frbr_uri.year - '1980' - >>> act.frbr_uri.date - '1980-05-03' - >>> act.frbr_uri.number - '10' - >>> act.frbr_uri.doctype - 'act' - >>> print act.to_xml() - [ lots of xml ] - -Contributing ------------- - -1. Clone the repo -2. Install development dependencies:: - - pip install -e .[dev] - -3. Make your changes -4. Run tests:: - - nosetests && flake8 cobalt - -5. Send a pull request - -Releasing a New Version ------------------------ - -1. Run the tests! -2. Update VERSION appropriately -3. Update the Change Log section in README.rst -4. Commit and tag:: - - git tag vX.X.X - git push -u origin --tags - -5. Build artefacts:: - - rm -rf build dist && python setup.py sdist bdist_wheel - -6. Upload to PyPI:: - - twine upload dist/* - -License and Copyright ---------------------- - -Cobalt is licensed under the LPGL 3.0 license. - -Cobalt is Copyright 2015-2020 AfricanLII. - -Change Log ----------- - -8.0.0 ------ - -- Parser now accepts both strings and bytes, and will encode strings to bytes using UTF-8 - -7.0.0 ------ - -- Rename ``DebateReport`` to ``Debate`` - -6.1.0 ------ - -- Add new schemas.AkomaNtoso30 class with basic schema information - -6.0.0 ------ - -- Add support for portions, such as ``~chp_2`` -- Remove non-standard support for expression component and subcomponent -- Remove non-standard legacy support for work components without ``!`` - -5.0.0 ------ - -- Allow slashes in FRBR URI work component names -- Setting expression and manifestation dates updates attachments and other components -- Don't include Cobalt-specific ```` element in attachments -- Cascade changes to FRBRlanguage into attachments -- Don't hardcode source -- Don't set ``contains="originalVersion"`` since it is the default value for that attribute. -- Use ``0001-01-01`` as a placeholder date for publication, amendment and repeal events with null dates - -4.1.1 -..... - -- Change eIds of content produced by empty_document_content() - -4.1.0 -..... - -- Allow setting of missing component names - -4.0.2 -..... - -- Better error handling when parsing malformed XML. - -4.0.1 -..... - -(replaced by 4.0.2) - -4.0.0 -..... - -- Support AKN 3.0 namespaces -- Produce URIs with ``akn`` prefix by default (backwards compatibility maintained) -- Support all Akoma Ntoso document types -- Start FRBR URI work component with ``!`` (eg. ``!main``) -- FRBRcountry uses full country code from the FRBR URI -- FRBRnumber uses number portion from FRBR URI -- FRBRdate for FRBRWork contains the date portion of the FRBR URI -- Include AKN 3.0 schema and support for validating against the schema -- The elements returned by ``components()`` are now ``attachment`` or ``component`` elements, not the inner ``doc`` - -3.1.1 -..... - -- FIX issue where a four-digit number in an FRBR URI confuses the parser - -3.1.0 -..... - -- Replace arrow with iso8601, avoiding `arrow issue 612 `_ - -3.0.0 -..... - -- Python 3.6 and 3.7 support -- Drop support for Python 2.x - -2.2.0 -..... - -- FIX don't mistake numbers in uris with subtypes and numeric numbers as actors -- FIX link to GitHub -- Unicode literals when parsing FRBR URIs - -2.1.0 -..... - -- FIX don't strip empty whitespace during objectify.fromstring - -2.0.0 -..... - -- FIX don't pretty-print XML, it introduces meaningful whitespace - -1.0.1 -..... - -- FIX FrbrUri clone bug when a URI had a language. - -1.0.0 -..... - -- Move table of contents, render and other locale (legal tradition) specific functionality out of Cobalt. -- FIX bug that returned the incorrect language when extracting a document's expression URI. - -0.3.2 -..... - -- Inject original img src as data-src - -0.3.1 -..... - -- Support for i18n in XSLT files, including all 11 South African languages from myconstitution.co.za - -0.3.0 -..... - -- Support for images -- Change how XSLT params are passed to the renderer -- Add expression_frbr_uri method to Act class - -0.2.1 -..... - -- When rendering HTML, ensure primary container elements and schedules have appropriate ids - -0.2.0 -..... - -- When rendering HTML, scope component/schedule ids to ensure they're unique - -0.1.11 -...... - -- Render ref elements as HTML a elements -- Optionally prepend a resolver URL before a elements - -0.1.10 -...... - -- Convert EOL elements to BR when changing XML to HTML - -0.1.9 -..... - -- Support dates before 1900. Contributed by rkunal. - -0.1.8 -..... - -- lifecycle and identification meta elements now have a configurable source attribute - -0.1.7 -..... - -- TOCElement items now include a best-effort title - -0.1.6 -..... - -- Use HTML5 semantic elements section and article when generating HTML for acts - -0.1.5 -..... - -- FIX use schedule FRBRalias as heading - -0.1.4 -..... - -- Transforming XML to HTML now includes all attributes as data- attributes - -0.1.3 -..... - -- Refactor TOC helpers into own file -- Fix .format in FrbrUri - -0.1.1 -..... - -- first release diff --git a/VERSION b/VERSION deleted file mode 100644 index ae9a76b..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -8.0.0 diff --git a/cobalt/__init__.py b/cobalt/__init__.py index 4e03768..9500ab8 100644 --- a/cobalt/__init__.py +++ b/cobalt/__init__.py @@ -8,6 +8,8 @@ from .portion import PortionStructure, Portion from .uri import FrbrUri +__version__ = '8.0.0' + __all__ = [ 'Act', 'AkomaNtosoDocument', 'Amendment', 'AmendmentEvent', 'AmendmentList', 'AmendmentStructure', 'Bill', diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..29bbd9f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,44 @@ +[build-system] +requires = ["setuptools", "setuptools_scm[toml]>=6.2", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "cobalt" +description = "A lightweight library for working with Akoma Ntoso Act documents" +authors = [ + { name="Laws.Africa", email="info@laws.africa" }, +] +license = {text = "LGPLv3+"} +readme = "README.md" +requires-python = ">=3.7" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Text Processing", + "Topic :: Text Processing :: Markup :: XML", + "Intended Audience :: Legal Industry", + "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", + "Programming Language :: Python", + "Programming Language :: Python :: 3", +] +dependencies = [ + "iso8601 >= 0.1", + "lxml>=3.4.1", +] +dynamic = ["version"] + +[project.urls] +"Homepage" = "https://github.com/laws-africa/cobalt" +"Bug Tracker" = "https://github.com/laws-africa/cobalt/issues" + +[project.optional-dependencies] +test = ["nose", "flake8"] + +[tool.setuptools.packages.find] +include = ["cobalt"] # package names should match these glob patterns (["*"] by default) +exclude = ["tests*"] # exclude packages matching these glob patterns (empty by default) +namespaces = false + +[tool.setuptools.dynamic] +version = {attr = "cobalt.__version__"} + diff --git a/setup.py b/setup.py index 5e50d22..6068493 100644 --- a/setup.py +++ b/setup.py @@ -1,82 +1,3 @@ -from setuptools import setup, find_packages -from codecs import open -from os import path +from setuptools import setup -here = path.abspath(path.dirname(__file__)) - -# Get the long description from the relevant file -with open(path.join(here, 'README.rst'), encoding='utf-8') as f: - long_description = f.read() - -with open(path.join(here, 'VERSION')) as f: - version = f.read().strip() - -setup( - name='cobalt', - - # Versions should comply with PEP440. For a discussion on single-sourcing - # the version across setup.py and the project code, see - # https://packaging.python.org/en/latest/single_source_version.html - version=version, - - description='A lightweight library for working with Akoma Ntoso Act documents', - long_description=long_description, - - # The project's main homepage. - url='https://github.com/laws-africa/cobalt', - - # Author details - author='Laws.Africa', - author_email='greg@laws.africa', - - # Choose your license - license='GNU Lesser General Public License v3 (LGPLv3)', - - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - # How mature is this project? Common values are - # 3 - Alpha - # 4 - Beta - # 5 - Production/Stable - 'Development Status :: 4 - Beta', - - # Indicate who your project is intended for - 'Intended Audience :: Developers', - 'Topic :: Text Processing', - 'Topic :: Text Processing :: Markup :: XML', - 'Intended Audience :: Legal Industry', - - # Pick your license as you wish (should match "license" above) - 'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)', - - # Specify the Python versions you support here. In particular, ensure - # that you indicate whether you support Python 2, Python 3 or both. - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - ], - - # You can just specify the packages manually here if your project is - # simple. Or you can use find_packages(). - packages=find_packages(exclude=['docs', 'tests*']), - include_package_data=True, - - # List run-time dependencies here. These will be installed by pip when - # your project is installed. For an analysis of "install_requires" vs pip's - # requirements files see: - # https://packaging.python.org/en/latest/requirements.html - install_requires=[ - 'iso8601 >= 0.1', - 'lxml >= 3.4.1', - ], - - # List additional groups of dependencies here (e.g. development - # dependencies). You can install these using the following syntax, - # for example: - # $ pip install -e .[dev,test] - extras_require={ - 'dev': ['nose', 'flake8'], - 'test': ['nose', 'flake8'], - 'docs': ['Sphinx>=3'], - }, -) +setup()