acdh-tei-pyutils


Nameacdh-tei-pyutils JSON
Version 1.1 PyPI version JSON
download
home_pagehttps://github.com/acdh-oeaw/acdh-tei-pyutils
SummaryUtilty functions to work with TEI Documents
upload_time2024-01-28 07:53:41
maintainer
docs_urlNone
authorPeter Andorfer, Daniel Stoxreiter
requires_python>=3.7
licenseMIT
keywords acdh-tei-pyutils
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # acdh-tei-pyutils

[![Github Workflow Tests Status](https://github.com/acdh-oeaw/acdh-tei-pyutils/workflows/Test/badge.svg)](https://github.com/acdh-oeaw/acdh-tei-pyutils/workflows/Test/badge.svg)
[![PyPI version](https://badge.fury.io/py/acdh-tei-pyutils.svg)](https://badge.fury.io/py/acdh-tei-pyutils)
[![codecov](https://codecov.io/gh/acdh-oeaw/acdh-tei-pyutils/branch/master/graph/badge.svg?token=y6HUg72XnH)](https://codecov.io/gh/acdh-oeaw/acdh-tei-pyutils)

Utilty functions to work with TEI Documents

## install

run `pip install acdh-tei-pyutils`

## usage

parse an XML/TEI Document from and URL, string or file:

```python
from acdh_tei_pyutils.tei import TeiReader

doc = TeiReader("https://raw.githubusercontent.com/acdh-oeaw/acdh-tei-pyutils/master/acdh_tei_pyutils/files/tei.xml")
print(doc.tree)
>>> <Element {http://www.tei-c.org/ns/1.0}TEI at 0x7ffb926f9c40>

doc = TeiReader("./acdh_tei_pyutils/files/tei.xml")
doc.tree
>>> <Element {http://www.tei-c.org/ns/1.0}TEI at 0x7ffb926f9c40>
```

write the current XML/TEI tree object to file
```python
doc.tree_to_file("out.xml")
>>> 'out.xml'
```

see [acdh_tei_pyutils/cli.py](https://github.com/acdh-oeaw/acdh-tei-pyutils/blob/master/acdh_tei_pyutils/cli.py) for further examples

### command line scripts

Batch process a collection of XML/Documents by adding xml:id, xml:base next and prev attributes to the documents root element run:

```bash
add-attributes -g "/path/to/your/xmls/*.xml" -b "https://value/of-your/base.com"
add-attributes -g "../../xml/grundbuecher/gb-data/data/editions/*.xml" -b "https://id.acdh.oeaw.ac.at/grundbuecher"
```

Write mentions as listEvents into index-files:

```bash
mentions-to-indices -t "erwähnt in " -i "/path/to/your/xmls/indices/*.xml" -f "/path/to/your/xmls/editions/*.xml"
```

Write mentions as listEvents of index-files and copy enriched index entries into files

```bash
denormalize-indices -f "../../xml/schnitzler/schnitzler-tagebuch-data-public/editions/*.xml" -i "../../xml/schnitzler/schnitzler-tagebuch-data-public/indices/*.xml"
denormalize-indices -f "./data/*/*.xml" -i "./data/indices/*.xml" -m ".//*[@key]/@key" -x ".//tei:title[@level='a']/text()"
denormalize-indices -f "./data/*/*.xml" -i "./data/indices/*.xml" -m ".//*[@key]/@key" -x ".//tei:title[@level='a']/text()" -b pmb2121 -b pmb10815 -b pmb50
```

Register handle-ids and add them as tei:idno elements:

```bash
add-handles -g "../../xml/grundbuecher/gb-data/data/editions/*.xml" -user "user12.3456-01" -pw "verysecret" -hixpath ".//tei:publicationStmt"
```

## develop

* install dev-dependencies: `pip install -r requirements_dev.txt`
* install local package `pip install -e .`
* before commiting run `flake8` to check linting and `coverage run -m pytest -v` to run the tests

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/acdh-oeaw/acdh-tei-pyutils",
    "name": "acdh-tei-pyutils",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "acdh-tei-pyutils",
    "author": "Peter Andorfer, Daniel Stoxreiter",
    "author_email": "peter.andorfer@oeaw.ac.at",
    "download_url": "https://files.pythonhosted.org/packages/3e/f4/020c8e2dea814d57712d809822695277ee24ff9816d878c30055a833cd46/acdh-tei-pyutils-1.1.tar.gz",
    "platform": null,
    "description": "# acdh-tei-pyutils\n\n[![Github Workflow Tests Status](https://github.com/acdh-oeaw/acdh-tei-pyutils/workflows/Test/badge.svg)](https://github.com/acdh-oeaw/acdh-tei-pyutils/workflows/Test/badge.svg)\n[![PyPI version](https://badge.fury.io/py/acdh-tei-pyutils.svg)](https://badge.fury.io/py/acdh-tei-pyutils)\n[![codecov](https://codecov.io/gh/acdh-oeaw/acdh-tei-pyutils/branch/master/graph/badge.svg?token=y6HUg72XnH)](https://codecov.io/gh/acdh-oeaw/acdh-tei-pyutils)\n\nUtilty functions to work with TEI Documents\n\n## install\n\nrun `pip install acdh-tei-pyutils`\n\n## usage\n\nparse an XML/TEI Document from and URL, string or file:\n\n```python\nfrom acdh_tei_pyutils.tei import TeiReader\n\ndoc = TeiReader(\"https://raw.githubusercontent.com/acdh-oeaw/acdh-tei-pyutils/master/acdh_tei_pyutils/files/tei.xml\")\nprint(doc.tree)\n>>> <Element {http://www.tei-c.org/ns/1.0}TEI at 0x7ffb926f9c40>\n\ndoc = TeiReader(\"./acdh_tei_pyutils/files/tei.xml\")\ndoc.tree\n>>> <Element {http://www.tei-c.org/ns/1.0}TEI at 0x7ffb926f9c40>\n```\n\nwrite the current XML/TEI tree object to file\n```python\ndoc.tree_to_file(\"out.xml\")\n>>> 'out.xml'\n```\n\nsee [acdh_tei_pyutils/cli.py](https://github.com/acdh-oeaw/acdh-tei-pyutils/blob/master/acdh_tei_pyutils/cli.py) for further examples\n\n### command line scripts\n\nBatch process a collection of XML/Documents by adding xml:id, xml:base next and prev attributes to the documents root element run:\n\n```bash\nadd-attributes -g \"/path/to/your/xmls/*.xml\" -b \"https://value/of-your/base.com\"\nadd-attributes -g \"../../xml/grundbuecher/gb-data/data/editions/*.xml\" -b \"https://id.acdh.oeaw.ac.at/grundbuecher\"\n```\n\nWrite mentions as listEvents into index-files:\n\n```bash\nmentions-to-indices -t \"erw\u00e4hnt in \" -i \"/path/to/your/xmls/indices/*.xml\" -f \"/path/to/your/xmls/editions/*.xml\"\n```\n\nWrite mentions as listEvents of index-files and copy enriched index entries into files\n\n```bash\ndenormalize-indices -f \"../../xml/schnitzler/schnitzler-tagebuch-data-public/editions/*.xml\" -i \"../../xml/schnitzler/schnitzler-tagebuch-data-public/indices/*.xml\"\ndenormalize-indices -f \"./data/*/*.xml\" -i \"./data/indices/*.xml\" -m \".//*[@key]/@key\" -x \".//tei:title[@level='a']/text()\"\ndenormalize-indices -f \"./data/*/*.xml\" -i \"./data/indices/*.xml\" -m \".//*[@key]/@key\" -x \".//tei:title[@level='a']/text()\" -b pmb2121 -b pmb10815 -b pmb50\n```\n\nRegister handle-ids and add them as tei:idno elements:\n\n```bash\nadd-handles -g \"../../xml/grundbuecher/gb-data/data/editions/*.xml\" -user \"user12.3456-01\" -pw \"verysecret\" -hixpath \".//tei:publicationStmt\"\n```\n\n## develop\n\n* install dev-dependencies: `pip install -r requirements_dev.txt`\n* install local package `pip install -e .`\n* before commiting run `flake8` to check linting and `coverage run -m pytest -v` to run the tests\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Utilty functions to work with TEI Documents",
    "version": "1.1",
    "project_urls": {
        "Homepage": "https://github.com/acdh-oeaw/acdh-tei-pyutils"
    },
    "split_keywords": [
        "acdh-tei-pyutils"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "08a8c6b4af15b5ea5005e0801c6960221ec451efbc564faff5a34dc635b46ba6",
                "md5": "9459a5d8cd686a8d617f51332d3b6008",
                "sha256": "f898a2bc7c4ed179a0644d72ddbf09c84675f3282526a6c6cbaf2f321999b55a"
            },
            "downloads": -1,
            "filename": "acdh_tei_pyutils-1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9459a5d8cd686a8d617f51332d3b6008",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 18256,
            "upload_time": "2024-01-28T07:53:39",
            "upload_time_iso_8601": "2024-01-28T07:53:39.881539Z",
            "url": "https://files.pythonhosted.org/packages/08/a8/c6b4af15b5ea5005e0801c6960221ec451efbc564faff5a34dc635b46ba6/acdh_tei_pyutils-1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ef4020c8e2dea814d57712d809822695277ee24ff9816d878c30055a833cd46",
                "md5": "0c701112fdc77686b5313f49e39df34a",
                "sha256": "39cb3e801e727e82e7897617811888522d7d27419085880ff3330d02d4490d92"
            },
            "downloads": -1,
            "filename": "acdh-tei-pyutils-1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0c701112fdc77686b5313f49e39df34a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 16486,
            "upload_time": "2024-01-28T07:53:41",
            "upload_time_iso_8601": "2024-01-28T07:53:41.658672Z",
            "url": "https://files.pythonhosted.org/packages/3e/f4/020c8e2dea814d57712d809822695277ee24ff9816d878c30055a833cd46/acdh-tei-pyutils-1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-28 07:53:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "acdh-oeaw",
    "github_project": "acdh-tei-pyutils",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "acdh-tei-pyutils"
}
        
Elapsed time: 0.21977s