diff --git a/poetry.lock b/poetry.lock index 85ec805..2c74d6b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -127,6 +127,7 @@ files = [ [package.dependencies] six = ">=1.9.0" +tinycss2 = {version = ">=1.1.0,<1.3", optional = true, markers = "extra == \"css\""} webencodings = "*" [package.extras] @@ -978,18 +979,18 @@ test = ["flaky", "ipykernel (>=6.19.3)", "ipython", "ipywidgets", "nbconvert (>= [[package]] name = "nbconvert" -version = "7.16.4" +version = "7.16.5" description = "Converting Jupyter Notebooks (.ipynb files) to other formats. Output formats include asciidoc, html, latex, markdown, pdf, py, rst, script. nbconvert can be used both as a Python library (`import nbconvert`) or as a command line tool (invoked as `jupyter nbconvert ...`)." optional = false python-versions = ">=3.8" files = [ - {file = "nbconvert-7.16.4-py3-none-any.whl", hash = "sha256:05873c620fe520b6322bf8a5ad562692343fe3452abda5765c7a34b7d1aa3eb3"}, - {file = "nbconvert-7.16.4.tar.gz", hash = "sha256:86ca91ba266b0a448dc96fa6c5b9d98affabde2867b363258703536807f9f7f4"}, + {file = "nbconvert-7.16.5-py3-none-any.whl", hash = "sha256:e12eac052d6fd03040af4166c563d76e7aeead2e9aadf5356db552a1784bd547"}, + {file = "nbconvert-7.16.5.tar.gz", hash = "sha256:c83467bb5777fdfaac5ebbb8e864f300b277f68692ecc04d6dab72f2d8442344"}, ] [package.dependencies] beautifulsoup4 = "*" -bleach = "!=5.0.0" +bleach = {version = "!=5.0.0", extras = ["css"]} defusedxml = "*" importlib-metadata = {version = ">=3.6", markers = "python_version < \"3.10\""} jinja2 = ">=3.0" @@ -1002,7 +1003,6 @@ nbformat = ">=5.7" packaging = "*" pandocfilters = ">=1.4.1" pygments = ">=2.4.1" -tinycss2 = "*" traitlets = ">=5.1" [package.extras] @@ -1304,13 +1304,13 @@ files = [ [[package]] name = "pygments" -version = "2.18.0" +version = "2.19.1" description = "Pygments is a syntax highlighting package written in Python." optional = false python-versions = ">=3.8" files = [ - {file = "pygments-2.18.0-py3-none-any.whl", hash = "sha256:b8e6aca0523f3ab76fee51799c488e38782ac06eafcf95e7ba832985c8e7b13a"}, - {file = "pygments-2.18.0.tar.gz", hash = "sha256:786ff802f32e91311bff3889f6e9a86e81505fe99f2735bb6d60ae0c5004f199"}, + {file = "pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c"}, + {file = "pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f"}, ] [package.extras] @@ -2051,13 +2051,13 @@ files = [ [[package]] name = "tinycss2" -version = "1.4.0" +version = "1.2.1" description = "A tiny CSS parser" optional = false -python-versions = ">=3.8" +python-versions = ">=3.7" files = [ - {file = "tinycss2-1.4.0-py3-none-any.whl", hash = "sha256:3a49cf47b7675da0b15d0c6e1df8df4ebd96e9394bb905a5775adb0d884c5289"}, - {file = "tinycss2-1.4.0.tar.gz", hash = "sha256:10c0972f6fc0fbee87c3edb76549357415e94548c1ae10ebccdea16fb404a9b7"}, + {file = "tinycss2-1.2.1-py3-none-any.whl", hash = "sha256:2b80a96d41e7c3914b8cda8bc7f705a4d9c49275616e886103dd839dfc847847"}, + {file = "tinycss2-1.2.1.tar.gz", hash = "sha256:8cff3a8f066c2ec677c06dbc7b45619804a6938478d9d73c284b29d14ecb0627"}, ] [package.dependencies] @@ -2065,7 +2065,7 @@ webencodings = ">=0.4" [package.extras] doc = ["sphinx", "sphinx_rtd_theme"] -test = ["pytest", "ruff"] +test = ["flake8", "isort", "pytest"] [[package]] name = "tomli" @@ -2193,13 +2193,13 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "virtualenv" -version = "20.28.0" +version = "20.28.1" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.8" files = [ - {file = "virtualenv-20.28.0-py3-none-any.whl", hash = "sha256:23eae1b4516ecd610481eda647f3a7c09aea295055337331bb4e6892ecce47b0"}, - {file = "virtualenv-20.28.0.tar.gz", hash = "sha256:2c9c3262bb8e7b87ea801d715fae4495e6032450c71d2309be9550e7364049aa"}, + {file = "virtualenv-20.28.1-py3-none-any.whl", hash = "sha256:412773c85d4dab0409b83ec36f7a6499e72eaf08c80e81e9576bca61831c71cb"}, + {file = "virtualenv-20.28.1.tar.gz", hash = "sha256:5d34ab240fdb5d21549b76f9e8ff3af28252f5499fb6d6f031adac4e5a8c5329"}, ] [package.dependencies] diff --git a/pyproject.toml b/pyproject.toml index 7c6409d..37da421 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "teiphy" -version = "0.1.15" +version = "0.1.16" description = "Converts TEI XML collations to NEXUS and other formats" authors = ["Joey McCollum and Robert Turnbull"] license = "MIT" diff --git a/teiphy/variation_unit.py b/teiphy/variation_unit.py index 78d32ae..067b48b 100644 --- a/teiphy/variation_unit.py +++ b/teiphy/variation_unit.py @@ -27,12 +27,14 @@ def __init__(self, xml: et.Element, verbose: bool = False): xml: An lxml.etree.Element representing an app element. verbose: An optional boolean flag indicating whether or not to print status updates. """ - # Use its xml:id if it has one; otherwise, use its n attribute if it has one: + # Use its xml:id if it has one; otherwise, use its n, from, and to attributes if it has them: self.id = "" if xml.get("{%s}id" % xml_ns) is not None: self.id = xml.get("{%s}id" % xml_ns) elif xml.get("n") is not None: self.id = xml.get("n") + if xml.get("from") is not None and xml.get("to") is not None: + self.id += "_" + xml.get("from") + "_" + xml.get("to") # Initialize its list of readings: self.readings = [] # Initialize its dictionaries of intrinsic and transcriptional relations: diff --git a/tests/test_variation_unit.py b/tests/test_variation_unit.py index 46534b8..2c745fa 100644 --- a/tests/test_variation_unit.py +++ b/tests/test_variation_unit.py @@ -33,6 +33,27 @@ def test_init_n_id(self): vu = VariationUnit(xml) self.assertEqual(vu.id, "39") + def test_init_n_from_to_id(self): + xml = et.fromstring( + """ + + ιησου χριστου δουλος + χριστου ιησου δουλος + δουλος ιησου χριστου + χριστου δουλος + ιησου χριστου δουλος ιουδας ιησου χριστου + δουλος + + + """ + ) + vu = VariationUnit(xml) + self.assertEqual(vu.id, "Jude1_4_8") + def test_init_readings_lem_wits(self): xml = et.fromstring( """