@@ -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 @@
+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 @@
-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
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