From aac6897864f61c51f70ffb83c193f3aca1d6a593 Mon Sep 17 00:00:00 2001 From: Nick <3816295+nickreynke@users.noreply.github.com> Date: Fri, 13 Feb 2026 10:41:48 +0100 Subject: [PATCH] refactor: remove legacy dependencies and migrate to `uv` Replaced `Pipfile`, `setup.py`, and `tox` with `uv` for dependency management, building, and testing. Simplified the local development process and updated the minimum Python version to 3.8. These changes streamline workflows and align the project with modern tools. --- .github/workflows/test.yml | 35 + CHANGELOG.md | 11 + MANIFEST.in | 20 - Pipfile | 16 - Pipfile.lock | 288 ----- README.md | 28 +- docs/gedcom/element/element.html | 445 ++----- docs/gedcom/element/family.html | 113 +- docs/gedcom/element/file.html | 113 +- docs/gedcom/element/index.html | 98 +- docs/gedcom/element/individual.html | 681 ++--------- docs/gedcom/element/object.html | 126 +- docs/gedcom/element/root.html | 83 +- docs/gedcom/helpers.html | 102 +- docs/gedcom/index.html | 111 +- docs/gedcom/parser.html | 762 ++---------- docs/gedcom/tags.html | 339 ++---- pyproject.toml | 48 + setup.cfg | 13 - setup.py | 45 - tox.ini | 27 - uv.lock | 1732 +++++++++++++++++++++++++++ 22 files changed, 2487 insertions(+), 2749 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 MANIFEST.in delete mode 100644 Pipfile delete mode 100644 Pipfile.lock create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 tox.ini create mode 100644 uv.lock diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1d68dbf --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,35 @@ +name: Test + +on: + pull_request: + branches: + - main + - develop + +jobs: + + test: + name: Test for Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3"] + + steps: + - uses: actions/checkout@v6.0.2 + + - name: Install uv + uses: astral-sh/setup-uv@v7.3.0 + with: + enable-cache: true + cache-dependency-glob: "uv.lock" + + - name: Set up Python ${{ matrix.python-version }} + run: uv python install ${{ matrix.python-version }} + + - name: Install dependencies + run: uv sync --all-groups + + - name: Run tests + run: uv run pytest diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c0ba86..dd20e1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Python GEDCOM Parser - Changelog +## [v1.1.0](https://github.com/nickreynke/python-gedcom/releases/tag/v1.1.0) + +### Changes: + +- Migrated to `uv` for local development and package management. +- Added GitHub Actions workflow for automated testing on push and pull requests. +- Moved project metadata from `setup.py` and `Pipfile` to `pyproject.toml`. +- Replaced `tox` with `uv run pytest` for testing. +- Updated minimum supported Python version to 3.8. +- Re-generated docs via `uv run pdoc3 --html -o docs/ gedcom --force`. + ## [v1.0.0](https://github.com/nickreynke/python-gedcom/releases/tag/v1.0.0) ### Changes: diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 88e92a9..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,20 +0,0 @@ -exclude MANIFEST.in - -# Include the README and the CHANGELOG -include *.md - -# Include the license file -include LICENSE.txt - -# Include the dependency related files -include Pipfile -include Pipfile.lock - -# Docs -exclude logo.png -exclude docs -recursive-exclude docs * -recursive-exclude gedcom *.md - -# Include GEDCOM test files -include tests/files/*.ged diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 59b90df..0000000 --- a/Pipfile +++ /dev/null @@ -1,16 +0,0 @@ -[[source]] -name = "pypi" -url = "https://pypi.org/simple" -verify_ssl = true - -[dev-packages] -setuptools = "*" -wheel = "*" -twine = "*" -tox = "*" -pdoc3 = "*" - -[packages] - -[requires] -python_version = "3.5" diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index 6e99c0c..0000000 --- a/Pipfile.lock +++ /dev/null @@ -1,288 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "ff4ffecf922d35b96c175b7a2a6e76ba732f698d575beb753c2742046c2da00d" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "3.5" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": {}, - "develop": { - "appdirs": { - "hashes": [ - "sha256:9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92", - "sha256:d8b24664561d0d34ddfaec54636d502d7cea6e29c3eaf68f3df6180863e2166e" - ], - "version": "==1.4.3" - }, - "bleach": { - "hashes": [ - "sha256:53165a6596e7899c4338d847315fec508110a53bd6fd15c127c2e0d0860264e3", - "sha256:f8dfd8a7e26443e986c4e44df31870da8e906ea61096af06ba5d5cc2d519842a" - ], - "version": "==3.1.3" - }, - "certifi": { - "hashes": [ - "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3", - "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f" - ], - "version": "==2019.11.28" - }, - "chardet": { - "hashes": [ - "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", - "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" - ], - "version": "==3.0.4" - }, - "distlib": { - "hashes": [ - "sha256:2e166e231a26b36d6dfe35a48c4464346620f8645ed0ace01ee31822b288de21" - ], - "version": "==0.3.0" - }, - "docutils": { - "hashes": [ - "sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af", - "sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc" - ], - "version": "==0.16" - }, - "filelock": { - "hashes": [ - "sha256:18d82244ee114f543149c66a6e0c14e9c4f8a1044b5cdaadd0f82159d6a6ff59", - "sha256:929b7d63ec5b7d6b71b0fa5ac14e030b3f70b75747cef1b10da9b879fef15836" - ], - "version": "==3.0.12" - }, - "idna": { - "hashes": [ - "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb", - "sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa" - ], - "version": "==2.9" - }, - "importlib-metadata": { - "hashes": [ - "sha256:06f5b3a99029c7134207dd882428a66992a9de2bef7c2b699b5641f9886c3302", - "sha256:b97607a1a18a5100839aec1dc26a1ea17ee0d93b20b0f008d80a5a050afb200b" - ], - "markers": "python_version < '3.8'", - "version": "==1.5.0" - }, - "importlib-resources": { - "hashes": [ - "sha256:4019b6a9082d8ada9def02bece4a76b131518866790d58fdda0b5f8c603b36c2", - "sha256:dd98ceeef3f5ad2ef4cc287b8586da4ebad15877f351e9688987ad663a0a29b8" - ], - "markers": "python_version < '3.7'", - "version": "==1.4.0" - }, - "mako": { - "hashes": [ - "sha256:3139c5d64aa5d175dbafb95027057128b5fbd05a40c53999f3905ceb53366d9d", - "sha256:8e8b53c71c7e59f3de716b6832c4e401d903af574f6962edbbbf6ecc2a5fe6c9" - ], - "version": "==1.1.2" - }, - "markdown": { - "hashes": [ - "sha256:90fee683eeabe1a92e149f7ba74e5ccdc81cd397bd6c516d93a8da0ef90b6902", - "sha256:e4795399163109457d4c5af2183fbe6b60326c17cfdf25ce6e7474c6624f725d" - ], - "version": "==3.2.1" - }, - "markupsafe": { - "hashes": [ - "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", - "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", - "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", - "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", - "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42", - "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", - "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", - "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", - "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", - "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", - "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", - "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b", - "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", - "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15", - "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", - "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", - "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", - "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", - "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", - "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", - "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", - "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", - "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", - "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", - "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", - "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", - "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", - "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", - "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", - "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", - "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2", - "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7", - "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be" - ], - "version": "==1.1.1" - }, - "packaging": { - "hashes": [ - "sha256:3c292b474fda1671ec57d46d739d072bfd495a4f51ad01a055121d81e952b7a3", - "sha256:82f77b9bee21c1bafbf35a84905d604d5d1223801d639cf3ed140bd651c08752" - ], - "version": "==20.3" - }, - "pdoc3": { - "hashes": [ - "sha256:ebca75b7fcf23f3b4320abe23339834d3f08c28517718e9d29e555fc38eeb33c" - ], - "index": "pypi", - "version": "==0.7.5" - }, - "pkginfo": { - "hashes": [ - "sha256:7424f2c8511c186cd5424bbf31045b77435b37a8d604990b79d4e70d741148bb", - "sha256:a6d9e40ca61ad3ebd0b72fbadd4fba16e4c0e4df0428c041e01e06eb6ee71f32" - ], - "version": "==1.5.0.1" - }, - "pluggy": { - "hashes": [ - "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0", - "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d" - ], - "version": "==0.13.1" - }, - "py": { - "hashes": [ - "sha256:5e27081401262157467ad6e7f851b7aa402c5852dbcb3dae06768434de5752aa", - "sha256:c20fdd83a5dbc0af9efd622bee9a5564e278f6380fffcacc43ba6f43db2813b0" - ], - "version": "==1.8.1" - }, - "pygments": { - "hashes": [ - "sha256:647344a061c249a3b74e230c739f434d7ea4d8b1d5f3721bc0f3558049b38f44", - "sha256:ff7a40b4860b727ab48fad6360eb351cc1b33cbf9b15a0f689ca5353e9463324" - ], - "version": "==2.6.1" - }, - "pyparsing": { - "hashes": [ - "sha256:4c830582a84fb022400b85429791bc551f1f4871c33f23e44f353119e92f969f", - "sha256:c342dccb5250c08d45fd6f8b4a559613ca603b57498511740e65cd11a2e7dcec" - ], - "version": "==2.4.6" - }, - "readme-renderer": { - "hashes": [ - "sha256:1b6d8dd1673a0b293766b4106af766b6eff3654605f9c4f239e65de6076bc222", - "sha256:e67d64242f0174a63c3b727801a2fff4c1f38ebe5d71d95ff7ece081945a6cd4" - ], - "version": "==25.0" - }, - "requests": { - "hashes": [ - "sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee", - "sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6" - ], - "version": "==2.23.0" - }, - "requests-toolbelt": { - "hashes": [ - "sha256:380606e1d10dc85c3bd47bf5a6095f815ec007be7a8b69c878507068df059e6f", - "sha256:968089d4584ad4ad7c171454f0a5c6dac23971e9472521ea3b6d49d610aa6fc0" - ], - "version": "==0.9.1" - }, - "six": { - "hashes": [ - "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a", - "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c" - ], - "version": "==1.14.0" - }, - "toml": { - "hashes": [ - "sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c", - "sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e" - ], - "version": "==0.10.0" - }, - "tox": { - "hashes": [ - "sha256:0cbe98369081fa16bd6f1163d3d0b2a62afa29d402ccfad2bd09fb2668be0956", - "sha256:676f1e3e7de245ad870f956436b84ea226210587d1f72c8dfb8cd5ac7b6f0e70" - ], - "index": "pypi", - "version": "==3.14.5" - }, - "tqdm": { - "hashes": [ - "sha256:0d8b5afb66e23d80433102e9bd8b5c8b65d34c2a2255b2de58d97bd2ea8170fd", - "sha256:f35fb121bafa030bd94e74fcfd44f3c2830039a2ddef7fc87ef1c2d205237b24" - ], - "version": "==4.43.0" - }, - "twine": { - "hashes": [ - "sha256:630fadd6e342e725930be6c696537e3f9ccc54331742b16245dab292a17d0460", - "sha256:a3d22aab467b4682a22de4a422632e79d07eebd07ff2a7079effb13f8a693787" - ], - "index": "pypi", - "version": "==1.15.0" - }, - "urllib3": { - "hashes": [ - "sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc", - "sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc" - ], - "version": "==1.25.8" - }, - "virtualenv": { - "hashes": [ - "sha256:87831f1070534b636fea2241dd66f3afe37ac9041bcca6d0af3215cdcfbf7d82", - "sha256:f3128d882383c503003130389bf892856341c1da12c881ae24d6358c82561b55" - ], - "version": "==20.0.13" - }, - "webencodings": { - "hashes": [ - "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78", - "sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923" - ], - "version": "==0.5.1" - }, - "wheel": { - "hashes": [ - "sha256:8788e9155fe14f54164c1b9eb0a319d98ef02c160725587ad60f14ddc57b6f96", - "sha256:df277cb51e61359aba502208d680f90c0493adec6f0e848af94948778aed386e" - ], - "index": "pypi", - "version": "==0.34.2" - }, - "zipp": { - "hashes": [ - "sha256:c70410551488251b0fee67b460fb9a536af8d6f9f008ad10ac51f615b6a521b1", - "sha256:e0d9e63797e483a30d27e09fffd308c59a700d365ec34e93cc100844168bf921" - ], - "markers": "python_version < '3.8'", - "version": "==1.2.0" - } - } -} diff --git a/README.md b/README.md index fca4721..072ef11 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,8 @@

PyPI GitHub release - Build Status GEDCOM format version 5.5 - Python versions 3.5 to 3.8 + Python versions 3.8 to 3.12

@@ -37,36 +36,31 @@ The current development process can be tracked in the [develop branch](https://g ## Local development -Local development is done using [pyenv](https://github.com/pyenv/pyenv) and -[pipenv](https://github.com/pypa/pipenv) using Python 3.5. +Local development is done using [uv](https://github.com/astral-sh/uv). ### Running tests -1. Run `pipenv install -d` to install normal and dev dependencies -1. Run tests with [tox](https://tox.readthedocs.io/en/latest/index.html) (`pipenv run tox` in your console) - * For Python 3.5 run `pipenv run tox -e py35` (you need to have Python 3.5 installed) - * For Python 3.6 run `pipenv run tox -e py36` (you need to have Python 3.6 installed) - * For Python 3.7 run `pipenv run tox -e py37` (you need to have Python 3.7 installed) - * For Python 3.8 run `pipenv run tox -e py38` (you need to have Python 3.8 installed) +1. Run `uv sync` to install dependencies +1. Run tests with [pytest](https://docs.pytest.org/) (`uv run pytest` in your console) ### Generating docs -1. Run `pipenv install -d` to install normal and dev dependencies -1. Run `pipenv run pdoc3 --html -o docs/ gedcom --force` to generate docs into the `docs/` directory +1. Run `uv sync` to install dependencies +1. Run `uv run pdoc3 --html -o docs/ gedcom --force` to generate docs into the `docs/` directory -> To develop docs run `pipenv run pdoc3 --http localhost:8000 gedcom` +> To develop docs run `uv run pdoc3 --http localhost:8000 gedcom` > to watch files and instantly see changes in your browser under http://localhost:8000. ### Uploading a new package to PyPI -1. Run `pipenv install -d` to install normal and dev dependencies -1. Run `pipenv run python3 setup.py sdist bdist_wheel` to generate distribution archives -1. Run `pipenv run twine upload --repository-url https://test.pypi.org/legacy/ dist/*` to upload the archives to the Test Python Package Index repository +1. Run `uv sync` to install dependencies +1. Run `uv build` to generate distribution archives +1. Run `uv run twine upload --repository-url https://test.pypi.org/legacy/ dist/*` to upload the archives to the Test Python Package Index repository > When the package is ready to be published to the real Python Package Index the `repository-url` is `https://upload.pypi.org/legacy/`. > -> `pipenv run twine upload --repository-url https://upload.pypi.org/legacy/ dist/*` +> `uv run twine upload --repository-url https://upload.pypi.org/legacy/ dist/*` ## History diff --git a/docs/gedcom/element/element.html b/docs/gedcom/element/element.html index 7d9c271..72c318a 100644 --- a/docs/gedcom/element/element.html +++ b/docs/gedcom/element/element.html @@ -2,16 +2,32 @@ - - + + gedcom.element.element API documentation - - - - - - + + + + + + + +

@@ -21,47 +37,26 @@

Module gedcom.element.element

Base GEDCOM element

+
+
+
+
+
+
+
+
+

Classes

+
+
+class Element +(level, pointer, tag, value, crlf='\n', multi_line=True) +
+
Expand source code -
# -*- coding: utf-8 -*-
-
-# Python GEDCOM Parser
-#
-# Copyright (C) 2018 Damon Brodie (damon.brodie at gmail.com)
-# Copyright (C) 2018-2019 Nicklas Reincke (contact at reynke.com)
-# Copyright (C) 2016 Andreas Oberritter
-# Copyright (C) 2012 Madeleine Price Ball
-# Copyright (C) 2005 Daniel Zappala (zappala at cs.byu.edu)
-# Copyright (C) 2005 Brigham Young University
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Further information about the license: http://www.gnu.org/licenses/gpl-2.0.html
-
-"""
-Base GEDCOM element
-"""
-
-from sys import version_info
-from gedcom.helpers import deprecated
-import gedcom.tags
-
-
-class Element(object):
+
class Element(object):
     """GEDCOM element
 
     Each line in a GEDCOM file is an element with the format
@@ -321,22 +316,7 @@ 

Module gedcom.element.element

return self.to_gedcom_string().encode('utf-8-sig')
-
-
-
-
-
-
-
-
-

Classes

-
-
-class Element -(level, pointer, tag, value, crlf='\n', multi_line=True) -
-
-

GEDCOM element

+

GEDCOM element

Each line in a GEDCOM file is an element with the format

level [pointer] tag [value]

where level and tag are required, and pointer and value are @@ -356,271 +336,7 @@

Classes

that points to a family record in which the associated person is a child.

See a GEDCOM file for examples of tags and their values.

-

Tags available to an element are seen here: gedcom.tags

-
- -Expand source code - -
class Element(object):
-    """GEDCOM element
-
-    Each line in a GEDCOM file is an element with the format
-
-    `level [pointer] tag [value]`
-
-    where `level` and `tag` are required, and `pointer` and `value` are
-    optional.  Elements are arranged hierarchically according to their
-    level, and elements with a level of zero are at the top level.
-    Elements with a level greater than zero are children of their
-    parent.
-
-    A pointer has the format `@pname@`, where `pname` is any sequence of
-    characters and numbers. The pointer identifies the object being
-    pointed to, so that any pointer included as the value of any
-    element points back to the original object.  For example, an
-    element may have a `FAMS` tag whose value is `@F1@`, meaning that this
-    element points to the family record in which the associated person
-    is a spouse. Likewise, an element with a tag of `FAMC` has a value
-    that points to a family record in which the associated person is a
-    child.
-
-    See a GEDCOM file for examples of tags and their values.
-
-    Tags available to an element are seen here: `gedcom.tags`
-    """
-
-    def __init__(self, level, pointer, tag, value, crlf="\n", multi_line=True):
-        # basic element info
-        self.__level = level
-        self.__pointer = pointer
-        self.__tag = tag
-        self.__value = value
-        self.__crlf = crlf
-
-        # structuring
-        self.__children = []
-        self.__parent = None
-
-        if multi_line:
-            self.set_multi_line_value(value)
-
-    def get_level(self):
-        """Returns the level of this element from within the GEDCOM file
-        :rtype: int
-        """
-        return self.__level
-
-    def get_pointer(self):
-        """Returns the pointer of this element from within the GEDCOM file
-        :rtype: str
-        """
-        return self.__pointer
-
-    def get_tag(self):
-        """Returns the tag of this element from within the GEDCOM file
-        :rtype: str
-        """
-        return self.__tag
-
-    def get_value(self):
-        """Return the value of this element from within the GEDCOM file
-        :rtype: str
-        """
-        return self.__value
-
-    def set_value(self, value):
-        """Sets the value of this element
-        :type value: str
-        """
-        self.__value = value
-
-    def get_multi_line_value(self):
-        """Returns the value of this element including concatenations or continuations
-        :rtype: str
-        """
-        result = self.get_value()
-        last_crlf = self.__crlf
-        for element in self.get_child_elements():
-            tag = element.get_tag()
-            if tag == gedcom.tags.GEDCOM_TAG_CONCATENATION:
-                result += element.get_value()
-                last_crlf = element.__crlf
-            elif tag == gedcom.tags.GEDCOM_TAG_CONTINUED:
-                result += last_crlf + element.get_value()
-                last_crlf = element.__crlf
-        return result
-
-    def __available_characters(self):
-        """Get the number of available characters of the elements original string
-        :rtype: int
-        """
-        element_characters = len(self.to_gedcom_string())
-        return 0 if element_characters > 255 else 255 - element_characters
-
-    def __line_length(self, line):
-        """@TODO Write docs.
-        :type line: str
-        :rtype: int
-        """
-        total_characters = len(line)
-        available_characters = self.__available_characters()
-        if total_characters <= available_characters:
-            return total_characters
-        spaces = 0
-        while spaces < available_characters and line[available_characters - spaces - 1] == ' ':
-            spaces += 1
-        if spaces == available_characters:
-            return available_characters
-        return available_characters - spaces
-
-    def __set_bounded_value(self, value):
-        """@TODO Write docs.
-        :type value: str
-        :rtype: int
-        """
-        line_length = self.__line_length(value)
-        self.set_value(value[:line_length])
-        return line_length
-
-    def __add_bounded_child(self, tag, value):
-        """@TODO Write docs.
-        :type tag: str
-        :type value: str
-        :rtype: int
-        """
-        child = self.new_child_element(tag)
-        return child.__set_bounded_value(value)
-
-    def __add_concatenation(self, string):
-        """@TODO Write docs.
-        :rtype: str
-        """
-        index = 0
-        size = len(string)
-        while index < size:
-            index += self.__add_bounded_child(gedcom.tags.GEDCOM_TAG_CONCATENATION, string[index:])
-
-    def set_multi_line_value(self, value):
-        """Sets the value of this element, adding concatenation and continuation lines when necessary
-        :type value: str
-        """
-        self.set_value('')
-        self.get_child_elements()[:] = [child for child in self.get_child_elements() if
-                                        child.get_tag() not in (gedcom.tags.GEDCOM_TAG_CONCATENATION, gedcom.tags.GEDCOM_TAG_CONTINUED)]
-
-        lines = value.splitlines()
-        if lines:
-            line = lines.pop(0)
-            n = self.__set_bounded_value(line)
-            self.__add_concatenation(line[n:])
-
-            for line in lines:
-                n = self.__add_bounded_child(gedcom.tags.GEDCOM_TAG_CONTINUED, line)
-                self.__add_concatenation(line[n:])
-
-    def get_child_elements(self):
-        """Returns the direct child elements of this element
-        :rtype: list of Element
-        """
-        return self.__children
-
-    def new_child_element(self, tag, pointer="", value=""):
-        """Creates and returns a new child element of this element
-
-        :type tag: str
-        :type pointer: str
-        :type value: str
-        :rtype: Element
-        """
-        from gedcom.element.family import FamilyElement
-        from gedcom.element.file import FileElement
-        from gedcom.element.individual import IndividualElement
-        from gedcom.element.object import ObjectElement
-
-        # Differentiate between the type of the new child element
-        if tag == gedcom.tags.GEDCOM_TAG_FAMILY:
-            child_element = FamilyElement(self.get_level() + 1, pointer, tag, value, self.__crlf)
-        elif tag == gedcom.tags.GEDCOM_TAG_FILE:
-            child_element = FileElement(self.get_level() + 1, pointer, tag, value, self.__crlf)
-        elif tag == gedcom.tags.GEDCOM_TAG_INDIVIDUAL:
-            child_element = IndividualElement(self.get_level() + 1, pointer, tag, value, self.__crlf)
-        elif tag == gedcom.tags.GEDCOM_TAG_OBJECT:
-            child_element = ObjectElement(self.get_level() + 1, pointer, tag, value, self.__crlf)
-        else:
-            child_element = Element(self.get_level() + 1, pointer, tag, value, self.__crlf)
-
-        self.add_child_element(child_element)
-
-        return child_element
-
-    def add_child_element(self, element):
-        """Adds a child element to this element
-
-        :type element: Element
-        """
-        self.get_child_elements().append(element)
-        element.set_parent_element(self)
-
-        return element
-
-    def get_parent_element(self):
-        """Returns the parent element of this element
-        :rtype: Element
-        """
-        return self.__parent
-
-    def set_parent_element(self, element):
-        """Adds a parent element to this element
-
-        There's usually no need to call this method manually,
-        `add_child_element()` calls it automatically.
-
-        :type element: Element
-        """
-        self.__parent = element
-
-    @deprecated
-    def get_individual(self):
-        """Returns this element and all of its sub-elements represented as a GEDCOM string
-        ::deprecated:: As of version 1.0.0 use `to_gedcom_string()` method instead
-        :rtype: str
-        """
-        return self.to_gedcom_string(True)
-
-    def to_gedcom_string(self, recursive=False):
-        """Formats this element and optionally all of its sub-elements into a GEDCOM string
-        :type recursive: bool
-        :rtype: str
-        """
-
-        result = str(self.get_level())
-
-        if self.get_pointer() != "":
-            result += ' ' + self.get_pointer()
-
-        result += ' ' + self.get_tag()
-
-        if self.get_value() != "":
-            result += ' ' + self.get_value()
-
-        result += self.__crlf
-
-        if self.get_level() < 0:
-            result = ''
-
-        if recursive:
-            for child_element in self.get_child_elements():
-                result += child_element.to_gedcom_string(True)
-
-        return result
-
-    def __str__(self):
-        """:rtype: str"""
-        if version_info[0] >= 3:
-            return self.to_gedcom_string()
-
-        return self.to_gedcom_string().encode('utf-8-sig')
-
+

Tags available to an element are seen here: gedcom.tags

Subclasses

  • FamilyElement
  • @@ -635,8 +351,6 @@

    Methods

    def add_child_element(self, element)
    -

    Adds a child element to this element

    -

    :type element: Element

    Expand source code @@ -651,13 +365,13 @@

    Methods

    return element
    +

    Adds a child element to this element

    +

    :type element: Element

    def get_child_elements(self)
    -

    Returns the direct child elements of this element -:rtype: list of Element

    Expand source code @@ -668,14 +382,13 @@

    Methods

    """ return self.__children
    +

    Returns the direct child elements of this element +:rtype: list of Element

    def get_individual(self)
    -

    Returns this element and all of its sub-elements represented as a GEDCOM string -::deprecated:: As of version 1.0.0 use to_gedcom_string() method instead -:rtype: str

    Expand source code @@ -688,13 +401,14 @@

    Methods

    """ return self.to_gedcom_string(True)
    +

    Returns this element and all of its sub-elements represented as a GEDCOM string +::deprecated:: As of version 1.0.0 use to_gedcom_string() method instead +:rtype: str

    def get_level(self)
    -

    Returns the level of this element from within the GEDCOM file -:rtype: int

    Expand source code @@ -705,13 +419,13 @@

    Methods

    """ return self.__level
    +

    Returns the level of this element from within the GEDCOM file +:rtype: int

    def get_multi_line_value(self)
    -

    Returns the value of this element including concatenations or continuations -:rtype: str

    Expand source code @@ -732,13 +446,13 @@

    Methods

    last_crlf = element.__crlf return result
    +

    Returns the value of this element including concatenations or continuations +:rtype: str

    def get_parent_element(self)
    -

    Returns the parent element of this element -:rtype: Element

    Expand source code @@ -749,13 +463,13 @@

    Methods

    """ return self.__parent
    +

    Returns the parent element of this element +:rtype: Element

    def get_pointer(self)
    -

    Returns the pointer of this element from within the GEDCOM file -:rtype: str

    Expand source code @@ -766,13 +480,13 @@

    Methods

    """ return self.__pointer
    +

    Returns the pointer of this element from within the GEDCOM file +:rtype: str

    def get_tag(self)
    -

    Returns the tag of this element from within the GEDCOM file -:rtype: str

    Expand source code @@ -783,13 +497,13 @@

    Methods

    """ return self.__tag
    +

    Returns the tag of this element from within the GEDCOM file +:rtype: str

    def get_value(self)
    -

    Return the value of this element from within the GEDCOM file -:rtype: str

    Expand source code @@ -800,16 +514,13 @@

    Methods

    """ return self.__value
    +

    Return the value of this element from within the GEDCOM file +:rtype: str

    def new_child_element(self, tag, pointer='', value='')
    -

    Creates and returns a new child element of this element

    -

    :type tag: str -:type pointer: str -:type value: str -:rtype: Element

    Expand source code @@ -843,13 +554,16 @@

    Methods

    return child_element
    +

    Creates and returns a new child element of this element

    +

    :type tag: str +:type pointer: str +:type value: str +:rtype: Element

    def set_multi_line_value(self, value)
    -

    Sets the value of this element, adding concatenation and continuation lines when necessary -:type value: str

    Expand source code @@ -872,15 +586,13 @@

    Methods

    n = self.__add_bounded_child(gedcom.tags.GEDCOM_TAG_CONTINUED, line) self.__add_concatenation(line[n:])
    +

    Sets the value of this element, adding concatenation and continuation lines when necessary +:type value: str

    def set_parent_element(self, element)
    -

    Adds a parent element to this element

    -

    There's usually no need to call this method manually, -add_child_element() calls it automatically.

    -

    :type element: Element

    Expand source code @@ -895,13 +607,15 @@

    Methods

    """ self.__parent = element
    +

    Adds a parent element to this element

    +

    There's usually no need to call this method manually, +add_child_element() calls it automatically.

    +

    :type element: Element

    def set_value(self, value)
    -

    Sets the value of this element -:type value: str

    Expand source code @@ -912,14 +626,13 @@

    Methods

    """ self.__value = value
    +

    Sets the value of this element +:type value: str

    def to_gedcom_string(self, recursive=False)
    -

    Formats this element and optionally all of its sub-elements into a GEDCOM string -:type recursive: bool -:rtype: str

    Expand source code @@ -951,6 +664,9 @@

    Methods

    return result
    +

    Formats this element and optionally all of its sub-elements into a GEDCOM string +:type recursive: bool +:rtype: str

@@ -958,7 +674,6 @@

Methods