pylint cleanups for gen/lib/*.py
This commit is contained in:
parent
977daf8f93
commit
5cf9b676e8
@ -31,27 +31,29 @@ Address class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .privacybase import PrivacyBase
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .citationbase import CitationBase
|
||||
from .notebase import NoteBase
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .datebase import DateBase
|
||||
from .locationbase import LocationBase
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .notebase import NoteBase
|
||||
from .privacybase import PrivacyBase
|
||||
from .secondaryobj import SecondaryObject
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Address for Person/Repository
|
||||
# Address class for Person/Repository
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class Address(
|
||||
SecondaryObject, PrivacyBase, CitationBase, NoteBase, DateBase, LocationBase
|
||||
):
|
||||
"""Provide address information."""
|
||||
"""
|
||||
Provides address information.
|
||||
"""
|
||||
|
||||
def __init__(self, source=None):
|
||||
"""
|
||||
@ -96,6 +98,7 @@ class Address(
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .date import Date
|
||||
|
||||
return {
|
||||
@ -176,7 +179,8 @@ class Address(
|
||||
:rtype: list
|
||||
"""
|
||||
return (
|
||||
self.get_referenced_note_handles() + self.get_referenced_citation_handles()
|
||||
self.get_referenced_note_handles()
|
||||
+ self.get_referenced_citation_handles()
|
||||
)
|
||||
|
||||
def is_equivalent(self, other):
|
||||
@ -194,11 +198,9 @@ class Address(
|
||||
or self.get_date_object() != other.get_date_object()
|
||||
):
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
return EQUAL
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
|
@ -29,7 +29,7 @@ AddressBase class for Gramps.
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .address import Address
|
||||
from .const import IDENTICAL, EQUAL
|
||||
from .const import EQUAL, IDENTICAL
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
@ -52,7 +52,9 @@ class AddressBase:
|
||||
:param source: Object used to initialize the new object
|
||||
:type source: AddressBase
|
||||
"""
|
||||
self.address_list = list(map(Address, source.address_list)) if source else []
|
||||
self.address_list = (
|
||||
list(map(Address, source.address_list)) if source else []
|
||||
)
|
||||
|
||||
def serialize(self):
|
||||
"""
|
||||
@ -79,7 +81,8 @@ class AddressBase:
|
||||
|
||||
def remove_address(self, address):
|
||||
"""
|
||||
Remove the specified :class:`~.address.Address` instance from the address list.
|
||||
Remove the specified :class:`~.address.Address` instance from the
|
||||
address list.
|
||||
|
||||
If the instance does not exist in the list, the operation has
|
||||
no effect.
|
||||
@ -95,8 +98,7 @@ class AddressBase:
|
||||
if address in self.address_list:
|
||||
self.address_list.remove(address)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
def get_address_list(self):
|
||||
"""
|
||||
@ -133,7 +135,7 @@ class AddressBase:
|
||||
equi = address.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
if equi == EQUAL:
|
||||
address.merge(addendum)
|
||||
break
|
||||
else:
|
||||
|
@ -29,8 +29,8 @@ AttributeRootBase class for Gramps.
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .attribute import Attribute, AttributeRoot
|
||||
from .const import EQUAL, IDENTICAL
|
||||
from .srcattribute import SrcAttribute
|
||||
from .const import IDENTICAL, EQUAL
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
@ -104,8 +104,7 @@ class AttributeRootBase:
|
||||
if attribute in self.attribute_list:
|
||||
self.attribute_list.remove(attribute)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
def get_attribute_list(self):
|
||||
"""
|
||||
@ -142,7 +141,7 @@ class AttributeRootBase:
|
||||
equi = attr.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
if equi == EQUAL:
|
||||
attr.merge(addendum)
|
||||
break
|
||||
else:
|
||||
@ -150,8 +149,16 @@ class AttributeRootBase:
|
||||
|
||||
|
||||
class AttributeBase(AttributeRootBase):
|
||||
"""
|
||||
Base class for an Attribute list.
|
||||
"""
|
||||
|
||||
_CLASS = Attribute
|
||||
|
||||
|
||||
class SrcAttributeBase(AttributeRootBase):
|
||||
"""
|
||||
Base class for a SrcAttribute list.
|
||||
"""
|
||||
|
||||
_CLASS = SrcAttribute
|
||||
|
@ -30,13 +30,13 @@ Attribute class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .privacybase import PrivacyBase
|
||||
from .citationbase import CitationBase
|
||||
from .notebase import NoteBase
|
||||
from .attrtype import AttributeType
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .attrtype import AttributeType
|
||||
from .citationbase import CitationBase
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .notebase import NoteBase
|
||||
from .privacybase import PrivacyBase
|
||||
from .secondaryobj import SecondaryObject
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -150,11 +150,9 @@ class AttributeRoot(SecondaryObject, PrivacyBase):
|
||||
"""
|
||||
if self.type != other.type or self.value != other.value:
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
return EQUAL
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
@ -190,6 +188,10 @@ class AttributeRoot(SecondaryObject, PrivacyBase):
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class Attribute(AttributeRoot, CitationBase, NoteBase):
|
||||
"""
|
||||
An attribute class that supports citation and note annotations.
|
||||
"""
|
||||
|
||||
def __init__(self, source=None):
|
||||
"""
|
||||
Create a new Attribute object, copying from the source if provided.
|
||||
@ -266,7 +268,8 @@ class Attribute(AttributeRoot, CitationBase, NoteBase):
|
||||
:rtype: list
|
||||
"""
|
||||
return (
|
||||
self.get_referenced_note_handles() + self.get_referenced_citation_handles()
|
||||
self.get_referenced_note_handles()
|
||||
+ self.get_referenced_citation_handles()
|
||||
)
|
||||
|
||||
def merge(self, acquisition):
|
||||
|
@ -28,8 +28,8 @@ Provide the different Attribute Types for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -39,7 +39,16 @@ def _T_(value, context=""): # enable deferred translations
|
||||
return "%s\x04%s" % (context, value) if context else value
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# AttributeType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class AttributeType(GrampsType):
|
||||
"""
|
||||
Class describing the type of an attribute.
|
||||
"""
|
||||
|
||||
UNKNOWN = -1
|
||||
CUSTOM = 0
|
||||
CASTE = 1
|
||||
@ -92,7 +101,6 @@ class AttributeType(GrampsType):
|
||||
"""
|
||||
if self.value == self.CUSTOM:
|
||||
return str(self)
|
||||
elif self._BASEMAP[self.value + 1]: # UNKNOWN is before CUSTOM, sigh
|
||||
if self._BASEMAP[self.value + 1]: # UNKNOWN is before CUSTOM, sigh
|
||||
return self._BASEMAP[self.value + 1][1]
|
||||
else:
|
||||
return self.UNKNOWN
|
||||
return self.UNKNOWN
|
||||
|
@ -24,16 +24,16 @@ Base Object class for Gramps
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
# Python modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from abc import ABCMeta, abstractmethod
|
||||
import re
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Base Object
|
||||
# BaseObject class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class BaseObject(metaclass=ABCMeta):
|
||||
@ -185,7 +185,6 @@ class BaseObject(metaclass=ABCMeta):
|
||||
:param acquisition: The object to incorporate.
|
||||
:type acquisition: BaseObject
|
||||
"""
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def create(cls, data):
|
||||
|
@ -25,35 +25,32 @@
|
||||
"""
|
||||
Child Reference class for Gramps.
|
||||
"""
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .privacybase import PrivacyBase
|
||||
from .citationbase import CitationBase
|
||||
from .notebase import NoteBase
|
||||
from .refbase import RefBase
|
||||
from .childreftype import ChildRefType
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .childreftype import ChildRefType
|
||||
from .citationbase import CitationBase
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .notebase import NoteBase
|
||||
from .privacybase import PrivacyBase
|
||||
from .refbase import RefBase
|
||||
from .secondaryobj import SecondaryObject
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Person References for Person/Family
|
||||
# ChildRef class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class ChildRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
||||
"""
|
||||
Person reference class.
|
||||
|
||||
This class is for keeping information about how the person relates
|
||||
to another person from the database, if not through family.
|
||||
Examples would be: godparent, friend, etc.
|
||||
A class for tracking information about how a child relates to their parents.
|
||||
"""
|
||||
|
||||
def __init__(self, source=None):
|
||||
@ -120,7 +117,11 @@ class ChildRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
||||
"items": {"type": "string", "maxLength": 50},
|
||||
"title": _("Notes"),
|
||||
},
|
||||
"ref": {"type": "string", "maxLength": 50, "title": _("Handle")},
|
||||
"ref": {
|
||||
"type": "string",
|
||||
"maxLength": 50,
|
||||
"title": _("Handle"),
|
||||
},
|
||||
"frel": ChildRefType.get_schema(),
|
||||
"mrel": ChildRefType.get_schema(),
|
||||
},
|
||||
@ -163,7 +164,8 @@ class ChildRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
||||
:rtype: list
|
||||
"""
|
||||
ret = (
|
||||
self.get_referenced_note_handles() + self.get_referenced_citation_handles()
|
||||
self.get_referenced_note_handles()
|
||||
+ self.get_referenced_citation_handles()
|
||||
)
|
||||
if self.ref:
|
||||
ret += [("Person", self.ref)]
|
||||
@ -191,11 +193,9 @@ class ChildRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
||||
"""
|
||||
if self.ref != other.ref:
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
return EQUAL
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
|
@ -27,12 +27,17 @@ Provide the different child reference types.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# ChildRefType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class ChildRefType(GrampsType):
|
||||
"""
|
||||
Provide the different ChildRef types.
|
||||
|
@ -27,7 +27,7 @@ Citation object for Gramps.
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# standard python modules
|
||||
# Python modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
import logging
|
||||
@ -37,14 +37,14 @@ import logging
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .primaryobj import PrimaryObject
|
||||
from .mediabase import MediaBase
|
||||
from .notebase import NoteBase
|
||||
from .datebase import DateBase
|
||||
from .tagbase import TagBase
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .attrbase import SrcAttributeBase
|
||||
from .citationbase import IndirectCitationBase
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .datebase import DateBase
|
||||
from .mediabase import MediaBase
|
||||
from .notebase import NoteBase
|
||||
from .primaryobj import PrimaryObject
|
||||
from .tagbase import TagBase
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -57,7 +57,12 @@ LOG = logging.getLogger(".citation")
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class Citation(
|
||||
MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase, DateBase, PrimaryObject
|
||||
MediaBase,
|
||||
NoteBase,
|
||||
SrcAttributeBase,
|
||||
IndirectCitationBase,
|
||||
DateBase,
|
||||
PrimaryObject,
|
||||
):
|
||||
"""
|
||||
A record of a citation of a source of information.
|
||||
@ -92,16 +97,21 @@ class Citation(
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
from .srcattribute import SrcAttribute
|
||||
from .mediaref import MediaRef
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .date import Date
|
||||
from .mediaref import MediaRef
|
||||
from .srcattribute import SrcAttribute
|
||||
|
||||
return {
|
||||
"type": "object",
|
||||
"title": _("Citation"),
|
||||
"properties": {
|
||||
"_class": {"enum": [cls.__name__]},
|
||||
"handle": {"type": "string", "maxLength": 50, "title": _("Handle")},
|
||||
"handle": {
|
||||
"type": "string",
|
||||
"maxLength": 50,
|
||||
"title": _("Handle"),
|
||||
},
|
||||
"gramps_id": {"type": "string", "title": _("Gramps ID")},
|
||||
"date": {
|
||||
"oneOf": [{"type": "null"}, Date.get_schema()],
|
||||
@ -205,9 +215,9 @@ class Citation(
|
||||
"""
|
||||
if classname == "Note":
|
||||
return handle in [ref.ref for ref in self.note_list]
|
||||
elif classname == "Media":
|
||||
if classname == "Media":
|
||||
return handle in [ref.ref for ref in self.media_list]
|
||||
elif classname == "Source":
|
||||
if classname == "Source":
|
||||
return handle == self.get_reference_handle()
|
||||
return False
|
||||
|
||||
@ -293,7 +303,10 @@ class Citation(
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
ret = self.get_referenced_note_handles() + self.get_referenced_tag_handles()
|
||||
ret = (
|
||||
self.get_referenced_note_handles()
|
||||
+ self.get_referenced_tag_handles()
|
||||
)
|
||||
if self.get_reference_handle():
|
||||
ret += [("Source", self.get_reference_handle())]
|
||||
return ret
|
||||
@ -337,7 +350,9 @@ class Citation(
|
||||
return self.page
|
||||
|
||||
def set_reference_handle(self, val):
|
||||
"""Set the source handle."""
|
||||
self.source_handle = val
|
||||
|
||||
def get_reference_handle(self):
|
||||
"""Get the source handle."""
|
||||
return self.source_handle
|
||||
|
@ -90,9 +90,8 @@ class CitationBase:
|
||||
"""
|
||||
if handle in self.citation_list:
|
||||
return False
|
||||
else:
|
||||
self.citation_list.append(handle)
|
||||
return True
|
||||
self.citation_list.append(handle)
|
||||
return True
|
||||
|
||||
def remove_citation_references(self, citation_handle_list):
|
||||
"""
|
||||
@ -111,7 +110,9 @@ class CitationBase:
|
||||
for handle in citation_handle_list:
|
||||
if handle in self.citation_list:
|
||||
LOG.debug(
|
||||
"remove handle %s from citation_list %s", handle, self.citation_list
|
||||
"remove handle %s from citation_list %s",
|
||||
handle,
|
||||
self.citation_list,
|
||||
)
|
||||
self.citation_list.remove(handle)
|
||||
LOG.debug("get_citation_child_list %s", self.get_citation_child_list())
|
||||
@ -239,7 +240,7 @@ class CitationBase:
|
||||
if new_handle in self.citation_list:
|
||||
new_ref = new_handle
|
||||
n_replace = refs_list.count(old_handle)
|
||||
for ix_replace in range(n_replace):
|
||||
for dummy_ix_replace in range(n_replace):
|
||||
idx = refs_list.index(old_handle)
|
||||
if new_ref:
|
||||
self.citation_list.pop(idx)
|
||||
|
@ -26,49 +26,48 @@
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
# Python modules
|
||||
#
|
||||
# ------------------------------------------------------------------------
|
||||
import logging
|
||||
import calendar
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gnome/GTK modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
# ------------------------------------------------------------------------
|
||||
from ..config import config
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from ..errors import DateError
|
||||
from .gcalendar import (
|
||||
gregorian_sdn,
|
||||
julian_sdn,
|
||||
hebrew_sdn,
|
||||
french_sdn,
|
||||
persian_sdn,
|
||||
islamic_sdn,
|
||||
swedish_sdn,
|
||||
gregorian_ymd,
|
||||
julian_ymd,
|
||||
hebrew_ymd,
|
||||
french_ymd,
|
||||
persian_ymd,
|
||||
gregorian_sdn,
|
||||
gregorian_ymd,
|
||||
hebrew_sdn,
|
||||
hebrew_ymd,
|
||||
islamic_sdn,
|
||||
islamic_ymd,
|
||||
julian_sdn,
|
||||
julian_ymd,
|
||||
persian_sdn,
|
||||
persian_ymd,
|
||||
swedish_sdn,
|
||||
swedish_ymd,
|
||||
)
|
||||
from ..config import config
|
||||
from ..errors import DateError
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
|
||||
_ = glocale.translation.sgettext
|
||||
|
||||
LOG = logging.getLogger(".Date")
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Span class
|
||||
#
|
||||
# ------------------------------------------------------------------------
|
||||
class Span:
|
||||
"""
|
||||
Span is used to represent the difference between two dates for three
|
||||
@ -102,130 +101,151 @@ class Span:
|
||||
if self.date2.calendar != Date.CAL_GREGORIAN:
|
||||
self.date2 = self.date2.to_calendar("gregorian")
|
||||
if self.date1.get_modifier() == Date.MOD_NONE:
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, 0)
|
||||
self.minmax = (val, val)
|
||||
elif self.date2.get_modifier() in [Date.MOD_BEFORE, Date.MOD_TO]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.BEFORE)
|
||||
self.minmax = (val - Span.BEFORE, val)
|
||||
elif self.date2.get_modifier() in [Date.MOD_AFTER, Date.MOD_FROM]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, Span.AFTER)
|
||||
self.minmax = (val, val + Span.AFTER)
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
elif self.date2.is_compound():
|
||||
start, stop = self.date2.get_start_stop_range()
|
||||
start = Date(*start)
|
||||
stop = Date(*stop)
|
||||
val1 = self.date1.sortval - stop.sortval # min
|
||||
val2 = self.date1.sortval - start.sortval # max
|
||||
self.sort = (val1, val2 - val1)
|
||||
self.minmax = (val1, val2)
|
||||
self.__init_date_mod_none()
|
||||
elif self.date1.get_modifier() == Date.MOD_BEFORE:
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, 0)
|
||||
self.minmax = (0, val)
|
||||
elif self.date2.get_modifier() in [Date.MOD_BEFORE, Date.MOD_TO]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.BEFORE)
|
||||
self.minmax = (val, val + Span.BEFORE)
|
||||
elif self.date2.get_modifier() in [Date.MOD_AFTER, Date.MOD_FROM]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.AFTER)
|
||||
self.minmax = (0, val)
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
elif self.date2.is_compound():
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
self.__init_date_mod_before()
|
||||
elif self.date1.get_modifier() == Date.MOD_AFTER:
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, Span.AFTER)
|
||||
self.minmax = (val, val + Span.AFTER)
|
||||
elif self.date2.get_modifier() in [Date.MOD_BEFORE, Date.MOD_TO]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, Span.AFTER)
|
||||
self.minmax = (val - Span.BEFORE, val + Span.AFTER)
|
||||
elif self.date2.get_modifier() in [Date.MOD_AFTER, Date.MOD_FROM]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, Span.AFTER)
|
||||
self.minmax = (val, val + Span.AFTER)
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.AFTER)
|
||||
elif self.date2.is_compound():
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
self.__init_date_mod_after()
|
||||
elif self.date1.get_modifier() == Date.MOD_ABOUT:
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
elif self.date2.get_modifier() in [Date.MOD_BEFORE, Date.MOD_TO]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.BEFORE)
|
||||
self.minmax = (val - Span.BEFORE, val + Span.ABOUT)
|
||||
elif self.date2.get_modifier() in [Date.MOD_AFTER, Date.MOD_FROM]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, Span.AFTER)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
elif self.date2.is_compound():
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
self.__init_date_mod_about()
|
||||
elif self.date1.is_compound():
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
start, stop = self.date1.get_start_stop_range()
|
||||
start = Date(*start)
|
||||
stop = Date(*stop)
|
||||
val1 = start.sortval - self.date2.sortval # min
|
||||
val2 = stop.sortval - self.date2.sortval # max
|
||||
self.sort = (val1, val2 - val1)
|
||||
self.minmax = (val1, val2)
|
||||
elif self.date2.get_modifier() in [Date.MOD_BEFORE, Date.MOD_TO]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, Span.BEFORE)
|
||||
self.minmax = (val - Span.BEFORE, val + Span.BEFORE)
|
||||
elif self.date2.get_modifier() in [Date.MOD_AFTER, Date.MOD_FROM]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.AFTER)
|
||||
self.minmax = (val - Span.AFTER, val + Span.AFTER)
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
elif self.date2.is_compound():
|
||||
start1, stop1 = self.date1.get_start_stop_range()
|
||||
start2, stop2 = self.date2.get_start_stop_range()
|
||||
start1 = Date(*start1)
|
||||
start2 = Date(*start2)
|
||||
stop1 = Date(*stop1)
|
||||
stop2 = Date(*stop2)
|
||||
val1 = start1.sortval - stop2.sortval # min
|
||||
val2 = stop1.sortval - start2.sortval # max
|
||||
self.sort = (val1, val2 - val1)
|
||||
self.minmax = (val1, val2)
|
||||
self.__init_compound_date()
|
||||
|
||||
def __init_date_mod_none(self):
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, 0)
|
||||
self.minmax = (val, val)
|
||||
elif self.date2.get_modifier() in [Date.MOD_BEFORE, Date.MOD_TO]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.BEFORE)
|
||||
self.minmax = (val - Span.BEFORE, val)
|
||||
elif self.date2.get_modifier() in [Date.MOD_AFTER, Date.MOD_FROM]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, Span.AFTER)
|
||||
self.minmax = (val, val + Span.AFTER)
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
elif self.date2.is_compound():
|
||||
start, stop = self.date2.get_start_stop_range()
|
||||
start = Date(*start)
|
||||
stop = Date(*stop)
|
||||
val1 = self.date1.sortval - stop.sortval # min
|
||||
val2 = self.date1.sortval - start.sortval # max
|
||||
self.sort = (val1, val2 - val1)
|
||||
self.minmax = (val1, val2)
|
||||
|
||||
def __init_date_mod_before(self):
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, 0)
|
||||
self.minmax = (0, val)
|
||||
elif self.date2.get_modifier() in [Date.MOD_BEFORE, Date.MOD_TO]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.BEFORE)
|
||||
self.minmax = (val, val + Span.BEFORE)
|
||||
elif self.date2.get_modifier() in [Date.MOD_AFTER, Date.MOD_FROM]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.AFTER)
|
||||
self.minmax = (0, val)
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
elif self.date2.is_compound():
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
|
||||
def __init_date_mod_after(self):
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, Span.AFTER)
|
||||
self.minmax = (val, val + Span.AFTER)
|
||||
elif self.date2.get_modifier() in [Date.MOD_BEFORE, Date.MOD_TO]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, Span.AFTER)
|
||||
self.minmax = (val - Span.BEFORE, val + Span.AFTER)
|
||||
elif self.date2.get_modifier() in [Date.MOD_AFTER, Date.MOD_FROM]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, Span.AFTER)
|
||||
self.minmax = (val, val + Span.AFTER)
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.AFTER)
|
||||
elif self.date2.is_compound():
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
|
||||
def __init_date_mod_about(self):
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
elif self.date2.get_modifier() in [Date.MOD_BEFORE, Date.MOD_TO]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.BEFORE)
|
||||
self.minmax = (val - Span.BEFORE, val + Span.ABOUT)
|
||||
elif self.date2.get_modifier() in [Date.MOD_AFTER, Date.MOD_FROM]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, Span.AFTER)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
elif self.date2.is_compound():
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
|
||||
def __init_compound_date(self):
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
start, stop = self.date1.get_start_stop_range()
|
||||
start = Date(*start)
|
||||
stop = Date(*stop)
|
||||
val1 = start.sortval - self.date2.sortval # min
|
||||
val2 = stop.sortval - self.date2.sortval # max
|
||||
self.sort = (val1, val2 - val1)
|
||||
self.minmax = (val1, val2)
|
||||
elif self.date2.get_modifier() in [Date.MOD_BEFORE, Date.MOD_TO]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, Span.BEFORE)
|
||||
self.minmax = (val - Span.BEFORE, val + Span.BEFORE)
|
||||
elif self.date2.get_modifier() in [Date.MOD_AFTER, Date.MOD_FROM]:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.AFTER)
|
||||
self.minmax = (val - Span.AFTER, val + Span.AFTER)
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
val = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (val, -Span.ABOUT)
|
||||
self.minmax = (val - Span.ABOUT, val + Span.ABOUT)
|
||||
elif self.date2.is_compound():
|
||||
start1, stop1 = self.date1.get_start_stop_range()
|
||||
start2, stop2 = self.date2.get_start_stop_range()
|
||||
start1 = Date(*start1)
|
||||
start2 = Date(*start2)
|
||||
stop1 = Date(*stop1)
|
||||
stop2 = Date(*stop2)
|
||||
val1 = start1.sortval - stop2.sortval # min
|
||||
val2 = stop1.sortval - start2.sortval # max
|
||||
self.sort = (val1, val2 - val1)
|
||||
self.minmax = (val1, val2)
|
||||
|
||||
def is_valid(self):
|
||||
"""
|
||||
Return date validity.
|
||||
"""
|
||||
return self.valid
|
||||
|
||||
def tuple(self):
|
||||
"""
|
||||
Return span length as tuple.
|
||||
"""
|
||||
return self._diff(self.date1, self.date2)
|
||||
|
||||
def __getitem__(self, pos):
|
||||
@ -238,23 +258,7 @@ class Span:
|
||||
"""
|
||||
if self.negative:
|
||||
return -(self.sort[0] + self.sort[1])
|
||||
else:
|
||||
return self.sort[0] + self.sort[1]
|
||||
|
||||
## def __cmp__(self, other):
|
||||
## """
|
||||
## DEPRECATED - not available in python 3
|
||||
##
|
||||
## Comparing two Spans for SORTING purposes.
|
||||
## Use cmp(abs(int(span1)), abs(int(span2))) for comparing
|
||||
## actual spans of times, as spans have directionality
|
||||
## as indicated by negative values.
|
||||
## """
|
||||
## raise NotImplementedError
|
||||
## if other is None:
|
||||
## return cmp(int(self), -9999)
|
||||
## else:
|
||||
## return cmp(int(self), int(other))
|
||||
return self.sort[0] + self.sort[1]
|
||||
|
||||
def as_age(self):
|
||||
"""
|
||||
@ -389,8 +393,7 @@ class Span:
|
||||
)
|
||||
if _repr.find("-") == -1: # we don't have a negative value to return.
|
||||
return _repr
|
||||
else:
|
||||
return "(" + _repr.replace("-", "") + ")"
|
||||
return "(" + _repr.replace("-", "") + ")"
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
@ -499,8 +502,7 @@ class Span:
|
||||
days = (days - years * 365) - months * 30
|
||||
if self.negative:
|
||||
return (-years, -months, -days)
|
||||
else:
|
||||
return (years, months, days)
|
||||
return (years, months, days)
|
||||
ymd1 = [i or 1 for i in date1.get_ymd()]
|
||||
ymd2 = [i or 1 for i in date2.get_ymd()]
|
||||
# ymd1 - ymd2 (1998, 12, 32) - (1982, 12, 15)
|
||||
@ -538,9 +540,8 @@ class Span:
|
||||
return (-1, -1, -1)
|
||||
if self.negative:
|
||||
return (-years, -months, -(days - diff))
|
||||
else:
|
||||
return (years, months, days - diff)
|
||||
elif edate > date2:
|
||||
return (years, months, days - diff)
|
||||
if edate > date2:
|
||||
diff = 0
|
||||
while edate >> date2 and diff > -60:
|
||||
diff -= 1
|
||||
@ -549,12 +550,10 @@ class Span:
|
||||
return (-1, -1, -1)
|
||||
if self.negative:
|
||||
return (-years, -months, -(days + diff))
|
||||
else:
|
||||
return (years, months, days + diff)
|
||||
return (years, months, days + diff)
|
||||
if self.negative:
|
||||
return (-years, -months, -days)
|
||||
else:
|
||||
return (years, months, days)
|
||||
return (years, months, days)
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
@ -666,7 +665,7 @@ class Date:
|
||||
elif len(source) == 3:
|
||||
pass # source is ok
|
||||
else:
|
||||
raise AttributeError("invalid args to Date: %s" % source)
|
||||
raise AttributeError(f"invalid args to Date: {source}")
|
||||
self.format = None
|
||||
#### ok, process either date or tuple
|
||||
if isinstance(source, tuple):
|
||||
@ -788,32 +787,14 @@ class Date:
|
||||
self.sortval = source.sortval
|
||||
self.newyear = source.newyear
|
||||
|
||||
## PYTHON 3 no __cmp__
|
||||
## def __cmp__(self, other):
|
||||
## """
|
||||
## Compare two dates.
|
||||
##
|
||||
## Comparison function. Allows the usage of equality tests.
|
||||
## This allows you do run statements like 'date1 <= date2'
|
||||
## """
|
||||
## if isinstance(other, Date):
|
||||
## return cmp(self.sortval, other.sortval)
|
||||
## else:
|
||||
## return -1
|
||||
|
||||
# Can't use this (as is) as this breaks comparing dates to None
|
||||
# def __eq__(self, other):
|
||||
# return self.sortval == other.sortval
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
Equality based on sort value, use is_equal/match instead if needed
|
||||
"""
|
||||
if isinstance(other, Date):
|
||||
return self.sortval == other.sortval
|
||||
else:
|
||||
# indicate this is not supported
|
||||
return False
|
||||
# indicate this is not supported
|
||||
return False
|
||||
|
||||
def __ne__(self, other):
|
||||
"""
|
||||
@ -821,9 +802,8 @@ class Date:
|
||||
"""
|
||||
if isinstance(other, Date):
|
||||
return self.sortval != other.sortval
|
||||
else:
|
||||
# indicate this is not supported
|
||||
return True
|
||||
# indicate this is not supported
|
||||
return True
|
||||
|
||||
def __le__(self, other):
|
||||
"""
|
||||
@ -832,9 +812,8 @@ class Date:
|
||||
"""
|
||||
if isinstance(other, Date):
|
||||
return self.sortval <= other.sortval
|
||||
else:
|
||||
# indicate this is not supported
|
||||
return NotImplemented
|
||||
# indicate this is not supported
|
||||
return NotImplemented
|
||||
|
||||
def __ge__(self, other):
|
||||
"""
|
||||
@ -843,9 +822,8 @@ class Date:
|
||||
"""
|
||||
if isinstance(other, Date):
|
||||
return self.sortval >= other.sortval
|
||||
else:
|
||||
# indicate this is not supported
|
||||
return NotImplemented
|
||||
# indicate this is not supported
|
||||
return NotImplemented
|
||||
|
||||
def __add__(self, other):
|
||||
"""
|
||||
@ -853,10 +831,9 @@ class Date:
|
||||
"""
|
||||
if isinstance(other, int):
|
||||
return self.copy_offset_ymd(other)
|
||||
elif isinstance(other, (tuple, list)):
|
||||
if isinstance(other, (tuple, list)):
|
||||
return self.copy_offset_ymd(*other)
|
||||
else:
|
||||
raise AttributeError("unknown date add type: %s " % type(other))
|
||||
raise AttributeError(f"unknown date add type: {type(other)}")
|
||||
|
||||
def __radd__(self, other):
|
||||
"""
|
||||
@ -870,12 +847,11 @@ class Date:
|
||||
"""
|
||||
if isinstance(other, int): # Date - value -> Date
|
||||
return self.copy_offset_ymd(-other)
|
||||
elif isinstance(other, (tuple, list)): # Date - (y, m, d) -> Date
|
||||
if isinstance(other, (tuple, list)): # Date - (y, m, d) -> Date
|
||||
return self.copy_offset_ymd(*[-i for i in other])
|
||||
elif isinstance(other, type(self)): # Date1 - Date2 -> tuple
|
||||
if isinstance(other, type(self)): # Date1 - Date2 -> tuple
|
||||
return Span(self, other)
|
||||
else:
|
||||
raise AttributeError("unknown date sub type: %s " % type(other))
|
||||
raise AttributeError(f"unknown date sub type: {type(other)}")
|
||||
|
||||
def __contains__(self, string):
|
||||
"""
|
||||
@ -915,7 +891,10 @@ class Date:
|
||||
Needed, because the __cmp__ only looks at the sorting value, and
|
||||
ignores the modifiers/comments.
|
||||
"""
|
||||
if self.modifier == other.modifier and self.modifier == Date.MOD_TEXTONLY:
|
||||
if (
|
||||
self.modifier == other.modifier
|
||||
and self.modifier == Date.MOD_TEXTONLY
|
||||
):
|
||||
value = self.text == other.text
|
||||
else:
|
||||
value = (
|
||||
@ -994,7 +973,10 @@ class Date:
|
||||
startmin = date_offset(stopmax, 1)
|
||||
fdiff = config.get("behavior.date-after-range")
|
||||
stopmax = (startmin[0] + fdiff, startmin[1], startmin[2])
|
||||
elif self.modifier == Date.MOD_ABOUT or self.quality == Date.QUAL_ESTIMATED:
|
||||
elif (
|
||||
self.modifier == Date.MOD_ABOUT
|
||||
or self.quality == Date.QUAL_ESTIMATED
|
||||
):
|
||||
fdiff = config.get("behavior.date-about-range")
|
||||
startmin = (startmin[0] - fdiff, startmin[1], startmin[2])
|
||||
stopmax = (stopmax[0] + fdiff, stopmax[1], stopmax[2])
|
||||
@ -1008,17 +990,16 @@ class Date:
|
||||
"""
|
||||
if other_date.modifier == Date.MOD_NONE:
|
||||
return other_date.sortval == self.sortval
|
||||
elif other_date.modifier in [Date.MOD_BEFORE, Date.MOD_TO]:
|
||||
if other_date.modifier in [Date.MOD_BEFORE, Date.MOD_TO]:
|
||||
return other_date.sortval > self.sortval
|
||||
elif other_date.modifier in [Date.MOD_AFTER, Date.MOD_FROM]:
|
||||
if other_date.modifier in [Date.MOD_AFTER, Date.MOD_FROM]:
|
||||
return other_date.sortval < self.sortval
|
||||
elif other_date.is_compound():
|
||||
if other_date.is_compound():
|
||||
start, stop = other_date.get_start_stop_range()
|
||||
start = Date(*start)
|
||||
stop = Date(*stop)
|
||||
return start.sortval <= self.sortval <= stop.sortval
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
def match(self, other_date, comparison="="):
|
||||
"""
|
||||
@ -1041,16 +1022,12 @@ class Date:
|
||||
>> True if all parts of other_date > all parts of self
|
||||
========== =======================================================
|
||||
"""
|
||||
if (
|
||||
other_date.modifier == Date.MOD_TEXTONLY
|
||||
or self.modifier == Date.MOD_TEXTONLY
|
||||
):
|
||||
if Date.MOD_TEXTONLY in [other_date.modifier, self.modifier]:
|
||||
if comparison == "=":
|
||||
return self.text.upper().find(other_date.text.upper()) != -1
|
||||
elif comparison == "==":
|
||||
if comparison == "==":
|
||||
return self.text == other_date.text
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
if self.sortval == 0 or other_date.sortval == 0:
|
||||
return False
|
||||
|
||||
@ -1066,29 +1043,30 @@ class Date:
|
||||
or (other_start <= self_start <= other_stop)
|
||||
or (other_start <= self_stop <= other_stop)
|
||||
)
|
||||
elif comparison == "==":
|
||||
if comparison == "==":
|
||||
# If they match exactly on start and stop
|
||||
return (self_start == other_start) and (other_stop == other_stop)
|
||||
elif comparison == "<":
|
||||
if comparison == "<":
|
||||
# If any < any
|
||||
return self_start < other_stop
|
||||
elif comparison == "<=":
|
||||
if comparison == "<=":
|
||||
# If any < any
|
||||
return self_start <= other_stop
|
||||
elif comparison == "<<":
|
||||
if comparison == "<<":
|
||||
# If all < all
|
||||
return self_stop < other_start
|
||||
elif comparison == ">":
|
||||
if comparison == ">":
|
||||
# If any > any
|
||||
return self_stop > other_start
|
||||
elif comparison == ">=":
|
||||
if comparison == ">=":
|
||||
# If any > any
|
||||
return self_stop >= other_start
|
||||
elif comparison == ">>":
|
||||
if comparison == ">>":
|
||||
# If all > all
|
||||
return self_start > other_stop
|
||||
else:
|
||||
raise AttributeError("invalid match comparison operator: '%s'" % comparison)
|
||||
raise AttributeError(
|
||||
f"invalid match comparison operator: '{comparison}'"
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
"""
|
||||
@ -1123,12 +1101,12 @@ class Date:
|
||||
|
||||
if self.calendar != Date.CAL_GREGORIAN:
|
||||
if nyear:
|
||||
cal = " (%s,%s)" % (Date.calendar_names[self.calendar], nyear)
|
||||
cal = f" ({Date.calendar_names[self.calendar]},{nyear})"
|
||||
else:
|
||||
cal = " (%s)" % Date.calendar_names[self.calendar]
|
||||
cal = f" ({Date.calendar_names[self.calendar]})"
|
||||
else:
|
||||
if nyear:
|
||||
cal = " (%s)" % nyear
|
||||
cal = f" ({nyear})"
|
||||
else:
|
||||
cal = ""
|
||||
|
||||
@ -1156,7 +1134,7 @@ class Date:
|
||||
self.dateval[Date._POS_MON],
|
||||
self.dateval[Date._POS_DAY],
|
||||
)
|
||||
return "%s%s%s%s" % (qual, pref, val, cal)
|
||||
return f"{qual}{pref}{val}{cal}"
|
||||
|
||||
def newyear_to_str(self):
|
||||
"""
|
||||
@ -1171,7 +1149,7 @@ class Date:
|
||||
elif self.newyear == Date.NEWYEAR_SEP1:
|
||||
nyear = "Sep1"
|
||||
elif isinstance(self.newyear, (list, tuple)):
|
||||
nyear = "%s-%s" % (self.newyear[0], self.newyear[1])
|
||||
nyear = f"{self.newyear[0]}-{self.newyear[1]}"
|
||||
else:
|
||||
nyear = "Err"
|
||||
return nyear
|
||||
@ -1183,7 +1161,7 @@ class Date:
|
||||
'', 'Jan1', 'Mar1', '3-25', '9-1', etc.
|
||||
"""
|
||||
string = string.strip().lower()
|
||||
if string == "" or string == "jan1":
|
||||
if string in ["", "jan1"]:
|
||||
code = Date.NEWYEAR_JAN1
|
||||
elif string == "mar1":
|
||||
code = Date.NEWYEAR_MAR1
|
||||
@ -1272,7 +1250,11 @@ class Date:
|
||||
"""
|
||||
Set the quality selected for the date.
|
||||
"""
|
||||
if val not in (Date.QUAL_NONE, Date.QUAL_ESTIMATED, Date.QUAL_CALCULATED):
|
||||
if val not in (
|
||||
Date.QUAL_NONE,
|
||||
Date.QUAL_ESTIMATED,
|
||||
Date.QUAL_CALCULATED,
|
||||
):
|
||||
raise DateError("Invalid quality")
|
||||
self.quality = val
|
||||
|
||||
@ -1312,10 +1294,8 @@ class Date:
|
||||
is returned. If slash is True, then the date is in the form of 1530/1.
|
||||
"""
|
||||
if self.modifier == Date.MOD_TEXTONLY:
|
||||
val = Date.EMPTY
|
||||
else:
|
||||
val = self.dateval[0:4]
|
||||
return val
|
||||
return Date.EMPTY
|
||||
return self.dateval[0:4]
|
||||
|
||||
def get_stop_date(self):
|
||||
"""
|
||||
@ -1326,40 +1306,32 @@ class Date:
|
||||
is returned. If slash is True, then the date is in the form of 1530/1.
|
||||
"""
|
||||
if self.is_compound():
|
||||
val = self.dateval[4:8]
|
||||
else:
|
||||
val = Date.EMPTY
|
||||
return val
|
||||
return self.dateval[4:8]
|
||||
return Date.EMPTY
|
||||
|
||||
def _get_low_item(self, index):
|
||||
"""
|
||||
Return the item specified.
|
||||
"""
|
||||
if self.modifier == Date.MOD_TEXTONLY:
|
||||
val = 0
|
||||
else:
|
||||
val = self.dateval[index]
|
||||
return val
|
||||
return 0
|
||||
return self.dateval[index]
|
||||
|
||||
def _get_low_item_valid(self, index):
|
||||
"""
|
||||
Determine if the item specified is valid.
|
||||
"""
|
||||
if self.modifier == Date.MOD_TEXTONLY:
|
||||
val = False
|
||||
else:
|
||||
val = self.dateval[index] != 0
|
||||
return val
|
||||
return False
|
||||
return self.dateval[index] != 0
|
||||
|
||||
def _get_high_item(self, index):
|
||||
"""
|
||||
Return the item specified.
|
||||
"""
|
||||
if self.is_compound():
|
||||
val = self.dateval[index]
|
||||
else:
|
||||
val = 0
|
||||
return val
|
||||
return self.dateval[index]
|
||||
return 0
|
||||
|
||||
def get_year(self):
|
||||
"""
|
||||
@ -1385,10 +1357,9 @@ class Date:
|
||||
cal = self.calendar
|
||||
if cal == self.calendar:
|
||||
return self.get_year()
|
||||
else:
|
||||
retval = Date(self)
|
||||
retval.convert_calendar(cal)
|
||||
return retval.get_year()
|
||||
retval = Date(self)
|
||||
retval.convert_calendar(cal)
|
||||
return retval.get_year()
|
||||
|
||||
def get_new_year(self):
|
||||
"""
|
||||
@ -1442,7 +1413,9 @@ class Date:
|
||||
year, month, day, Date._POS_RYR, Date._POS_RMON, Date._POS_RDAY
|
||||
)
|
||||
|
||||
def __set_yr_mon_day_offset(self, year, month, day, pos_yr, pos_mon, pos_day):
|
||||
def __set_yr_mon_day_offset(
|
||||
self, year, month, day, pos_yr, pos_mon, pos_day
|
||||
):
|
||||
dlist = list(self.dateval)
|
||||
if dlist[pos_yr]:
|
||||
dlist[pos_yr] += year
|
||||
@ -1506,9 +1479,8 @@ class Date:
|
||||
retval.set_yr_mon_day_offset(year, month, day)
|
||||
if orig_cal == 0:
|
||||
return retval
|
||||
else:
|
||||
retval.convert_calendar(orig_cal)
|
||||
return retval
|
||||
retval.convert_calendar(orig_cal)
|
||||
return retval
|
||||
|
||||
def copy_ymd(self, year=0, month=0, day=0, remove_stop_date=None):
|
||||
"""
|
||||
@ -1658,7 +1630,9 @@ class Date:
|
||||
if (self.get_month(), self.get_day()) >= split and split != (0, 0):
|
||||
year_delta = -1
|
||||
new_date = Date(
|
||||
self.get_year() + year_delta, self.get_month(), self.get_day()
|
||||
self.get_year() + year_delta,
|
||||
self.get_month(),
|
||||
self.get_day(),
|
||||
)
|
||||
new_date.set_calendar(self.calendar)
|
||||
new_date.recalc_sort_value()
|
||||
@ -1725,7 +1699,8 @@ class Date:
|
||||
raise DateError("Invalid value. Should be: (DD, MM, YY, slash)")
|
||||
if modifier in (Date.MOD_RANGE, Date.MOD_SPAN) and len(value) < 8:
|
||||
raise DateError(
|
||||
"Invalid value. Should be: (DD, MM, " "YY, slash1, DD, MM, YY, slash2)"
|
||||
"Invalid value. Should be: (DD, MM, "
|
||||
"YY, slash1, DD, MM, YY, slash2)"
|
||||
)
|
||||
if modifier not in (
|
||||
Date.MOD_NONE,
|
||||
@ -1739,15 +1714,17 @@ class Date:
|
||||
Date.MOD_TEXTONLY,
|
||||
):
|
||||
raise DateError("Invalid modifier")
|
||||
if quality not in (Date.QUAL_NONE, Date.QUAL_ESTIMATED, Date.QUAL_CALCULATED):
|
||||
if quality not in (
|
||||
Date.QUAL_NONE,
|
||||
Date.QUAL_ESTIMATED,
|
||||
Date.QUAL_CALCULATED,
|
||||
):
|
||||
raise DateError("Invalid quality")
|
||||
if calendar not in Date.CALENDARS:
|
||||
raise DateError("Invalid calendar")
|
||||
if newyear != 0 and calendar_has_fixed_newyear(calendar):
|
||||
raise DateError(
|
||||
"May not adjust newyear to {ny} for calendar {cal}".format(
|
||||
ny=newyear, cal=calendar
|
||||
)
|
||||
f"May not adjust newyear to {newyear} for calendar {calendar}"
|
||||
)
|
||||
|
||||
self.quality = quality
|
||||
@ -1795,9 +1772,9 @@ class Date:
|
||||
self.__compare(sanity.dateval, value, year_delta)
|
||||
except DateError as err:
|
||||
LOG.debug(
|
||||
"Sanity check failed - self: {}, sanity: {}".format(
|
||||
self.__dict__, sanity.__dict__
|
||||
)
|
||||
"Sanity check failed - self: %s, sanity: %s",
|
||||
self.__dict__,
|
||||
sanity.__dict__,
|
||||
)
|
||||
err.date = self
|
||||
raise
|
||||
@ -1809,21 +1786,21 @@ class Date:
|
||||
# each of d,m,y,sl is a pair from dateval and value, to compare
|
||||
adjusted, original = slash
|
||||
if adjusted != original:
|
||||
raise DateError("Invalid date value {}".format(value))
|
||||
raise DateError(f"Invalid date value {value}")
|
||||
|
||||
for adjusted, original in day, month:
|
||||
if adjusted != original and not (original == 0 and adjusted == 1):
|
||||
if adjusted != original and not (
|
||||
original == 0 and adjusted == 1
|
||||
):
|
||||
raise DateError(
|
||||
"Invalid day/month {} passed in value {}".format(
|
||||
original, value
|
||||
)
|
||||
f"Invalid day/month {original} passed in value {value}"
|
||||
)
|
||||
|
||||
adjusted, original = year
|
||||
adjusted -= year_delta
|
||||
if adjusted != original and not (original == 0 and adjusted == 1):
|
||||
raise DateError(
|
||||
"Invalid year {} passed in value {}".format(original, value)
|
||||
f"Invalid year {original} passed in value {value}"
|
||||
)
|
||||
|
||||
def recalc_sort_value(self):
|
||||
@ -1902,7 +1879,7 @@ class Date:
|
||||
"""
|
||||
Return True if the date is a date range or a date span.
|
||||
"""
|
||||
return self.modifier == Date.MOD_RANGE or self.modifier == Date.MOD_SPAN
|
||||
return self.modifier in [Date.MOD_RANGE, Date.MOD_SPAN]
|
||||
|
||||
def is_regular(self):
|
||||
"""
|
||||
@ -1924,7 +1901,11 @@ class Date:
|
||||
"""
|
||||
Return True if the date is fully specified.
|
||||
"""
|
||||
return self.get_year_valid() and self.get_month_valid() and self.get_day_valid()
|
||||
return (
|
||||
self.get_year_valid()
|
||||
and self.get_month_valid()
|
||||
and self.get_day_valid()
|
||||
)
|
||||
|
||||
def get_ymd(self):
|
||||
"""
|
||||
@ -1937,16 +1918,24 @@ class Date:
|
||||
Return (day, month, year, [slash]).
|
||||
"""
|
||||
if get_slash:
|
||||
return (self.get_day(), self.get_month(), self.get_year(), self.get_slash())
|
||||
else:
|
||||
return (self.get_day(), self.get_month(), self.get_year())
|
||||
return (
|
||||
self.get_day(),
|
||||
self.get_month(),
|
||||
self.get_year(),
|
||||
self.get_slash(),
|
||||
)
|
||||
return (self.get_day(), self.get_month(), self.get_year())
|
||||
|
||||
def get_stop_ymd(self):
|
||||
"""
|
||||
Return (year, month, day) of the stop date, or all-zeros if it's not
|
||||
defined.
|
||||
"""
|
||||
return (self.get_stop_year(), self.get_stop_month(), self.get_stop_day())
|
||||
return (
|
||||
self.get_stop_year(),
|
||||
self.get_stop_month(),
|
||||
self.get_stop_day(),
|
||||
)
|
||||
|
||||
def offset(self, value):
|
||||
"""
|
||||
@ -1958,7 +1947,9 @@ class Date:
|
||||
"""
|
||||
Return (year, month, day) of this date +- value.
|
||||
"""
|
||||
return Date(Date._calendar_change[Date.CAL_GREGORIAN](self.sortval + value))
|
||||
return Date(
|
||||
Date._calendar_change[Date.CAL_GREGORIAN](self.sortval + value)
|
||||
)
|
||||
|
||||
def lookup_calendar(self, calendar):
|
||||
"""
|
||||
@ -1971,13 +1962,16 @@ class Date:
|
||||
Lookup date quality keyword, even if translated.
|
||||
"""
|
||||
qualities = ["none", "estimated", "calculated"]
|
||||
ui_qualities = [_("none", "date-quality"), _("estimated"), _("calculated")]
|
||||
ui_qualities = [
|
||||
_("none", "date-quality"),
|
||||
_("estimated"),
|
||||
_("calculated"),
|
||||
]
|
||||
if quality.lower() in qualities:
|
||||
return qualities.index(quality.lower())
|
||||
elif quality.lower() in ui_qualities:
|
||||
if quality.lower() in ui_qualities:
|
||||
return ui_qualities.index(quality.lower())
|
||||
else:
|
||||
raise AttributeError("invalid quality: '%s'" % quality)
|
||||
raise AttributeError(f"invalid quality: '{quality}'")
|
||||
|
||||
def lookup_modifier(self, modifier):
|
||||
"""
|
||||
@ -2007,10 +2001,9 @@ class Date:
|
||||
]
|
||||
if modifier.lower() in mods:
|
||||
return mods.index(modifier.lower())
|
||||
elif modifier.lower() in ui_mods:
|
||||
if modifier.lower() in ui_mods:
|
||||
return ui_mods.index(modifier.lower())
|
||||
else:
|
||||
raise AttributeError("invalid modifier: '%s'" % modifier)
|
||||
raise AttributeError(f"invalid modifier: '{modifier}'")
|
||||
|
||||
def to_calendar(self, calendar_name):
|
||||
"""
|
||||
@ -2090,8 +2083,6 @@ def Today():
|
||||
"""
|
||||
Returns a Date object set to the current date.
|
||||
"""
|
||||
import time
|
||||
|
||||
current_date = Date()
|
||||
current_date.set_yr_mon_day(*time.localtime(time.time())[0:3])
|
||||
return current_date
|
||||
@ -2128,7 +2119,7 @@ def lookup_calendar(calendar):
|
||||
for pos, calendar_name in enumerate(Date.ui_calendar_names):
|
||||
if calendar.lower() == calendar_name.lower():
|
||||
return pos
|
||||
raise AttributeError("invalid calendar: '%s'" % calendar)
|
||||
raise AttributeError(f"invalid calendar: '{calendar}'")
|
||||
|
||||
|
||||
def gregorian(date):
|
||||
|
@ -32,7 +32,7 @@ from .date import Date
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# DateBase classes
|
||||
# DateBase class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class DateBase:
|
||||
|
@ -27,7 +27,7 @@ Event object for Gramps.
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# standard python modules
|
||||
# Python modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
import logging
|
||||
@ -37,16 +37,16 @@ import logging
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .primaryobj import PrimaryObject
|
||||
from .citationbase import CitationBase
|
||||
from .notebase import NoteBase
|
||||
from .mediabase import MediaBase
|
||||
from .attrbase import AttributeBase
|
||||
from .datebase import DateBase
|
||||
from .placebase import PlaceBase
|
||||
from .tagbase import TagBase
|
||||
from .eventtype import EventType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .attrbase import AttributeBase
|
||||
from .citationbase import CitationBase
|
||||
from .datebase import DateBase
|
||||
from .eventtype import EventType
|
||||
from .mediabase import MediaBase
|
||||
from .notebase import NoteBase
|
||||
from .placebase import PlaceBase
|
||||
from .primaryobj import PrimaryObject
|
||||
from .tagbase import TagBase
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -59,7 +59,13 @@ LOG = logging.getLogger(".citation")
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class Event(
|
||||
CitationBase, NoteBase, MediaBase, AttributeBase, DateBase, PlaceBase, PrimaryObject
|
||||
CitationBase,
|
||||
NoteBase,
|
||||
MediaBase,
|
||||
AttributeBase,
|
||||
DateBase,
|
||||
PlaceBase,
|
||||
PrimaryObject,
|
||||
):
|
||||
"""
|
||||
The Event record is used to store information about some type of
|
||||
@ -138,6 +144,7 @@ class Event(
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .attribute import Attribute
|
||||
from .date import Date
|
||||
from .mediaref import MediaRef
|
||||
@ -147,7 +154,11 @@ class Event(
|
||||
"title": _("Event"),
|
||||
"properties": {
|
||||
"_class": {"enum": [cls.__name__]},
|
||||
"handle": {"type": "string", "maxLength": 50, "title": _("Handle")},
|
||||
"handle": {
|
||||
"type": "string",
|
||||
"maxLength": 50,
|
||||
"title": _("Handle"),
|
||||
},
|
||||
"gramps_id": {"type": "string", "title": _("Gramps ID")},
|
||||
"type": EventType.get_schema(),
|
||||
"date": {
|
||||
@ -417,7 +428,9 @@ class Event(
|
||||
"""
|
||||
return self.__type
|
||||
|
||||
type = property(get_type, set_type, None, "Returns or sets type of the event")
|
||||
type = property(
|
||||
get_type, set_type, None, "Returns or sets type of the event"
|
||||
)
|
||||
|
||||
def set_description(self, description):
|
||||
"""
|
||||
|
@ -31,15 +31,15 @@ Event Reference class for Gramps
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .privacybase import PrivacyBase
|
||||
from .notebase import NoteBase
|
||||
from .attrbase import AttributeBase
|
||||
from .refbase import RefBase
|
||||
from .eventroletype import EventRoleType
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from .citationbase import CitationBase
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .attrbase import AttributeBase
|
||||
from .citationbase import CitationBase
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .eventroletype import EventRoleType
|
||||
from .notebase import NoteBase
|
||||
from .privacybase import PrivacyBase
|
||||
from .refbase import RefBase
|
||||
from .secondaryobj import SecondaryObject
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -94,6 +94,7 @@ class EventRef(
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .attribute import Attribute
|
||||
|
||||
return {
|
||||
@ -184,7 +185,8 @@ class EventRef(
|
||||
:rtype: list
|
||||
"""
|
||||
ret = (
|
||||
self.get_referenced_citation_handles() + self.get_referenced_note_handles()
|
||||
self.get_referenced_citation_handles()
|
||||
+ self.get_referenced_note_handles()
|
||||
)
|
||||
if self.ref:
|
||||
ret += [("Event", self.ref)]
|
||||
@ -212,11 +214,9 @@ class EventRef(
|
||||
"""
|
||||
if self.ref != other.ref or self.role != other.role:
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
return EQUAL
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
|
@ -27,13 +27,22 @@ Provide the different event roles.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.sgettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# EventRoleType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class EventRoleType(GrampsType):
|
||||
"""
|
||||
Class representing role a participant played in an event.
|
||||
"""
|
||||
|
||||
UNKNOWN = -1
|
||||
CUSTOM = 0
|
||||
PRIMARY = 1
|
||||
|
@ -28,12 +28,17 @@ Provide the different event types
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.sgettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# EventType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class EventType(GrampsType):
|
||||
"""
|
||||
Event types.
|
||||
@ -389,9 +394,9 @@ class EventType(GrampsType):
|
||||
"""
|
||||
if self.value in self._ABBREVIATIONS:
|
||||
return trans_text(self._ABBREVIATIONS[self.value])
|
||||
else:
|
||||
abbrev = str(self)
|
||||
if " " in abbrev:
|
||||
return ".".join([letter[0].lower() for letter in abbrev.split()]) + "."
|
||||
else:
|
||||
return abbrev[:3].lower() + "."
|
||||
abbrev = str(self)
|
||||
if " " in abbrev:
|
||||
return (
|
||||
".".join([letter[0].lower() for letter in abbrev.split()]) + "."
|
||||
)
|
||||
return abbrev[:3].lower() + "."
|
||||
|
@ -27,29 +27,29 @@ Family object for Gramps.
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# standard python modules
|
||||
# Python modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from warnings import warn
|
||||
import logging
|
||||
from warnings import warn
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .primaryobj import PrimaryObject
|
||||
from .citationbase import CitationBase
|
||||
from .notebase import NoteBase
|
||||
from .mediabase import MediaBase
|
||||
from .attrbase import AttributeBase
|
||||
from .eventref import EventRef
|
||||
from .ldsordbase import LdsOrdBase
|
||||
from .tagbase import TagBase
|
||||
from .childref import ChildRef
|
||||
from .familyreltype import FamilyRelType
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .attrbase import AttributeBase
|
||||
from .childref import ChildRef
|
||||
from .citationbase import CitationBase
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .eventref import EventRef
|
||||
from .familyreltype import FamilyRelType
|
||||
from .ldsordbase import LdsOrdBase
|
||||
from .mediabase import MediaBase
|
||||
from .notebase import NoteBase
|
||||
from .primaryobj import PrimaryObject
|
||||
from .tagbase import TagBase
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -145,17 +145,21 @@ class Family(
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
from .mediaref import MediaRef
|
||||
from .ldsord import LdsOrd
|
||||
from .childref import ChildRef
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .attribute import Attribute
|
||||
from .ldsord import LdsOrd
|
||||
from .mediaref import MediaRef
|
||||
|
||||
return {
|
||||
"type": "object",
|
||||
"title": _("Family"),
|
||||
"properties": {
|
||||
"_class": {"enum": [cls.__name__]},
|
||||
"handle": {"type": "string", "maxLength": 50, "title": _("Handle")},
|
||||
"handle": {
|
||||
"type": "string",
|
||||
"maxLength": 50,
|
||||
"title": _("Handle"),
|
||||
},
|
||||
"gramps_id": {"type": "string", "title": _("Gramps ID")},
|
||||
"father_handle": {
|
||||
"type": ["string", "null"],
|
||||
@ -238,8 +242,12 @@ class Family(
|
||||
|
||||
self.type = FamilyRelType()
|
||||
self.type.unserialize(the_type)
|
||||
self.event_ref_list = [EventRef().unserialize(er) for er in event_ref_list]
|
||||
self.child_ref_list = [ChildRef().unserialize(cr) for cr in child_ref_list]
|
||||
self.event_ref_list = [
|
||||
EventRef().unserialize(er) for er in event_ref_list
|
||||
]
|
||||
self.child_ref_list = [
|
||||
ChildRef().unserialize(cr) for cr in child_ref_list
|
||||
]
|
||||
MediaBase.unserialize(self, media_list)
|
||||
AttributeBase.unserialize(self, attribute_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
@ -263,12 +271,12 @@ class Family(
|
||||
"""
|
||||
if classname == "Event":
|
||||
return handle in [ref.ref for ref in self.event_ref_list]
|
||||
elif classname == "Person":
|
||||
if classname == "Person":
|
||||
return handle in (
|
||||
[ref.ref for ref in self.child_ref_list]
|
||||
+ [self.father_handle, self.mother_handle]
|
||||
)
|
||||
elif classname == "Place":
|
||||
if classname == "Place":
|
||||
return handle in [x.place for x in self.lds_ord_list]
|
||||
return False
|
||||
|
||||
@ -317,7 +325,7 @@ class Family(
|
||||
if new_handle in refs_list:
|
||||
new_ref = self.event_ref_list[refs_list.index(new_handle)]
|
||||
n_replace = refs_list.count(old_handle)
|
||||
for ix_replace in range(n_replace):
|
||||
for dummy_ix_replace in range(n_replace):
|
||||
idx = refs_list.index(old_handle)
|
||||
self.event_ref_list[idx].ref = new_handle
|
||||
refs_list[idx] = new_handle
|
||||
@ -335,7 +343,7 @@ class Family(
|
||||
if new_handle in refs_list:
|
||||
new_ref = self.child_ref_list[refs_list.index(new_handle)]
|
||||
n_replace = refs_list.count(old_handle)
|
||||
for ix_replace in range(n_replace):
|
||||
for dummy_ix_replace in range(n_replace):
|
||||
idx = refs_list.index(old_handle)
|
||||
self.child_ref_list[idx].ref = new_handle
|
||||
refs_list[idx] = new_handle
|
||||
@ -418,7 +426,8 @@ class Family(
|
||||
:rtype: list
|
||||
"""
|
||||
ret = (
|
||||
self.get_referenced_note_handles() + self.get_referenced_citation_handles()
|
||||
self.get_referenced_note_handles()
|
||||
+ self.get_referenced_citation_handles()
|
||||
)
|
||||
ret += [
|
||||
("Person", handle)
|
||||
@ -580,7 +589,9 @@ class Family(
|
||||
"""
|
||||
if not isinstance(child_ref, ChildRef):
|
||||
raise ValueError("expecting ChildRef instance")
|
||||
new_list = [ref for ref in self.child_ref_list if ref.ref != child_ref.ref]
|
||||
new_list = [
|
||||
ref for ref in self.child_ref_list if ref.ref != child_ref.ref
|
||||
]
|
||||
self.child_ref_list = new_list
|
||||
|
||||
def remove_child_handle(self, child_handle):
|
||||
@ -594,7 +605,9 @@ class Family(
|
||||
in the list.
|
||||
:rtype: bool
|
||||
"""
|
||||
new_list = [ref for ref in self.child_ref_list if ref.ref != child_handle]
|
||||
new_list = [
|
||||
ref for ref in self.child_ref_list if ref.ref != child_handle
|
||||
]
|
||||
self.child_ref_list = new_list
|
||||
|
||||
def get_child_ref_list(self):
|
||||
@ -632,7 +645,7 @@ class Family(
|
||||
equi = childref.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
if equi == EQUAL:
|
||||
childref.merge(addendum)
|
||||
break
|
||||
else:
|
||||
@ -655,7 +668,11 @@ class Family(
|
||||
self.event_ref_list.append(event_ref)
|
||||
|
||||
def get_event_list(self):
|
||||
warn("Use get_event_ref_list instead of get_event_list", DeprecationWarning, 2)
|
||||
warn(
|
||||
"Use get_event_ref_list instead of get_event_list",
|
||||
DeprecationWarning,
|
||||
2,
|
||||
)
|
||||
# Wrapper for old API
|
||||
# remove when transitition done.
|
||||
event_handle_list = []
|
||||
@ -699,7 +716,7 @@ class Family(
|
||||
equi = eventref.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
if equi == EQUAL:
|
||||
eventref.merge(addendum)
|
||||
break
|
||||
else:
|
||||
|
@ -27,14 +27,23 @@ Provide the different family reference types.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..config import config
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# FamilyRelType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class FamilyRelType(GrampsType):
|
||||
"""
|
||||
Class for type of relationship between two partners forming the family.
|
||||
"""
|
||||
|
||||
MARRIED = 0
|
||||
UNMARRIED = 1
|
||||
CIVIL_UNION = 2
|
||||
|
@ -119,7 +119,11 @@ def _tishri1(metonic_year, molad_day, molad_halakim):
|
||||
# Apply rules 2, 3 and 4.
|
||||
if (
|
||||
(molad_halakim >= _HBR_NOON)
|
||||
or ((not leap_year) and dow == _HBR_TUESDAY and molad_halakim >= _HBR_AM3_11_20)
|
||||
or (
|
||||
(not leap_year)
|
||||
and dow == _HBR_TUESDAY
|
||||
and molad_halakim >= _HBR_AM3_11_20
|
||||
)
|
||||
or (
|
||||
last_was_leap_year
|
||||
and dow == _HBR_MONDAY
|
||||
@ -133,7 +137,7 @@ def _tishri1(metonic_year, molad_day, molad_halakim):
|
||||
|
||||
# Apply rule 1 after the others because it can cause an additional
|
||||
# delay of one day
|
||||
if dow == _HBR_WEDNESDAY or dow == _HBR_FRIDAY or dow == _HBR_SUNDAY:
|
||||
if dow in [_HBR_WEDNESDAY, _HBR_FRIDAY, _HBR_SUNDAY]:
|
||||
tishri1 += 1
|
||||
|
||||
return tishri1
|
||||
@ -185,28 +189,32 @@ def _molad_of_metonic_cycle(metonic_cycle):
|
||||
Start with the time of the first molad after creation.
|
||||
"""
|
||||
|
||||
r1 = _HBR_NEW_MOON_OF_CREATION
|
||||
var_r1 = _HBR_NEW_MOON_OF_CREATION
|
||||
|
||||
# Calculate metonic_cycle * HALAKIM_PER_METONIC_CYCLE. The upper 32
|
||||
# bits of the result will be in r2 and the lower 16 bits will be
|
||||
# in r1.
|
||||
|
||||
r1 = r1 + (metonic_cycle * (_HBR_HALAKIM_PER_METONIC_CYCLE & 0xFFFF))
|
||||
r2 = r1 >> 16
|
||||
r2 = r2 + (metonic_cycle * ((_HBR_HALAKIM_PER_METONIC_CYCLE >> 16) & 0xFFFF))
|
||||
var_r1 = var_r1 + (
|
||||
metonic_cycle * (_HBR_HALAKIM_PER_METONIC_CYCLE & 0xFFFF)
|
||||
)
|
||||
var_r2 = var_r1 >> 16
|
||||
var_r2 = var_r2 + (
|
||||
metonic_cycle * ((_HBR_HALAKIM_PER_METONIC_CYCLE >> 16) & 0xFFFF)
|
||||
)
|
||||
|
||||
# Calculate r2r1 / HALAKIM_PER_DAY. The remainder will be in r1, the
|
||||
# upper 16 bits of the quotient will be in d2 and the lower 16 bits
|
||||
# will be in d1.
|
||||
|
||||
d2 = r2 // _HBR_HALAKIM_PER_DAY
|
||||
r2 -= d2 * _HBR_HALAKIM_PER_DAY
|
||||
r1 = (r2 << 16) | (r1 & 0xFFFF)
|
||||
d1 = r1 // _HBR_HALAKIM_PER_DAY
|
||||
r1 -= d1 * _HBR_HALAKIM_PER_DAY
|
||||
var_d2 = var_r2 // _HBR_HALAKIM_PER_DAY
|
||||
var_r2 -= var_d2 * _HBR_HALAKIM_PER_DAY
|
||||
var_r1 = (var_r2 << 16) | (var_r1 & 0xFFFF)
|
||||
var_d1 = var_r1 // _HBR_HALAKIM_PER_DAY
|
||||
var_r1 -= var_d1 * _HBR_HALAKIM_PER_DAY
|
||||
|
||||
molad_day = (d2 << 16) | d1
|
||||
molad_halakim = r1
|
||||
molad_day = (var_d2 << 16) | var_d1
|
||||
molad_halakim = var_r1
|
||||
|
||||
return (molad_day, molad_halakim)
|
||||
|
||||
@ -233,7 +241,7 @@ def _start_of_year(year):
|
||||
def hebrew_sdn(year, month, day):
|
||||
"""Convert a Jewish calendar date to an SDN number."""
|
||||
|
||||
if month == 1 or month == 2:
|
||||
if month in [1, 2]:
|
||||
# It is Tishri or Heshvan - don't need the year length.
|
||||
(
|
||||
metonic_cycle,
|
||||
@ -264,15 +272,17 @@ def hebrew_sdn(year, month, day):
|
||||
)
|
||||
molad_day = molad_day + (molad_halakim // _HBR_HALAKIM_PER_DAY)
|
||||
molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
|
||||
tishri1_after = _tishri1((metonic_year + 1) % 19, molad_day, molad_halakim)
|
||||
tishri1_after = _tishri1(
|
||||
(metonic_year + 1) % 19, molad_day, molad_halakim
|
||||
)
|
||||
|
||||
year_length = tishri1_after - tishri1
|
||||
|
||||
if year_length == 355 or year_length == 385:
|
||||
if year_length in [355, 385]:
|
||||
sdn = tishri1 + day + 59
|
||||
else:
|
||||
sdn = tishri1 + day + 58
|
||||
elif month == 4 or month == 5 or month == 6:
|
||||
elif month in [4, 5, 6]:
|
||||
# It is Tevet, Shevat or Adar I - don't need the year length
|
||||
|
||||
(
|
||||
@ -348,7 +358,9 @@ def hebrew_ymd(sdn):
|
||||
# We need the length of the year to figure this out, so find
|
||||
# Tishri 1 of the next year.
|
||||
|
||||
halakim += _HBR_HALAKIM_PER_LUNAR_CYCLE * _HBR_MONTHS_PER_YEAR[metonic_year]
|
||||
halakim += (
|
||||
_HBR_HALAKIM_PER_LUNAR_CYCLE * _HBR_MONTHS_PER_YEAR[metonic_year]
|
||||
)
|
||||
day1 += halakim // _HBR_HALAKIM_PER_DAY
|
||||
halakim = halakim % _HBR_HALAKIM_PER_DAY
|
||||
tishri1_after = _tishri1((metonic_year + 1) % 19, day1, halakim)
|
||||
@ -377,42 +389,42 @@ def hebrew_ymd(sdn):
|
||||
month = 8
|
||||
day = input_day - tishri1 + 178
|
||||
return (year, month, day)
|
||||
else:
|
||||
if _HBR_MONTHS_PER_YEAR[(year - 1) % 19] == 13:
|
||||
month = 7
|
||||
day = input_day - tishri1 + 207
|
||||
if day > 0:
|
||||
return (year, month, day)
|
||||
month -= 1
|
||||
day += 30
|
||||
if day > 0:
|
||||
return (year, month, day)
|
||||
month -= 1
|
||||
day += 30
|
||||
else:
|
||||
month = 6
|
||||
day = input_day - tishri1 + 207
|
||||
if day > 0:
|
||||
return (year, month, day)
|
||||
month -= 1
|
||||
day += 30
|
||||
|
||||
if _HBR_MONTHS_PER_YEAR[(year - 1) % 19] == 13:
|
||||
month = 7
|
||||
day = input_day - tishri1 + 207
|
||||
if day > 0:
|
||||
return (year, month, day)
|
||||
month -= 1
|
||||
day += 29
|
||||
day += 30
|
||||
if day > 0:
|
||||
return (year, month, day)
|
||||
month -= 1
|
||||
day += 30
|
||||
else:
|
||||
month = 6
|
||||
day = input_day - tishri1 + 207
|
||||
if day > 0:
|
||||
return (year, month, day)
|
||||
month -= 1
|
||||
day += 30
|
||||
|
||||
# We need the length of the year to figure this out, so find
|
||||
# Tishri 1 of this year
|
||||
tishri1_after = tishri1
|
||||
(metonic_cycle, metonic_year, day1, halakim) = _tishri_molad(day1 - 365)
|
||||
tishri1 = _tishri1(metonic_year, day1, halakim)
|
||||
if day > 0:
|
||||
return (year, month, day)
|
||||
month -= 1
|
||||
day += 29
|
||||
if day > 0:
|
||||
return (year, month, day)
|
||||
|
||||
# We need the length of the year to figure this out, so find
|
||||
# Tishri 1 of this year
|
||||
tishri1_after = tishri1
|
||||
(metonic_cycle, metonic_year, day1, halakim) = _tishri_molad(day1 - 365)
|
||||
tishri1 = _tishri1(metonic_year, day1, halakim)
|
||||
|
||||
year_length = tishri1_after - tishri1
|
||||
day = input_day - tishri1 - 29
|
||||
if year_length == 355 or year_length == 385:
|
||||
if year_length in [355, 385]:
|
||||
# Heshvan has 30 days
|
||||
if day <= 30:
|
||||
month = 2
|
||||
@ -536,7 +548,8 @@ def gregorian_ymd(sdn):
|
||||
|
||||
|
||||
def _check_republican_period(sdn, restrict_period):
|
||||
# French Republican calendar wasn't in use before 22.9.1792 or after 1.1.1806
|
||||
# French Republican calendar wasn't in use before 22.9.1792 or
|
||||
# after 1.1.1806
|
||||
if restrict_period and (sdn < 2375840 or sdn > 2380688):
|
||||
raise ValueError("Outside of the French Republican period")
|
||||
|
||||
@ -574,14 +587,14 @@ def persian_sdn(year, month, day):
|
||||
epyear = 474 + epbase % 2820
|
||||
|
||||
if month <= 7:
|
||||
v1 = (month - 1) * 31
|
||||
var1 = (month - 1) * 31
|
||||
else:
|
||||
v1 = ((month - 1) * 30) + 6
|
||||
v2 = ((epyear * 682) - 110) // 2816
|
||||
v3 = (epyear - 1) * 365 + day
|
||||
v4 = (epbase // 2820) * 1029983
|
||||
var1 = ((month - 1) * 30) + 6
|
||||
var2 = ((epyear * 682) - 110) // 2816
|
||||
var3 = (epyear - 1) * 365 + day
|
||||
var4 = (epbase // 2820) * 1029983
|
||||
|
||||
return int(math.ceil(v1 + v2 + v3 + v4 + _PRS_EPOCH - 1))
|
||||
return int(math.ceil(var1 + var2 + var3 + var4 + _PRS_EPOCH - 1))
|
||||
|
||||
|
||||
def persian_ymd(sdn):
|
||||
@ -614,18 +627,20 @@ def persian_ymd(sdn):
|
||||
|
||||
def islamic_sdn(year, month, day):
|
||||
"""Convert an Islamic date to an SDN number."""
|
||||
v1 = math.ceil(29.5 * (month - 1))
|
||||
v2 = (year - 1) * 354
|
||||
v3 = math.floor((3 + (11 * year)) // 30)
|
||||
var1 = math.ceil(29.5 * (month - 1))
|
||||
var2 = (year - 1) * 354
|
||||
var3 = math.floor((3 + (11 * year)) // 30)
|
||||
|
||||
return int(math.ceil((day + v1 + v2 + v3 + _ISM_EPOCH) - 1))
|
||||
return int(math.ceil((day + var1 + var2 + var3 + _ISM_EPOCH) - 1))
|
||||
|
||||
|
||||
def islamic_ymd(sdn):
|
||||
"""Convert an SDN number to an Islamic calendar date."""
|
||||
sdn = math.floor(sdn) + 0.5
|
||||
year = int(math.floor(((30 * (sdn - _ISM_EPOCH)) + 10646) / 10631))
|
||||
month = int(min(12, math.ceil((sdn - (29 + islamic_sdn(year, 1, 1))) / 29.5) + 1))
|
||||
month = int(
|
||||
min(12, math.ceil((sdn - (29 + islamic_sdn(year, 1, 1))) / 29.5) + 1)
|
||||
)
|
||||
day = int((sdn - islamic_sdn(year, month, 1)) + 1)
|
||||
return (year, month, day)
|
||||
|
||||
@ -637,10 +652,9 @@ def swedish_sdn(year, month, day):
|
||||
if (1700, 3, 1) <= datum <= (1712, 2, 30):
|
||||
return julian_sdn(year, month, day) - 1
|
||||
# Gregorian Calendar (1753-03-01)
|
||||
elif (1753, 3, 1) <= datum:
|
||||
if (1753, 3, 1) <= datum:
|
||||
return gregorian_sdn(year, month, day)
|
||||
else:
|
||||
return julian_sdn(year, month, day)
|
||||
return julian_sdn(year, month, day)
|
||||
|
||||
|
||||
def swedish_ymd(sdn):
|
||||
@ -648,10 +662,9 @@ def swedish_ymd(sdn):
|
||||
if sdn == 2346425:
|
||||
return (1712, 2, 30)
|
||||
# Swedish Calendar
|
||||
elif 2342042 <= sdn < 2346425:
|
||||
if 2342042 <= sdn < 2346425:
|
||||
return julian_ymd(sdn + 1)
|
||||
# Gregorian Calendar (1753-03-01)
|
||||
elif sdn >= 2361390:
|
||||
if sdn >= 2361390:
|
||||
return gregorian_ymd(sdn)
|
||||
else:
|
||||
return julian_ymd(sdn)
|
||||
return julian_ymd(sdn)
|
||||
|
@ -33,7 +33,7 @@ from .person import Person
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
# GenderStats class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class GenderStats:
|
||||
@ -52,13 +52,22 @@ class GenderStats:
|
||||
self.stats = stats
|
||||
|
||||
def save_stats(self):
|
||||
"""
|
||||
Return the stats for saving.
|
||||
"""
|
||||
return self.stats
|
||||
|
||||
def clear_stats(self):
|
||||
"""
|
||||
Clear the stats.
|
||||
"""
|
||||
self.stats = {}
|
||||
return self.stats
|
||||
|
||||
def name_stats(self, name):
|
||||
"""
|
||||
Return stats for a name.
|
||||
"""
|
||||
if name in self.stats:
|
||||
return self.stats[name]
|
||||
return (0, 0, 0)
|
||||
@ -74,6 +83,9 @@ class GenderStats:
|
||||
self._set_stats(keyname, gender)
|
||||
|
||||
def count_person(self, person, undo=0):
|
||||
"""
|
||||
Add a person to the stats.
|
||||
"""
|
||||
if not person:
|
||||
return
|
||||
# Let the Person do their own counting later
|
||||
@ -94,23 +106,26 @@ class GenderStats:
|
||||
|
||||
if gender == Person.MALE:
|
||||
male += increment
|
||||
if male < 0:
|
||||
male = 0
|
||||
male = max(male, 0)
|
||||
elif gender == Person.FEMALE:
|
||||
female += increment
|
||||
if female < 0:
|
||||
female = 0
|
||||
female = max(female, 0)
|
||||
elif gender in (Person.UNKNOWN, Person.OTHER):
|
||||
unknown += increment
|
||||
if unknown < 0:
|
||||
unknown = 0
|
||||
unknown = max(unknown, 0)
|
||||
|
||||
self.stats[keyname] = (male, female, unknown)
|
||||
|
||||
def uncount_person(self, person):
|
||||
"""
|
||||
Remove person from stats.
|
||||
"""
|
||||
return self.count_person(person, undo=1)
|
||||
|
||||
def guess_gender(self, name):
|
||||
"""
|
||||
Attempt to guess gender of person given a name.
|
||||
"""
|
||||
name = _get_key_from_name(name)
|
||||
if not name or name not in self.stats:
|
||||
return Person.UNKNOWN
|
||||
|
@ -55,15 +55,12 @@ class GrampsTypeMeta(type):
|
||||
columns.
|
||||
"""
|
||||
if blacklist:
|
||||
return dict(
|
||||
[
|
||||
(item[key_col], item[data_col])
|
||||
for item in data
|
||||
if item[0] not in blacklist
|
||||
]
|
||||
)
|
||||
else:
|
||||
return dict([(item[key_col], item[data_col]) for item in data])
|
||||
return {
|
||||
item[key_col]: item[data_col]
|
||||
for item in data
|
||||
if item[0] not in blacklist
|
||||
}
|
||||
return {item[key_col]: item[data_col] for item in data}
|
||||
|
||||
# Call superclass initialization
|
||||
type.__init__(cls, name, bases, namespace)
|
||||
@ -81,7 +78,7 @@ class GrampsTypeMeta(type):
|
||||
# GrampsType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class GrampsType(object, metaclass=GrampsTypeMeta):
|
||||
class GrampsType(metaclass=GrampsTypeMeta):
|
||||
"""Base class for all Gramps object types.
|
||||
|
||||
:cvar _DATAMAP:
|
||||
@ -207,10 +204,9 @@ class GrampsType(object, metaclass=GrampsTypeMeta):
|
||||
"""
|
||||
if self.__value == self._CUSTOM:
|
||||
return self.__string
|
||||
elif self.__value in self._I2EMAP:
|
||||
if self.__value in self._I2EMAP:
|
||||
return self._I2EMAP[self.__value]
|
||||
else:
|
||||
return _UNKNOWN
|
||||
return _UNKNOWN
|
||||
|
||||
def serialize(self):
|
||||
"""Convert the object to a serialized tuple of data."""
|
||||
@ -243,8 +239,7 @@ class GrampsType(object, metaclass=GrampsTypeMeta):
|
||||
def __str__(self):
|
||||
if self.__value == self._CUSTOM:
|
||||
return self.__string
|
||||
else:
|
||||
return self._I2SMAP.get(self.__value, _UNKNOWN)
|
||||
return self._I2SMAP.get(self.__value, _UNKNOWN)
|
||||
|
||||
def __int__(self):
|
||||
return self.__value
|
||||
@ -269,12 +264,15 @@ class GrampsType(object, metaclass=GrampsTypeMeta):
|
||||
]
|
||||
|
||||
def is_custom(self):
|
||||
"""Return true if custom type."""
|
||||
return self.__value == self._CUSTOM
|
||||
|
||||
def is_default(self):
|
||||
"""Return true if default type."""
|
||||
return self.__value == self._DEFAULT
|
||||
|
||||
def get_custom(self):
|
||||
"""Return custom type."""
|
||||
return self._CUSTOM
|
||||
|
||||
def get_menu(self):
|
||||
@ -290,23 +288,20 @@ class GrampsType(object, metaclass=GrampsTypeMeta):
|
||||
def __eq__(self, value):
|
||||
if isinstance(value, int):
|
||||
return self.__value == value
|
||||
elif isinstance(value, str):
|
||||
if isinstance(value, str):
|
||||
if self.__value == self._CUSTOM:
|
||||
return self.__string == value
|
||||
else:
|
||||
return self._I2SMAP.get(self.__value) == value
|
||||
elif isinstance(value, tuple):
|
||||
return self._I2SMAP.get(self.__value) == value
|
||||
if isinstance(value, tuple):
|
||||
if self.__value == self._CUSTOM:
|
||||
return (self.__value, self.__string) == value
|
||||
else:
|
||||
return self.__value == value[0]
|
||||
else:
|
||||
if value.value == self._CUSTOM and self.__value == self._CUSTOM:
|
||||
return self.__string == value.string
|
||||
elif value.value != self._CUSTOM and self.__value != self._CUSTOM:
|
||||
return self.__value == value.value
|
||||
else:
|
||||
return False
|
||||
return self.__value == value[0]
|
||||
|
||||
if value.value == self._CUSTOM and self.__value == self._CUSTOM:
|
||||
return self.__string == value.string
|
||||
if self._CUSTOM not in [value.value, self.__value]:
|
||||
return self.__value == value.value
|
||||
return False
|
||||
|
||||
def __ne__(self, value):
|
||||
return not self.__eq__(value)
|
||||
|
@ -38,14 +38,14 @@ from warnings import warn
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .citationbase import CitationBase
|
||||
from .notebase import NoteBase
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .datebase import DateBase
|
||||
from .notebase import NoteBase
|
||||
from .placebase import PlaceBase
|
||||
from .privacybase import PrivacyBase
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .secondaryobj import SecondaryObject
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -55,7 +55,9 @@ _ = glocale.translation.gettext
|
||||
# LDS Ordinance class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class LdsOrd(SecondaryObject, CitationBase, NoteBase, DateBase, PlaceBase, PrivacyBase):
|
||||
class LdsOrd(
|
||||
SecondaryObject, CitationBase, NoteBase, DateBase, PlaceBase, PrivacyBase
|
||||
):
|
||||
"""
|
||||
Class that contains information about LDS Ordinances.
|
||||
|
||||
@ -178,6 +180,7 @@ class LdsOrd(SecondaryObject, CitationBase, NoteBase, DateBase, PlaceBase, Priva
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .date import Date
|
||||
|
||||
return {
|
||||
@ -246,7 +249,8 @@ class LdsOrd(SecondaryObject, CitationBase, NoteBase, DateBase, PlaceBase, Priva
|
||||
:rtype: list
|
||||
"""
|
||||
ret = (
|
||||
self.get_referenced_note_handles() + self.get_referenced_citation_handles()
|
||||
self.get_referenced_note_handles()
|
||||
+ self.get_referenced_citation_handles()
|
||||
)
|
||||
if self.place:
|
||||
ret += [("Place", self.place)]
|
||||
@ -282,11 +286,9 @@ class LdsOrd(SecondaryObject, CitationBase, NoteBase, DateBase, PlaceBase, Priva
|
||||
or self.famc != other.famc
|
||||
):
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
return EQUAL
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
@ -357,8 +359,7 @@ class LdsOrd(SecondaryObject, CitationBase, NoteBase, DateBase, PlaceBase, Priva
|
||||
or self.place
|
||||
):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
return True
|
||||
|
||||
def are_equal(self, other):
|
||||
"""Return 1 if the specified ordinance is the same as the instance."""
|
||||
|
@ -28,8 +28,8 @@ LdsOrdBase class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .const import EQUAL, IDENTICAL
|
||||
from .ldsord import LdsOrd
|
||||
from .const import IDENTICAL, EQUAL
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
@ -54,7 +54,9 @@ class LdsOrdBase:
|
||||
"""
|
||||
|
||||
if source:
|
||||
self.lds_ord_list = [LdsOrd(lds_ord) for lds_ord in source.lds_ord_list]
|
||||
self.lds_ord_list = [
|
||||
LdsOrd(lds_ord) for lds_ord in source.lds_ord_list
|
||||
]
|
||||
else:
|
||||
self.lds_ord_list = []
|
||||
|
||||
@ -99,8 +101,7 @@ class LdsOrdBase:
|
||||
if lds_ord in self.lds_ord_list:
|
||||
self.lds_ord_list.remove(lds_ord)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
def get_lds_ord_list(self):
|
||||
"""
|
||||
@ -137,7 +138,7 @@ class LdsOrdBase:
|
||||
equi = ldsord.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
if equi == EQUAL:
|
||||
ldsord.merge(addendum)
|
||||
break
|
||||
else:
|
||||
|
@ -30,10 +30,10 @@ Location class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .locationbase import LocationBase
|
||||
from .const import IDENTICAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .const import DIFFERENT, IDENTICAL
|
||||
from .locationbase import LocationBase
|
||||
from .secondaryobj import SecondaryObject
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -121,8 +121,7 @@ class Location(SecondaryObject, LocationBase):
|
||||
"""
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return DIFFERENT
|
||||
return DIFFERENT
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
@ -133,9 +132,9 @@ class Location(SecondaryObject, LocationBase):
|
||||
:param acquisition: The location to merge with the present location.
|
||||
:type acquisition: Location
|
||||
"""
|
||||
pass
|
||||
|
||||
def is_empty(self):
|
||||
"""Return true if empty."""
|
||||
return (
|
||||
not self.street
|
||||
and not self.locality
|
||||
|
@ -27,25 +27,25 @@ Media object for Gramps.
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# standard python modules
|
||||
# Python modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
import logging
|
||||
import os
|
||||
from urllib.parse import urlparse
|
||||
import logging
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .primaryobj import PrimaryObject
|
||||
from .citationbase import CitationBase
|
||||
from .notebase import NoteBase
|
||||
from .datebase import DateBase
|
||||
from .attrbase import AttributeBase
|
||||
from .tagbase import TagBase
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .attrbase import AttributeBase
|
||||
from .citationbase import CitationBase
|
||||
from .datebase import DateBase
|
||||
from .notebase import NoteBase
|
||||
from .primaryobj import PrimaryObject
|
||||
from .tagbase import TagBase
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -134,6 +134,7 @@ class Media(CitationBase, NoteBase, DateBase, AttributeBase, PrimaryObject):
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .attribute import Attribute
|
||||
from .date import Date
|
||||
|
||||
@ -142,7 +143,11 @@ class Media(CitationBase, NoteBase, DateBase, AttributeBase, PrimaryObject):
|
||||
"title": _("Media"),
|
||||
"properties": {
|
||||
"_class": {"enum": [cls.__name__]},
|
||||
"handle": {"type": "string", "maxLength": 50, "title": _("Handle")},
|
||||
"handle": {
|
||||
"type": "string",
|
||||
"maxLength": 50,
|
||||
"title": _("Handle"),
|
||||
},
|
||||
"gramps_id": {"type": "string", "title": _("Gramps ID")},
|
||||
"path": {"type": "string", "title": _("Path")},
|
||||
"mime": {"type": "string", "title": _("MIME")},
|
||||
@ -306,7 +311,7 @@ class Media(CitationBase, NoteBase, DateBase, AttributeBase, PrimaryObject):
|
||||
def set_path(self, path):
|
||||
"""Set the file path to the passed path."""
|
||||
res = urlparse(path)
|
||||
if res.scheme == "" or res.scheme == "file":
|
||||
if res.scheme in ["", "file"]:
|
||||
self.path = os.path.normpath(path)
|
||||
else:
|
||||
# The principal case this path caters for is where the scheme is
|
||||
|
@ -28,8 +28,8 @@ MediaBase class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .mediaref import MediaRef
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
@ -49,7 +49,9 @@ class MediaBase:
|
||||
:param source: Object used to initialize the new object
|
||||
:type source: MediaBase
|
||||
"""
|
||||
self.media_list = list(map(MediaRef, source.media_list)) if source else []
|
||||
self.media_list = (
|
||||
list(map(MediaRef, source.media_list)) if source else []
|
||||
)
|
||||
|
||||
def serialize(self):
|
||||
"""
|
||||
@ -110,7 +112,7 @@ class MediaBase:
|
||||
equi = obj.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
if equi == EQUAL:
|
||||
obj.merge(addendum)
|
||||
break
|
||||
else:
|
||||
@ -158,7 +160,7 @@ class MediaBase:
|
||||
if new_handle in refs_list:
|
||||
new_ref = self.media_list[refs_list.index(new_handle)]
|
||||
n_replace = refs_list.count(old_handle)
|
||||
for ix_replace in range(n_replace):
|
||||
for dummy_ix_replace in range(n_replace):
|
||||
idx = refs_list.index(old_handle)
|
||||
self.media_list[idx].ref = new_handle
|
||||
refs_list[idx] = new_handle
|
||||
|
@ -31,14 +31,14 @@ Media Reference class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .privacybase import PrivacyBase
|
||||
from .citationbase import CitationBase
|
||||
from .notebase import NoteBase
|
||||
from .refbase import RefBase
|
||||
from .attrbase import AttributeBase
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .attrbase import AttributeBase
|
||||
from .citationbase import CitationBase
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .notebase import NoteBase
|
||||
from .privacybase import PrivacyBase
|
||||
from .refbase import RefBase
|
||||
from .secondaryobj import SecondaryObject
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -51,7 +51,9 @@ _ = glocale.translation.gettext
|
||||
class MediaRef(
|
||||
SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase, AttributeBase
|
||||
):
|
||||
"""Media reference class."""
|
||||
"""
|
||||
Media reference class.
|
||||
"""
|
||||
|
||||
def __init__(self, source=None):
|
||||
PrivacyBase.__init__(self, source)
|
||||
@ -86,6 +88,7 @@ class MediaRef(
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .attribute import Attribute
|
||||
|
||||
return {
|
||||
@ -109,7 +112,11 @@ class MediaRef(
|
||||
"title": _("Attributes"),
|
||||
"items": Attribute.get_schema(),
|
||||
},
|
||||
"ref": {"type": "string", "title": _("Handle"), "maxLength": 50},
|
||||
"ref": {
|
||||
"type": "string",
|
||||
"title": _("Handle"),
|
||||
"maxLength": 50,
|
||||
},
|
||||
"rect": {
|
||||
"oneOf": [
|
||||
{"type": "null"},
|
||||
@ -129,7 +136,14 @@ class MediaRef(
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
(privacy, citation_list, note_list, attribute_list, ref, self.rect) = data
|
||||
(
|
||||
privacy,
|
||||
citation_list,
|
||||
note_list,
|
||||
attribute_list,
|
||||
ref,
|
||||
self.rect,
|
||||
) = data
|
||||
PrivacyBase.unserialize(self, privacy)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
@ -175,7 +189,8 @@ class MediaRef(
|
||||
:rtype: list
|
||||
"""
|
||||
ret = (
|
||||
self.get_referenced_note_handles() + self.get_referenced_citation_handles()
|
||||
self.get_referenced_note_handles()
|
||||
+ self.get_referenced_citation_handles()
|
||||
)
|
||||
if self.ref:
|
||||
ret += [("Media", self.ref)]
|
||||
@ -203,11 +218,9 @@ class MediaRef(
|
||||
"""
|
||||
if self.ref != other.ref or self.rect != other.rect:
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
return EQUAL
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
|
@ -31,26 +31,28 @@ Name class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .privacybase import PrivacyBase
|
||||
from .citationbase import CitationBase
|
||||
from .notebase import NoteBase
|
||||
from .datebase import DateBase
|
||||
from .surnamebase import SurnameBase
|
||||
from .nametype import NameType
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from .date import Date
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .citationbase import CitationBase
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .date import Date
|
||||
from .datebase import DateBase
|
||||
from .nametype import NameType
|
||||
from .notebase import NoteBase
|
||||
from .privacybase import PrivacyBase
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .surnamebase import SurnameBase
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Personal Name
|
||||
# Name class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, DateBase):
|
||||
class Name(
|
||||
SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, DateBase
|
||||
):
|
||||
"""
|
||||
Provide name information about a person.
|
||||
|
||||
@ -158,6 +160,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, Da
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .surname import Surname
|
||||
|
||||
return {
|
||||
@ -298,7 +301,8 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, Da
|
||||
:rtype: list
|
||||
"""
|
||||
return (
|
||||
self.get_referenced_note_handles() + self.get_referenced_citation_handles()
|
||||
self.get_referenced_note_handles()
|
||||
+ self.get_referenced_citation_handles()
|
||||
)
|
||||
|
||||
def is_equivalent(self, other):
|
||||
@ -318,11 +322,9 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, Da
|
||||
or SurnameBase.serialize(self) != SurnameBase.serialize(other)
|
||||
):
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
return EQUAL
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
@ -368,8 +370,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, Da
|
||||
"""
|
||||
if self.group_as:
|
||||
return self.group_as
|
||||
else:
|
||||
return self.get_primary_surname().get_surname()
|
||||
return self.get_primary_surname().get_surname()
|
||||
|
||||
def set_sort_as(self, value):
|
||||
"""
|
||||
@ -507,9 +508,8 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, Da
|
||||
"first": first,
|
||||
"suffix": self.suffix,
|
||||
}
|
||||
else:
|
||||
# Translators: needed for Arabic, ignore otherwise
|
||||
return _("%(str1)s, %(str2)s") % {"str1": surname, "str2": first}
|
||||
# Translators: needed for Arabic, ignore otherwise
|
||||
return _("%(str1)s, %(str2)s") % {"str1": surname, "str2": first}
|
||||
|
||||
def get_upper_name(self):
|
||||
"""
|
||||
@ -525,9 +525,8 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, Da
|
||||
"first": first,
|
||||
"suffix": self.suffix,
|
||||
}
|
||||
else:
|
||||
# Translators: needed for Arabic, ignore otherwise
|
||||
return _("%(str1)s, %(str2)s") % {"str1": surname, "str2": first}
|
||||
# Translators: needed for Arabic, ignore otherwise
|
||||
return _("%(str1)s, %(str2)s") % {"str1": surname, "str2": first}
|
||||
|
||||
def get_regular_name(self):
|
||||
"""
|
||||
@ -537,14 +536,13 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, Da
|
||||
first = self.first_name
|
||||
surname = self.get_surname()
|
||||
if self.suffix == "":
|
||||
return "%s %s" % (first, surname)
|
||||
else:
|
||||
# Translators: needed for Arabic, ignore otherwise
|
||||
return _("%(first)s %(surname)s, %(suffix)s") % {
|
||||
"surname": surname,
|
||||
"first": first,
|
||||
"suffix": self.suffix,
|
||||
}
|
||||
return f"{first} {surname}"
|
||||
# Translators: needed for Arabic, ignore otherwise
|
||||
return _("%(first)s %(surname)s, %(suffix)s") % {
|
||||
"surname": surname,
|
||||
"first": first,
|
||||
"suffix": self.suffix,
|
||||
}
|
||||
|
||||
def get_gedcom_parts(self):
|
||||
"""
|
||||
@ -573,6 +571,5 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, Da
|
||||
surname = self.get_surname().replace("/", "?")
|
||||
suffix = self.suffix
|
||||
if suffix == "":
|
||||
return "%s /%s/" % (firstname, surname)
|
||||
else:
|
||||
return "%s /%s/ %s" % (firstname, surname, suffix)
|
||||
return f"{firstname} /{surname}/"
|
||||
return f"{firstname} /{surname}/ {suffix}"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#
|
||||
|
||||
"""
|
||||
Name types.
|
||||
Name origin types.
|
||||
"""
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
@ -27,12 +27,17 @@ Name types.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.sgettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# NameOriginType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class NameOriginType(GrampsType):
|
||||
"""
|
||||
Name Origin Types
|
||||
|
@ -27,13 +27,22 @@ Name types.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# NameType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class NameType(GrampsType):
|
||||
"""
|
||||
Class encapsulating the type of name.
|
||||
"""
|
||||
|
||||
UNKNOWN = -1
|
||||
CUSTOM = 0
|
||||
AKA = 1
|
||||
|
@ -29,12 +29,12 @@ Note class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .primaryobj import BasicPrimaryObject
|
||||
from .tagbase import TagBase
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .notetype import NoteType
|
||||
from .primaryobj import BasicPrimaryObject
|
||||
from .styledtext import StyledText
|
||||
from .styledtexttagtype import StyledTextTagType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .tagbase import TagBase
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -121,7 +121,11 @@ class Note(BasicPrimaryObject):
|
||||
"title": _("Note"),
|
||||
"properties": {
|
||||
"_class": {"enum": [cls.__name__]},
|
||||
"handle": {"type": "string", "maxLength": 50, "title": _("Handle")},
|
||||
"handle": {
|
||||
"type": "string",
|
||||
"maxLength": 50,
|
||||
"title": _("Handle"),
|
||||
},
|
||||
"gramps_id": {"type": "string", "title": _("Gramps ID")},
|
||||
"text": StyledText.get_schema(),
|
||||
"format": {"type": "integer", "title": _("Format")},
|
||||
@ -180,8 +184,7 @@ class Note(BasicPrimaryObject):
|
||||
for dom, obj, prop, hndl in self.get_links():
|
||||
if dom != "gramps" or prop != "handle":
|
||||
continue
|
||||
else:
|
||||
reflist.append((obj, hndl))
|
||||
reflist.append((obj, hndl))
|
||||
reflist.extend(self.get_referenced_tag_handles())
|
||||
return reflist
|
||||
|
||||
@ -230,7 +233,11 @@ class Note(BasicPrimaryObject):
|
||||
and styledtext_tag.value.startswith("gramps://")
|
||||
):
|
||||
obj, prop, value = styledtext_tag.value[9:].split("/", 2)
|
||||
if obj == classname and prop == "handle" and value in handle_list:
|
||||
if (
|
||||
obj == classname
|
||||
and prop == "handle"
|
||||
and value in handle_list
|
||||
):
|
||||
continue
|
||||
tags.append(styledtext_tag)
|
||||
self.text.set_tags(tags)
|
||||
@ -252,7 +259,11 @@ class Note(BasicPrimaryObject):
|
||||
and styledtext_tag.value.startswith("gramps://")
|
||||
):
|
||||
obj, prop, value = styledtext_tag.value[9:].split("/", 2)
|
||||
if obj == classname and prop == "handle" and value == old_handle:
|
||||
if (
|
||||
obj == classname
|
||||
and prop == "handle"
|
||||
and value == old_handle
|
||||
):
|
||||
styledtext_tag.value = styledtext_tag.value.replace(
|
||||
old_handle, new_handle
|
||||
)
|
||||
@ -309,13 +320,13 @@ class Note(BasicPrimaryObject):
|
||||
"""
|
||||
self.text = self.text + text
|
||||
|
||||
def set_format(self, format):
|
||||
def set_format(self, note_format):
|
||||
"""Set the format of the note to the passed value.
|
||||
|
||||
:param format: The value can either indicate Flowed or Preformatted.
|
||||
:type format: int
|
||||
"""
|
||||
self.format = format
|
||||
self.format = note_format
|
||||
|
||||
def get_format(self):
|
||||
"""Return the format of the note.
|
||||
@ -360,8 +371,12 @@ class Note(BasicPrimaryObject):
|
||||
for styledtext_tag in self.text.get_tags():
|
||||
if int(styledtext_tag.name) == StyledTextTagType.LINK:
|
||||
if styledtext_tag.value.startswith("gramps://"):
|
||||
object_class, prop, value = styledtext_tag.value[9:].split("/", 2)
|
||||
object_class, prop, value = styledtext_tag.value[9:].split(
|
||||
"/", 2
|
||||
)
|
||||
retval.append(("gramps", object_class, prop, value))
|
||||
else:
|
||||
retval.append(("external", "www", "url", styledtext_tag.value))
|
||||
retval.append(
|
||||
("external", "www", "url", styledtext_tag.value)
|
||||
)
|
||||
return retval
|
||||
|
@ -22,6 +22,7 @@
|
||||
"""
|
||||
NoteBase class for Gramps.
|
||||
"""
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
@ -79,9 +80,8 @@ class NoteBase:
|
||||
"""
|
||||
if handle in self.note_list:
|
||||
return False
|
||||
else:
|
||||
self.note_list.append(handle)
|
||||
return True
|
||||
self.note_list.append(handle)
|
||||
return True
|
||||
|
||||
def remove_note(self, handle):
|
||||
"""
|
||||
@ -158,7 +158,9 @@ class NoteBase:
|
||||
)
|
||||
for handle in handle_list:
|
||||
if handle in self.note_list:
|
||||
LOG.debug("remove handle %s from note_list %s", handle, self.note_list)
|
||||
LOG.debug(
|
||||
"remove handle %s from note_list %s", handle, self.note_list
|
||||
)
|
||||
self.note_list.remove(handle)
|
||||
LOG.debug("get_note_child_list %s", self.get_note_child_list())
|
||||
for item in self.get_note_child_list():
|
||||
@ -213,7 +215,7 @@ class NoteBase:
|
||||
if new_handle in self.note_list:
|
||||
new_ref = new_handle
|
||||
n_replace = refs_list.count(old_handle)
|
||||
for ix_replace in range(n_replace):
|
||||
for dummy_ix_replace in range(n_replace):
|
||||
idx = refs_list.index(old_handle)
|
||||
if new_ref:
|
||||
self.note_list.pop(idx)
|
||||
|
@ -27,13 +27,17 @@ Note types.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.sgettext
|
||||
|
||||
|
||||
class NoteType(GrampsType):
|
||||
"""
|
||||
Class encapsulating the type of note.
|
||||
"""
|
||||
|
||||
UNKNOWN = -1
|
||||
CUSTOM = 0
|
||||
GENERAL = 1
|
||||
|
@ -30,23 +30,23 @@ Person object for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .primaryobj import PrimaryObject
|
||||
from .citationbase import CitationBase
|
||||
from .notebase import NoteBase
|
||||
from .mediabase import MediaBase
|
||||
from .attrbase import AttributeBase
|
||||
from .addressbase import AddressBase
|
||||
from .ldsordbase import LdsOrdBase
|
||||
from .urlbase import UrlBase
|
||||
from .tagbase import TagBase
|
||||
from .name import Name
|
||||
from .eventref import EventRef
|
||||
from .personref import PersonRef
|
||||
from .attrtype import AttributeType
|
||||
from .eventroletype import EventRoleType
|
||||
from .attribute import Attribute
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .addressbase import AddressBase
|
||||
from .attrbase import AttributeBase
|
||||
from .attribute import Attribute
|
||||
from .attrtype import AttributeType
|
||||
from .citationbase import CitationBase
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .eventref import EventRef
|
||||
from .eventroletype import EventRoleType
|
||||
from .ldsordbase import LdsOrdBase
|
||||
from .mediabase import MediaBase
|
||||
from .name import Name
|
||||
from .notebase import NoteBase
|
||||
from .personref import PersonRef
|
||||
from .primaryobj import PrimaryObject
|
||||
from .tagbase import TagBase
|
||||
from .urlbase import UrlBase
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -175,17 +175,22 @@ class Person(
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
from .mediaref import MediaRef
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .address import Address
|
||||
from .url import Url
|
||||
from .ldsord import LdsOrd
|
||||
from .mediaref import MediaRef
|
||||
from .url import Url
|
||||
|
||||
return {
|
||||
"type": "object",
|
||||
"title": _("Person"),
|
||||
"properties": {
|
||||
"_class": {"enum": [cls.__name__]},
|
||||
"handle": {"type": "string", "maxLength": 50, "title": _("Handle")},
|
||||
"handle": {
|
||||
"type": "string",
|
||||
"maxLength": 50,
|
||||
"title": _("Handle"),
|
||||
},
|
||||
"gramps_id": {"type": "string", "title": _("Gramps ID")},
|
||||
"gender": {
|
||||
"type": "integer",
|
||||
@ -307,9 +312,15 @@ class Person(
|
||||
|
||||
self.primary_name = Name()
|
||||
self.primary_name.unserialize(primary_name)
|
||||
self.alternate_names = [Name().unserialize(name) for name in alternate_names]
|
||||
self.event_ref_list = [EventRef().unserialize(er) for er in event_ref_list]
|
||||
self.person_ref_list = [PersonRef().unserialize(pr) for pr in person_ref_list]
|
||||
self.alternate_names = [
|
||||
Name().unserialize(name) for name in alternate_names
|
||||
]
|
||||
self.event_ref_list = [
|
||||
EventRef().unserialize(er) for er in event_ref_list
|
||||
]
|
||||
self.person_ref_list = [
|
||||
PersonRef().unserialize(pr) for pr in person_ref_list
|
||||
]
|
||||
MediaBase.unserialize(self, media_list)
|
||||
LdsOrdBase.unserialize(self, lds_ord_list)
|
||||
AddressBase.unserialize(self, address_list)
|
||||
@ -335,17 +346,19 @@ class Person(
|
||||
"""
|
||||
if classname == "Event":
|
||||
return any(ref.ref == handle for ref in self.event_ref_list)
|
||||
elif classname == "Person":
|
||||
if classname == "Person":
|
||||
return any(ref.ref == handle for ref in self.person_ref_list)
|
||||
elif classname == "Family":
|
||||
if classname == "Family":
|
||||
return any(
|
||||
ref == handle
|
||||
for ref in self.family_list
|
||||
+ self.parent_family_list
|
||||
+ [ordinance.famc for ordinance in self.lds_ord_list]
|
||||
)
|
||||
elif classname == "Place":
|
||||
return any(ordinance.place == handle for ordinance in self.lds_ord_list)
|
||||
if classname == "Place":
|
||||
return any(
|
||||
ordinance.place == handle for ordinance in self.lds_ord_list
|
||||
)
|
||||
return False
|
||||
|
||||
def _remove_handle_references(self, classname, handle_list):
|
||||
@ -378,12 +391,16 @@ class Person(
|
||||
self.set_death_ref(death_ref)
|
||||
elif classname == "Person":
|
||||
new_list = [
|
||||
ref for ref in self.person_ref_list if ref.ref not in handle_list
|
||||
ref
|
||||
for ref in self.person_ref_list
|
||||
if ref.ref not in handle_list
|
||||
]
|
||||
self.person_ref_list = new_list
|
||||
elif classname == "Family":
|
||||
new_list = [
|
||||
handle for handle in self.family_list if handle not in handle_list
|
||||
handle
|
||||
for handle in self.family_list
|
||||
if handle not in handle_list
|
||||
]
|
||||
self.family_list = new_list
|
||||
new_list = [
|
||||
@ -407,7 +424,7 @@ class Person(
|
||||
if new_handle in refs_list:
|
||||
new_ref = self.event_ref_list[refs_list.index(new_handle)]
|
||||
n_replace = refs_list.count(old_handle)
|
||||
for ix_replace in range(n_replace):
|
||||
for dummy_ix_replace in range(n_replace):
|
||||
idx = refs_list.index(old_handle)
|
||||
self.event_ref_list[idx].ref = new_handle
|
||||
refs_list[idx] = new_handle
|
||||
@ -437,7 +454,7 @@ class Person(
|
||||
if new_handle in refs_list:
|
||||
new_ref = self.person_ref_list[refs_list.index(new_handle)]
|
||||
n_replace = refs_list.count(old_handle)
|
||||
for ix_replace in range(n_replace):
|
||||
for dummy_ix_replace in range(n_replace):
|
||||
idx = refs_list.index(old_handle)
|
||||
self.person_ref_list[idx].ref = new_handle
|
||||
refs_list[idx] = new_handle
|
||||
@ -451,22 +468,22 @@ class Person(
|
||||
refs_list.pop(idx)
|
||||
elif classname == "Family":
|
||||
while old_handle in self.family_list:
|
||||
ix = self.family_list.index(old_handle)
|
||||
self.family_list[ix] = new_handle
|
||||
idx = self.family_list.index(old_handle)
|
||||
self.family_list[idx] = new_handle
|
||||
while old_handle in self.parent_family_list:
|
||||
ix = self.parent_family_list.index(old_handle)
|
||||
self.parent_family_list[ix] = new_handle
|
||||
idx = self.parent_family_list.index(old_handle)
|
||||
self.parent_family_list[idx] = new_handle
|
||||
handle_list = [ordinance.famc for ordinance in self.lds_ord_list]
|
||||
while old_handle in handle_list:
|
||||
ix = handle_list.index(old_handle)
|
||||
self.lds_ord_list[ix].famc = new_handle
|
||||
handle_list[ix] = ""
|
||||
idx = handle_list.index(old_handle)
|
||||
self.lds_ord_list[idx].famc = new_handle
|
||||
handle_list[idx] = ""
|
||||
elif classname == "Place":
|
||||
handle_list = [ordinance.place for ordinance in self.lds_ord_list]
|
||||
while old_handle in handle_list:
|
||||
ix = handle_list.index(old_handle)
|
||||
self.lds_ord_list[ix].place = new_handle
|
||||
handle_list[ix] = ""
|
||||
idx = handle_list.index(old_handle)
|
||||
self.lds_ord_list[idx].place = new_handle
|
||||
handle_list[idx] = ""
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
@ -663,7 +680,7 @@ class Person(
|
||||
equi = name.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
if equi == EQUAL:
|
||||
name.merge(addendum)
|
||||
break
|
||||
else:
|
||||
@ -679,6 +696,12 @@ class Person(
|
||||
self.alternate_names.append(name)
|
||||
|
||||
def get_nick_name(self):
|
||||
"""
|
||||
Return nick name of a person.
|
||||
|
||||
:returns: Nickname of person if one found.
|
||||
:rtype: str
|
||||
"""
|
||||
for name in [self.get_primary_name()] + self.get_alternate_names():
|
||||
if name.get_nick_name():
|
||||
return name.get_nick_name()
|
||||
@ -700,7 +723,12 @@ class Person(
|
||||
- Person.UNKNOWN
|
||||
:type gender: int
|
||||
"""
|
||||
if gender not in (Person.MALE, Person.FEMALE, Person.OTHER, Person.UNKNOWN):
|
||||
if gender not in (
|
||||
Person.MALE,
|
||||
Person.FEMALE,
|
||||
Person.OTHER,
|
||||
Person.UNKNOWN,
|
||||
):
|
||||
raise ValueError("Attempt to assign invalid gender")
|
||||
self.__gender = gender
|
||||
|
||||
@ -786,8 +814,7 @@ class Person(
|
||||
|
||||
if 0 <= self.birth_ref_index < len(self.event_ref_list):
|
||||
return self.event_ref_list[self.birth_ref_index]
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
def get_death_ref(self):
|
||||
"""
|
||||
@ -803,8 +830,7 @@ class Person(
|
||||
|
||||
if 0 <= self.death_ref_index < len(self.event_ref_list):
|
||||
return self.event_ref_list[self.death_ref_index]
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
def add_event_ref(self, event_ref):
|
||||
"""
|
||||
@ -877,14 +903,20 @@ class Person(
|
||||
equi = eventref.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
if equi == EQUAL:
|
||||
eventref.merge(addendum)
|
||||
break
|
||||
else:
|
||||
self.event_ref_list.append(addendum)
|
||||
if self.birth_ref_index == -1 and idx == acquisition.birth_ref_index:
|
||||
if (
|
||||
self.birth_ref_index == -1
|
||||
and idx == acquisition.birth_ref_index
|
||||
):
|
||||
self.birth_ref_index = len(self.event_ref_list) - 1
|
||||
if self.death_ref_index == -1 and idx == acquisition.death_ref_index:
|
||||
if (
|
||||
self.death_ref_index == -1
|
||||
and idx == acquisition.death_ref_index
|
||||
):
|
||||
self.death_ref_index = len(self.event_ref_list) - 1
|
||||
|
||||
def add_family_handle(self, family_handle):
|
||||
@ -932,8 +964,7 @@ class Person(
|
||||
self.family_list.remove(family_handle)
|
||||
self.family_list = [family_handle] + self.family_list
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
def get_family_handle_list(self):
|
||||
"""
|
||||
@ -983,8 +1014,7 @@ class Person(
|
||||
if family_handle in self.family_list:
|
||||
self.family_list.remove(family_handle)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
def get_parent_family_handle_list(self):
|
||||
"""
|
||||
@ -1029,7 +1059,7 @@ class Person(
|
||||
:type family_handle: str
|
||||
"""
|
||||
if not isinstance(family_handle, str):
|
||||
raise ValueError("Expecting handle, obtained %s" % str(family_handle))
|
||||
raise ValueError(f"Expecting handle, obtained {family_handle}")
|
||||
if family_handle not in self.parent_family_list:
|
||||
self.parent_family_list.append(family_handle)
|
||||
|
||||
@ -1060,8 +1090,7 @@ class Person(
|
||||
if family_handle in self.parent_family_list:
|
||||
self.parent_family_list.remove(family_handle)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
def set_main_parent_family_handle(self, family_handle):
|
||||
"""
|
||||
@ -1082,8 +1111,7 @@ class Person(
|
||||
self.parent_family_list.remove(family_handle)
|
||||
self.parent_family_list = [family_handle] + self.parent_family_list
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
def get_main_parents_family_handle(self):
|
||||
"""
|
||||
@ -1096,8 +1124,7 @@ class Person(
|
||||
"""
|
||||
if self.parent_family_list:
|
||||
return self.parent_family_list[0]
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
def add_person_ref(self, person_ref):
|
||||
"""
|
||||
@ -1146,7 +1173,7 @@ class Person(
|
||||
equi = personref.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
if equi == EQUAL:
|
||||
personref.merge(addendum)
|
||||
break
|
||||
else:
|
||||
|
@ -31,13 +31,13 @@ Person Reference class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .privacybase import PrivacyBase
|
||||
from .citationbase import CitationBase
|
||||
from .notebase import NoteBase
|
||||
from .refbase import RefBase
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .citationbase import CitationBase
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .notebase import NoteBase
|
||||
from .privacybase import PrivacyBase
|
||||
from .refbase import RefBase
|
||||
from .secondaryobj import SecondaryObject
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -113,7 +113,11 @@ class PersonRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
||||
"title": _("Notes"),
|
||||
"items": {"type": "string", "maxLength": 50},
|
||||
},
|
||||
"ref": {"type": "string", "title": _("Handle"), "maxLength": 50},
|
||||
"ref": {
|
||||
"type": "string",
|
||||
"title": _("Handle"),
|
||||
"maxLength": 50,
|
||||
},
|
||||
"rel": {"type": "string", "title": _("Association")},
|
||||
},
|
||||
}
|
||||
@ -155,7 +159,8 @@ class PersonRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
||||
:rtype: list
|
||||
"""
|
||||
ret = (
|
||||
self.get_referenced_note_handles() + self.get_referenced_citation_handles()
|
||||
self.get_referenced_note_handles()
|
||||
+ self.get_referenced_citation_handles()
|
||||
)
|
||||
if self.ref:
|
||||
ret += [("Person", self.ref)]
|
||||
@ -186,11 +191,9 @@ class PersonRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
||||
or self.get_text_data_list() != other.get_text_data_list()
|
||||
):
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
return EQUAL
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
|
@ -31,17 +31,17 @@ Place object for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .primaryobj import PrimaryObject
|
||||
from .placeref import PlaceRef
|
||||
from .placename import PlaceName
|
||||
from .placetype import PlaceType
|
||||
from .citationbase import CitationBase
|
||||
from .notebase import NoteBase
|
||||
from .mediabase import MediaBase
|
||||
from .urlbase import UrlBase
|
||||
from .tagbase import TagBase
|
||||
from .location import Location
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .citationbase import CitationBase
|
||||
from .location import Location
|
||||
from .mediabase import MediaBase
|
||||
from .notebase import NoteBase
|
||||
from .placename import PlaceName
|
||||
from .placeref import PlaceRef
|
||||
from .placetype import PlaceType
|
||||
from .primaryobj import PrimaryObject
|
||||
from .tagbase import TagBase
|
||||
from .urlbase import UrlBase
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -138,15 +138,20 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
from .url import Url
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .mediaref import MediaRef
|
||||
from .url import Url
|
||||
|
||||
return {
|
||||
"type": "object",
|
||||
"title": _("Place"),
|
||||
"properties": {
|
||||
"_class": {"enum": [cls.__name__]},
|
||||
"handle": {"type": "string", "maxLength": 50, "title": _("Handle")},
|
||||
"handle": {
|
||||
"type": "string",
|
||||
"maxLength": 50,
|
||||
"title": _("Handle"),
|
||||
},
|
||||
"gramps_id": {"type": "string", "title": _("Gramps ID")},
|
||||
"title": {"type": "string", "title": _("Title")},
|
||||
"long": {"type": "string", "title": _("Longitude")},
|
||||
@ -232,7 +237,9 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
self.place_type = PlaceType()
|
||||
self.place_type.unserialize(the_type)
|
||||
self.alt_loc = [Location().unserialize(al) for al in alt_loc]
|
||||
self.placeref_list = [PlaceRef().unserialize(pr) for pr in placeref_list]
|
||||
self.placeref_list = [
|
||||
PlaceRef().unserialize(pr) for pr in placeref_list
|
||||
]
|
||||
self.name = PlaceName().unserialize(name)
|
||||
self.alt_names = [PlaceName().unserialize(an) for an in alt_names]
|
||||
UrlBase.unserialize(self, urls)
|
||||
@ -259,14 +266,21 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
:rtype: list
|
||||
"""
|
||||
|
||||
ret = self.media_list + self.alt_loc + self.urls + [self.name] + self.alt_names
|
||||
ret = (
|
||||
self.media_list
|
||||
+ self.alt_loc
|
||||
+ self.urls
|
||||
+ [self.name]
|
||||
+ self.alt_names
|
||||
)
|
||||
return ret
|
||||
|
||||
def get_citation_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer citations.
|
||||
|
||||
:returns: List of child secondary child objects that may refer citations.
|
||||
:returns: List of child secondary child objects that may reference
|
||||
citations.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.media_list
|
||||
|
@ -28,10 +28,10 @@ Place name class for Gramps
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .datebase import DateBase
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .datebase import DateBase
|
||||
from .secondaryobj import SecondaryObject
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -59,11 +59,13 @@ class PlaceName(SecondaryObject, DateBase):
|
||||
else:
|
||||
self.value = ""
|
||||
self.lang = ""
|
||||
for key in kwargs:
|
||||
for key, value in kwargs.items():
|
||||
if key in ["value", "lang"]:
|
||||
setattr(self, key, kwargs[key])
|
||||
setattr(self, key, value)
|
||||
else:
|
||||
raise AttributeError("PlaceName does not have property '%s'" % key)
|
||||
raise AttributeError(
|
||||
f"PlaceName does not have property '{key}'"
|
||||
)
|
||||
|
||||
def serialize(self):
|
||||
"""
|
||||
@ -87,6 +89,7 @@ class PlaceName(SecondaryObject, DateBase):
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .date import Date
|
||||
|
||||
return {
|
||||
@ -178,11 +181,9 @@ class PlaceName(SecondaryObject, DateBase):
|
||||
or self.lang != other.lang
|
||||
):
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
return EQUAL
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.is_equal(other)
|
||||
|
@ -28,11 +28,11 @@ Place Reference class for Gramps
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .refbase import RefBase
|
||||
from .datebase import DateBase
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .datebase import DateBase
|
||||
from .refbase import RefBase
|
||||
from .secondaryobj import SecondaryObject
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -80,6 +80,7 @@ class PlaceRef(RefBase, DateBase, SecondaryObject):
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .date import Date
|
||||
|
||||
return {
|
||||
@ -87,7 +88,11 @@ class PlaceRef(RefBase, DateBase, SecondaryObject):
|
||||
"title": _("Place ref"),
|
||||
"properties": {
|
||||
"_class": {"enum": [cls.__name__]},
|
||||
"ref": {"type": "string", "title": _("Handle"), "maxLength": 50},
|
||||
"ref": {
|
||||
"type": "string",
|
||||
"title": _("Handle"),
|
||||
"maxLength": 50,
|
||||
},
|
||||
"date": {
|
||||
"oneOf": [{"type": "null"}, Date.get_schema()],
|
||||
"title": _("Date"),
|
||||
@ -166,8 +171,6 @@ class PlaceRef(RefBase, DateBase, SecondaryObject):
|
||||
"""
|
||||
if self.ref != other.ref or self.date != other.date:
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
return EQUAL
|
||||
|
@ -27,13 +27,22 @@ Provide the different place types.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# PlaceType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class PlaceType(GrampsType):
|
||||
"""
|
||||
Class encapsulating the type of a place.
|
||||
"""
|
||||
|
||||
UNKNOWN = -1
|
||||
CUSTOM = 0
|
||||
COUNTRY = 1
|
||||
|
@ -25,7 +25,7 @@ Basic Primary Object class for Gramps.
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
# Python modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from abc import abstractmethod
|
||||
@ -35,11 +35,11 @@ from abc import abstractmethod
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .tableobj import TableObject
|
||||
from .privacybase import PrivacyBase
|
||||
from .citationbase import CitationBase
|
||||
from .mediabase import MediaBase
|
||||
from .notebase import NoteBase
|
||||
from .privacybase import PrivacyBase
|
||||
from .tableobj import TableObject
|
||||
from .tagbase import TagBase
|
||||
|
||||
|
||||
@ -137,7 +137,6 @@ class BasicPrimaryObject(TableObject, PrivacyBase, TagBase):
|
||||
:param handle_list: The list of handles to be removed.
|
||||
:type handle_list: str
|
||||
"""
|
||||
pass
|
||||
|
||||
def replace_handle_reference(self, classname, old_handle, new_handle):
|
||||
"""
|
||||
@ -150,7 +149,6 @@ class BasicPrimaryObject(TableObject, PrivacyBase, TagBase):
|
||||
:param new_handle: The handle to replace the old one with.
|
||||
:type new_handle: str
|
||||
"""
|
||||
pass
|
||||
|
||||
def has_citation_reference(self, handle):
|
||||
"""
|
||||
@ -177,7 +175,6 @@ class BasicPrimaryObject(TableObject, PrivacyBase, TagBase):
|
||||
In the base class no such references exist. Derived classes should
|
||||
override this if they provide citation references.
|
||||
"""
|
||||
pass
|
||||
|
||||
def remove_media_references(self, handle_list):
|
||||
"""
|
||||
@ -186,21 +183,26 @@ class BasicPrimaryObject(TableObject, PrivacyBase, TagBase):
|
||||
In the base class no such references exist. Derived classes should
|
||||
override this if they provide media references.
|
||||
"""
|
||||
pass
|
||||
|
||||
def remove_note_references(self, handle_list):
|
||||
"""
|
||||
Remove the specified note references from the object.
|
||||
|
||||
In the base class no such references exist. Derived classes should
|
||||
override this if they provide note references.
|
||||
"""
|
||||
|
||||
def replace_citation_references(self, old_handle, new_handle):
|
||||
"""
|
||||
Replace all references to the old citation handle with those to the new
|
||||
citation handle.
|
||||
"""
|
||||
pass
|
||||
|
||||
def replace_media_references(self, old_handle, new_handle):
|
||||
"""
|
||||
Replace all references to the old media handle with those to the new
|
||||
media handle.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
@ -259,10 +261,9 @@ class PrimaryObject(BasicPrimaryObject):
|
||||
"""
|
||||
if classname == "Citation" and isinstance(self, CitationBase):
|
||||
return self.has_citation_reference(handle)
|
||||
elif classname == "Media" and isinstance(self, MediaBase):
|
||||
if classname == "Media" and isinstance(self, MediaBase):
|
||||
return self.has_media_reference(handle)
|
||||
else:
|
||||
return self._has_handle_reference(classname, handle)
|
||||
return self._has_handle_reference(classname, handle)
|
||||
|
||||
def remove_handle_references(self, classname, handle_list):
|
||||
"""
|
||||
@ -310,10 +311,8 @@ class PrimaryObject(BasicPrimaryObject):
|
||||
"""
|
||||
Remove the handle references from the object.
|
||||
"""
|
||||
pass
|
||||
|
||||
def _replace_handle_reference(self, classname, old_handle, new_handle):
|
||||
"""
|
||||
Replace the handle reference with the new reference.
|
||||
"""
|
||||
pass
|
||||
|
@ -24,7 +24,7 @@ Base Reference class for Gramps.
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
# Python modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
@ -30,14 +30,14 @@ Repository object for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .primaryobj import PrimaryObject
|
||||
from .notebase import NoteBase
|
||||
from .addressbase import AddressBase
|
||||
from .urlbase import UrlBase
|
||||
from .tagbase import TagBase
|
||||
from .repotype import RepositoryType
|
||||
from .citationbase import IndirectCitationBase
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .addressbase import AddressBase
|
||||
from .citationbase import IndirectCitationBase
|
||||
from .notebase import NoteBase
|
||||
from .primaryobj import PrimaryObject
|
||||
from .repotype import RepositoryType
|
||||
from .tagbase import TagBase
|
||||
from .urlbase import UrlBase
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -47,7 +47,9 @@ _ = glocale.translation.gettext
|
||||
# Repository class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase, PrimaryObject):
|
||||
class Repository(
|
||||
NoteBase, AddressBase, UrlBase, IndirectCitationBase, PrimaryObject
|
||||
):
|
||||
"""A location where collections of Sources are found."""
|
||||
|
||||
def __init__(self):
|
||||
@ -86,6 +88,7 @@ class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase, PrimaryOb
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .address import Address
|
||||
from .url import Url
|
||||
|
||||
@ -94,7 +97,11 @@ class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase, PrimaryOb
|
||||
"title": _("Repository"),
|
||||
"properties": {
|
||||
"_class": {"enum": [cls.__name__]},
|
||||
"handle": {"type": "string", "maxLength": 50, "title": _("Handle")},
|
||||
"handle": {
|
||||
"type": "string",
|
||||
"maxLength": 50,
|
||||
"title": _("Handle"),
|
||||
},
|
||||
"gramps_id": {"type": "string", "title": _("Gramps ID")},
|
||||
"type": RepositoryType.get_schema(),
|
||||
"name": {"type": "string", "title": _("Name")},
|
||||
@ -205,7 +212,10 @@ class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase, PrimaryOb
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.get_referenced_note_handles() + self.get_referenced_tag_handles()
|
||||
return (
|
||||
self.get_referenced_note_handles()
|
||||
+ self.get_referenced_tag_handles()
|
||||
)
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
|
@ -30,13 +30,13 @@ Repository Reference class for Gramps
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .privacybase import PrivacyBase
|
||||
from .notebase import NoteBase
|
||||
from .refbase import RefBase
|
||||
from .srcmediatype import SourceMediaType
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .notebase import NoteBase
|
||||
from .privacybase import PrivacyBase
|
||||
from .refbase import RefBase
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .srcmediatype import SourceMediaType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -104,7 +104,11 @@ class RepoRef(SecondaryObject, PrivacyBase, NoteBase, RefBase):
|
||||
"title": _("Notes"),
|
||||
"items": {"type": "string", "maxLength": 50},
|
||||
},
|
||||
"ref": {"type": "string", "title": _("Handle"), "maxLength": 50},
|
||||
"ref": {
|
||||
"type": "string",
|
||||
"title": _("Handle"),
|
||||
"maxLength": 50,
|
||||
},
|
||||
"call_number": {"type": "string", "title": _("Call Number")},
|
||||
"media_type": SourceMediaType.get_schema(),
|
||||
"private": {"type": "boolean", "title": _("Private")},
|
||||
@ -148,11 +152,9 @@ class RepoRef(SecondaryObject, PrivacyBase, NoteBase, RefBase):
|
||||
or self.get_text_data_list() != other.get_text_data_list()
|
||||
):
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
return EQUAL
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
@ -166,13 +168,25 @@ class RepoRef(SecondaryObject, PrivacyBase, NoteBase, RefBase):
|
||||
self._merge_note_list(acquisition)
|
||||
|
||||
def set_call_number(self, number):
|
||||
"""
|
||||
Set the call number.
|
||||
"""
|
||||
self.call_number = number
|
||||
|
||||
def get_call_number(self):
|
||||
"""
|
||||
Get the call number.
|
||||
"""
|
||||
return self.call_number
|
||||
|
||||
def get_media_type(self):
|
||||
"""
|
||||
Get the media type.
|
||||
"""
|
||||
return self.media_type
|
||||
|
||||
def set_media_type(self, media_type):
|
||||
"""
|
||||
Set the media type.
|
||||
"""
|
||||
self.media_type.set(media_type)
|
||||
|
@ -27,13 +27,22 @@ Repository types.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# RepositoryType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class RepositoryType(GrampsType):
|
||||
"""
|
||||
Class encapsulating the type of repository.
|
||||
"""
|
||||
|
||||
UNKNOWN = -1
|
||||
CUSTOM = 0
|
||||
LIBRARY = 1
|
||||
|
@ -33,11 +33,13 @@ from .locationbase import LocationBase
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
# Researcher class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class Researcher(LocationBase):
|
||||
"""Contains the information about the owner of the database."""
|
||||
"""
|
||||
Contains the information about the owner of the database.
|
||||
"""
|
||||
|
||||
def __init__(self, source=None):
|
||||
"""
|
||||
@ -109,6 +111,9 @@ class Researcher(LocationBase):
|
||||
self.email = other_researcher.email
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
Return attributes about the researcher.
|
||||
"""
|
||||
return [
|
||||
getattr(self, value)
|
||||
for value in [
|
||||
@ -125,6 +130,9 @@ class Researcher(LocationBase):
|
||||
]
|
||||
|
||||
def is_empty(self):
|
||||
"""
|
||||
Check and return true if object empty.
|
||||
"""
|
||||
for attr in [
|
||||
"name",
|
||||
"addr",
|
||||
|
@ -24,7 +24,7 @@ Secondary Object class for Gramps.
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
# Python modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from abc import abstractmethod
|
||||
@ -39,7 +39,7 @@ from .baseobj import BaseObject
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Secondary Object class
|
||||
# SecondaryObject class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class SecondaryObject(BaseObject):
|
||||
@ -61,6 +61,9 @@ class SecondaryObject(BaseObject):
|
||||
"""
|
||||
|
||||
def is_equal(self, source):
|
||||
"""
|
||||
Check if two secondary objects are equivalent.
|
||||
"""
|
||||
return self.serialize() == source.serialize()
|
||||
|
||||
def is_equivalent(self, other):
|
||||
@ -69,4 +72,3 @@ class SecondaryObject(BaseObject):
|
||||
|
||||
Should be overwritten by objects that inherit from this class.
|
||||
"""
|
||||
pass
|
||||
|
@ -31,15 +31,15 @@ Source object for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .primaryobj import PrimaryObject
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .attrbase import SrcAttributeBase
|
||||
from .citationbase import IndirectCitationBase
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .mediabase import MediaBase
|
||||
from .notebase import NoteBase
|
||||
from .tagbase import TagBase
|
||||
from .attrbase import SrcAttributeBase
|
||||
from .primaryobj import PrimaryObject
|
||||
from .reporef import RepoRef
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .citationbase import IndirectCitationBase
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .tagbase import TagBase
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -52,7 +52,9 @@ _ = glocale.translation.gettext
|
||||
class Source(
|
||||
MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase, PrimaryObject
|
||||
):
|
||||
"""A record of a source of information."""
|
||||
"""
|
||||
A record of a source of information.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""Create a new Source instance."""
|
||||
@ -94,16 +96,20 @@ class Source(
|
||||
:returns: Returns a dict containing the schema.
|
||||
:rtype: dict
|
||||
"""
|
||||
from .srcattribute import SrcAttribute
|
||||
from .reporef import RepoRef
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .mediaref import MediaRef
|
||||
from .srcattribute import SrcAttribute
|
||||
|
||||
return {
|
||||
"type": "object",
|
||||
"title": _("Source"),
|
||||
"properties": {
|
||||
"_class": {"enum": [cls.__name__]},
|
||||
"handle": {"type": "string", "maxLength": 50, "title": _("Handle")},
|
||||
"handle": {
|
||||
"type": "string",
|
||||
"maxLength": 50,
|
||||
"title": _("Handle"),
|
||||
},
|
||||
"gramps_id": {"type": "string", "title": _("Gramps ID")},
|
||||
"title": {"type": "string", "title": _("Title")},
|
||||
"author": {"type": "string", "title": _("Author")},
|
||||
@ -164,7 +170,9 @@ class Source(
|
||||
MediaBase.unserialize(self, media_list)
|
||||
TagBase.unserialize(self, tag_list)
|
||||
SrcAttributeBase.unserialize(self, srcattr_list)
|
||||
self.reporef_list = [RepoRef().unserialize(item) for item in reporef_list]
|
||||
self.reporef_list = [
|
||||
RepoRef().unserialize(item) for item in reporef_list
|
||||
]
|
||||
return self
|
||||
|
||||
def _has_handle_reference(self, classname, handle):
|
||||
@ -194,7 +202,9 @@ class Source(
|
||||
:type handle_list: str
|
||||
"""
|
||||
if classname == "Repository":
|
||||
new_list = [ref for ref in self.reporef_list if ref.ref not in handle_list]
|
||||
new_list = [
|
||||
ref for ref in self.reporef_list if ref.ref not in handle_list
|
||||
]
|
||||
self.reporef_list = new_list
|
||||
|
||||
def _replace_handle_reference(self, classname, old_handle, new_handle):
|
||||
@ -222,7 +232,13 @@ class Source(
|
||||
:returns: Returns the list of all textual attributes of the object.
|
||||
:rtype: list
|
||||
"""
|
||||
return [self.title, self.author, self.pubinfo, self.abbrev, self.gramps_id]
|
||||
return [
|
||||
self.title,
|
||||
self.author,
|
||||
self.pubinfo,
|
||||
self.abbrev,
|
||||
self.gramps_id,
|
||||
]
|
||||
|
||||
def get_text_data_child_list(self):
|
||||
"""
|
||||
@ -271,7 +287,10 @@ class Source(
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.get_referenced_note_handles() + self.get_referenced_tag_handles()
|
||||
return (
|
||||
self.get_referenced_note_handles()
|
||||
+ self.get_referenced_tag_handles()
|
||||
)
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
@ -376,7 +395,7 @@ class Source(
|
||||
equi = reporef.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
if equi == EQUAL:
|
||||
reporef.merge(addendum)
|
||||
break
|
||||
else:
|
||||
@ -423,7 +442,7 @@ class Source(
|
||||
if new_handle in refs_list:
|
||||
new_ref = self.reporef_list[refs_list.index(new_handle)]
|
||||
n_replace = refs_list.count(old_handle)
|
||||
for ix_replace in range(n_replace):
|
||||
for dummy_ix_replace in range(n_replace):
|
||||
idx = refs_list.index(old_handle)
|
||||
self.reporef_list[idx].ref = new_handle
|
||||
refs_list[idx] = new_handle
|
||||
|
@ -28,9 +28,9 @@ Source Attribute class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .attribute import AttributeRoot
|
||||
from .srcattrtype import SrcAttributeType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
@ -27,13 +27,22 @@ Provide the different Source Attribute Types for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# SrcAttributeType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class SrcAttributeType(GrampsType):
|
||||
"""
|
||||
Class encapsulating the type of source attribute.
|
||||
"""
|
||||
|
||||
UNKNOWN = -1
|
||||
CUSTOM = 0
|
||||
|
||||
|
@ -27,13 +27,22 @@ SourceMedia types.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# SourceMediaType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class SourceMediaType(GrampsType):
|
||||
"""
|
||||
Class encapsulating the media type for a source.
|
||||
"""
|
||||
|
||||
UNKNOWN = -1
|
||||
CUSTOM = 0
|
||||
AUDIO = 1
|
||||
|
@ -24,12 +24,18 @@
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
# Python modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from copy import copy
|
||||
from .styledtexttag import StyledTextTag
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .styledtexttag import StyledTextTag
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -118,17 +124,17 @@ class StyledText:
|
||||
# need to join strings and merge tags
|
||||
for tag in other.tags:
|
||||
tag.ranges = [
|
||||
(start + offset, end + offset) for (start, end) in tag.ranges
|
||||
(start + offset, end + offset)
|
||||
for (start, end) in tag.ranges
|
||||
]
|
||||
|
||||
return self.__class__(
|
||||
"".join([self._string, other.string]), self._tags + other.tags
|
||||
)
|
||||
elif isinstance(other, str):
|
||||
if isinstance(other, str):
|
||||
# tags remain the same, only text becomes longer
|
||||
return self.__class__("".join([self._string, other]), self._tags)
|
||||
else:
|
||||
return self.__class__("".join([self._string, str(other)]), self._tags)
|
||||
return self.__class__("".join([self._string, str(other)]), self._tags)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self._string == other.string and self._tags == other.tags
|
||||
@ -214,7 +220,8 @@ class StyledText:
|
||||
for tag in self.tags:
|
||||
ntag = copy(tag)
|
||||
ntag.ranges = [
|
||||
(start + offset, end + offset) for (start, end) in tag.ranges
|
||||
(start + offset, end + offset)
|
||||
for (start, end) in tag.ranges
|
||||
]
|
||||
new_tags += [ntag]
|
||||
offset += self_len
|
||||
@ -222,7 +229,8 @@ class StyledText:
|
||||
for tag in text.tags:
|
||||
ntag = copy(tag)
|
||||
ntag.ranges = [
|
||||
(start + offset, end + offset) for (start, end) in tag.ranges
|
||||
(start + offset, end + offset)
|
||||
for (start, end) in tag.ranges
|
||||
]
|
||||
new_tags += [ntag]
|
||||
offset += len(str(text))
|
||||
|
@ -27,8 +27,8 @@
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .styledtexttagtype import StyledTextTagType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .styledtexttagtype import StyledTextTagType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -105,7 +105,10 @@ class StyledTextTag:
|
||||
"properties": {
|
||||
"_class": {"enum": [cls.__name__]},
|
||||
"name": StyledTextTagType.get_schema(),
|
||||
"value": {"type": ["null", "string", "integer"], "title": _("Value")},
|
||||
"value": {
|
||||
"type": ["null", "string", "integer"],
|
||||
"title": _("Value"),
|
||||
},
|
||||
"ranges": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
@ -27,8 +27,8 @@ Define text formatting tag types.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
@ -29,17 +29,17 @@ Surname class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .nameorigintype import NameOriginType
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .nameorigintype import NameOriginType
|
||||
from .secondaryobj import SecondaryObject
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Personal Name
|
||||
# Surname class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class Surname(SecondaryObject):
|
||||
@ -112,7 +112,13 @@ class Surname(SecondaryObject):
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
(self.surname, self.prefix, self.primary, origin_type, self.connector) = data
|
||||
(
|
||||
self.surname,
|
||||
self.prefix,
|
||||
self.primary,
|
||||
origin_type,
|
||||
self.connector,
|
||||
) = data
|
||||
self.origintype = NameOriginType(origin_type)
|
||||
return self
|
||||
|
||||
@ -141,11 +147,9 @@ class Surname(SecondaryObject):
|
||||
or self.primary != other.primary
|
||||
):
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
return EQUAL
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
@ -156,7 +160,6 @@ class Surname(SecondaryObject):
|
||||
:param acquisition: The surname to merge with the present surname.
|
||||
:type acquisition: Surname
|
||||
"""
|
||||
pass
|
||||
|
||||
def get_surname(self):
|
||||
"""
|
||||
|
@ -27,16 +27,16 @@ SurnameBase class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .surname import Surname
|
||||
from .const import IDENTICAL, EQUAL
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .const import EQUAL, IDENTICAL
|
||||
from .surname import Surname
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# SurnameBase classes
|
||||
# SurnameBase class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class SurnameBase:
|
||||
@ -54,7 +54,9 @@ class SurnameBase:
|
||||
:param source: Object used to initialize the new object
|
||||
:type source: SurnameBase
|
||||
"""
|
||||
self.surname_list = list(map(Surname, source.surname_list)) if source else []
|
||||
self.surname_list = (
|
||||
list(map(Surname, source.surname_list)) if source else []
|
||||
)
|
||||
|
||||
def serialize(self):
|
||||
"""
|
||||
@ -98,8 +100,7 @@ class SurnameBase:
|
||||
if surname in self.surname_list:
|
||||
self.surname_list.remove(surname)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
def get_surname_list(self):
|
||||
"""
|
||||
@ -136,10 +137,9 @@ class SurnameBase:
|
||||
return surname
|
||||
if self.surname_list:
|
||||
return self.surname_list[0]
|
||||
else:
|
||||
# self healing, add a surname to this object and return it
|
||||
self.set_surname_list([Surname()])
|
||||
return self.surname_list[0]
|
||||
# self healing, add a surname to this object and return it
|
||||
self.set_surname_list([Surname()])
|
||||
return self.surname_list[0]
|
||||
|
||||
def set_primary_surname(self, surnamenr=0):
|
||||
"""
|
||||
@ -172,7 +172,7 @@ class SurnameBase:
|
||||
equi = surname.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
if equi == EQUAL:
|
||||
# This should normally never happen, an alternate name
|
||||
# should be added
|
||||
surname.merge(addendum)
|
||||
|
@ -25,33 +25,26 @@ Table Object class for Gramps.
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
# Python modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from abc import abstractmethod
|
||||
import time
|
||||
from abc import abstractmethod
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .baseobj import BaseObject
|
||||
from ..errors import HandleError
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Localized constants
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .baseobj import BaseObject
|
||||
|
||||
CODESET = glocale.encoding
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Table Object class
|
||||
# TableObject class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class TableObject(BaseObject):
|
||||
@ -128,9 +121,10 @@ class TableObject(BaseObject):
|
||||
|
||||
"""
|
||||
if self.change:
|
||||
return str(time.strftime("%x %X", time.localtime(self.change)), CODESET)
|
||||
else:
|
||||
return ""
|
||||
return str(
|
||||
time.strftime("%x %X", time.localtime(self.change)), CODESET
|
||||
)
|
||||
return ""
|
||||
|
||||
def set_handle(self, handle):
|
||||
"""
|
||||
@ -171,5 +165,7 @@ class TableObject(BaseObject):
|
||||
elif isinstance(schema_type, dict):
|
||||
schema_type = None
|
||||
if schema_type in ("string", "integer", "number", "boolean"):
|
||||
result.append((key.lower(), schema_type, value.get("maxLength")))
|
||||
result.append(
|
||||
(key.lower(), schema_type, value.get("maxLength"))
|
||||
)
|
||||
return result
|
||||
|
@ -28,8 +28,8 @@ Tag object for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .tableobj import TableObject
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .tableobj import TableObject
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -82,7 +82,13 @@ class Tag(TableObject):
|
||||
be considered persistent.
|
||||
:rtype: tuple
|
||||
"""
|
||||
return (self.handle, self.__name, self.__color, self.__priority, self.change)
|
||||
return (
|
||||
self.handle,
|
||||
self.__name,
|
||||
self.__color,
|
||||
self.__priority,
|
||||
self.change,
|
||||
)
|
||||
|
||||
def unserialize(self, data):
|
||||
"""
|
||||
@ -93,7 +99,13 @@ class Tag(TableObject):
|
||||
object
|
||||
:type data: tuple
|
||||
"""
|
||||
(self.handle, self.__name, self.__color, self.__priority, self.change) = data
|
||||
(
|
||||
self.handle,
|
||||
self.__name,
|
||||
self.__color,
|
||||
self.__priority,
|
||||
self.change,
|
||||
) = data
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
@ -109,10 +121,22 @@ class Tag(TableObject):
|
||||
"title": _("Tag"),
|
||||
"properties": {
|
||||
"_class": {"enum": [cls.__name__]},
|
||||
"handle": {"type": "string", "maxLength": 50, "title": _("Handle")},
|
||||
"handle": {
|
||||
"type": "string",
|
||||
"maxLength": 50,
|
||||
"title": _("Handle"),
|
||||
},
|
||||
"name": {"type": "string", "title": _("Name")},
|
||||
"color": {"type": "string", "maxLength": 13, "title": _("Color")},
|
||||
"priority": {"type": "integer", "minimum": 0, "title": _("Priority")},
|
||||
"color": {
|
||||
"type": "string",
|
||||
"maxLength": 13,
|
||||
"title": _("Color"),
|
||||
},
|
||||
"priority": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"title": _("Priority"),
|
||||
},
|
||||
"change": {"type": "integer", "title": _("Last changed")},
|
||||
},
|
||||
}
|
||||
@ -195,7 +219,9 @@ class Tag(TableObject):
|
||||
"""
|
||||
return self.__color
|
||||
|
||||
color = property(get_color, set_color, None, "Returns or sets color of the tag")
|
||||
color = property(
|
||||
get_color, set_color, None, "Returns or sets color of the tag"
|
||||
)
|
||||
|
||||
def set_priority(self, priority):
|
||||
"""
|
||||
|
@ -86,8 +86,7 @@ class TagBase:
|
||||
if tag in self.tag_list:
|
||||
self.tag_list.remove(tag)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
def get_tag_list(self):
|
||||
"""
|
||||
@ -145,7 +144,7 @@ class TagBase:
|
||||
if new_handle in self.tag_list:
|
||||
new_ref = new_handle
|
||||
n_replace = refs_list.count(old_handle)
|
||||
for ix_replace in range(n_replace):
|
||||
for dummy_ix_replace in range(n_replace):
|
||||
idx = refs_list.index(old_handle)
|
||||
if new_ref:
|
||||
self.tag_list.pop(idx)
|
||||
|
@ -34,11 +34,12 @@ import unittest
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from ...config import config
|
||||
from ...datehandler import get_date_formats, set_format
|
||||
from ...datehandler import parser as _dp
|
||||
from ...datehandler import displayer as _dd
|
||||
from ...datehandler import get_date_formats
|
||||
from ...datehandler import parser as _dp
|
||||
from ...datehandler import set_format
|
||||
from ...datehandler._datedisplay import DateDisplayEn
|
||||
from ...lib.date import Date, DateError, Today, calendar_has_fixed_newyear, Span
|
||||
from ...lib.date import Date, DateError, Span, Today, calendar_has_fixed_newyear
|
||||
|
||||
date_tests = {}
|
||||
|
||||
@ -57,7 +58,13 @@ for quality in (Date.QUAL_NONE, Date.QUAL_ESTIMATED, Date.QUAL_CALCULATED):
|
||||
):
|
||||
for month in range(1, 13):
|
||||
d = Date()
|
||||
d.set(quality, modifier, calendar, (4, month, 1789, False), "Text comment")
|
||||
d.set(
|
||||
quality,
|
||||
modifier,
|
||||
calendar,
|
||||
(4, month, 1789, False),
|
||||
"Text comment",
|
||||
)
|
||||
dates.append(d)
|
||||
for modifier in (Date.MOD_RANGE, Date.MOD_SPAN):
|
||||
for month1 in range(1, 13):
|
||||
@ -267,7 +274,13 @@ for calendar in (
|
||||
Date.MOD_TO,
|
||||
):
|
||||
d = Date()
|
||||
d.set(quality, modifier, calendar, (4, 11, 1789, False), "Text comment")
|
||||
d.set(
|
||||
quality,
|
||||
modifier,
|
||||
calendar,
|
||||
(4, 11, 1789, False),
|
||||
"Text comment",
|
||||
)
|
||||
dates.append(d)
|
||||
for modifier in (Date.MOD_RANGE, Date.MOD_SPAN):
|
||||
d = Date()
|
||||
@ -304,7 +317,13 @@ with Context(Date.CAL_SWEDISH) as calendar:
|
||||
Date.MOD_TO,
|
||||
):
|
||||
d = Date()
|
||||
d.set(quality, modifier, calendar, (4, 11, 1700, False), "Text comment")
|
||||
d.set(
|
||||
quality,
|
||||
modifier,
|
||||
calendar,
|
||||
(4, 11, 1700, False),
|
||||
"Text comment",
|
||||
)
|
||||
dates.append(d)
|
||||
for modifier in (Date.MOD_RANGE, Date.MOD_SPAN):
|
||||
d = Date()
|
||||
@ -326,13 +345,17 @@ for calendar in (
|
||||
):
|
||||
for month in range(1, 13):
|
||||
d = Date()
|
||||
d.set(quality, modifier, calendar, (4, month, 1789, False), "Text comment")
|
||||
d.set(
|
||||
quality, modifier, calendar, (4, month, 1789, False), "Text comment"
|
||||
)
|
||||
dates.append(d)
|
||||
|
||||
for calendar in (Date.CAL_HEBREW, Date.CAL_FRENCH):
|
||||
for month in range(1, 14):
|
||||
d = Date()
|
||||
d.set(quality, modifier, calendar, (4, month, 1789, False), "Text comment")
|
||||
d.set(
|
||||
quality, modifier, calendar, (4, month, 1789, False), "Text comment"
|
||||
)
|
||||
dates.append(d)
|
||||
|
||||
date_tests[testset] = dates
|
||||
@ -343,7 +366,13 @@ with Context(Date.CAL_SWEDISH) as calendar:
|
||||
for year in range(1701, 1712):
|
||||
for month in range(1, 13):
|
||||
d = Date()
|
||||
d.set(quality, modifier, calendar, (4, month, year, False), "Text comment")
|
||||
d.set(
|
||||
quality,
|
||||
modifier,
|
||||
calendar,
|
||||
(4, month, year, False),
|
||||
"Text comment",
|
||||
)
|
||||
swedish_dates.append(d)
|
||||
|
||||
|
||||
@ -590,7 +619,9 @@ class ArithmeticDateTest(BaseDateTest):
|
||||
val1 = eval(exp1)
|
||||
val2 = eval(exp2)
|
||||
self.assertEqual(
|
||||
val1, val2, "'%s' should be '%s' but was '%s'" % (exp1, val2, val1)
|
||||
val1,
|
||||
val2,
|
||||
"'%s' should be '%s' but was '%s'" % (exp1, val2, val1),
|
||||
)
|
||||
|
||||
|
||||
@ -868,105 +899,600 @@ class DateComparisonTest(BaseDateTest):
|
||||
("from 1960 to 1961", ">=", "from 1960 to 1961", True),
|
||||
("from 1960 to 1961", ">=", "from 1961 to 1962", False),
|
||||
("from 1960 to 1961", ">=", "from 1962 to 1963", False),
|
||||
("from 1960-01-01 to 1961-01-01", "=", "from 1958-01-01 to 1959-12-31", False),
|
||||
("from 1960-01-01 to 1961-01-01", "=", "from 1958-01-01 to 1960-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "=", "from 1958-01-01 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "=", "from 1958-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "=", "from 1960-01-01 to 1960-12-31", True),
|
||||
("from 1960-01-01 to 1961-01-01", "=", "from 1960-01-01 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "=", "from 1960-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "=", "from 1960-12-31 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "=", "from 1960-12-31 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "=", "from 1961-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "=", "from 1961-01-02 to 1961-01-03", False),
|
||||
("from 1960-01-01 to 1961-01-01", "!=", "from 1958-01-01 to 1959-12-31", True),
|
||||
("from 1960-01-01 to 1961-01-01", "!=", "from 1958-01-01 to 1960-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "!=", "from 1958-01-01 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "!=", "from 1958-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "!=", "from 1960-01-01 to 1960-12-31", False),
|
||||
("from 1960-01-01 to 1961-01-01", "!=", "from 1960-01-01 to 1961-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", "!=", "from 1960-01-01 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", "!=", "from 1960-12-31 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "!=", "from 1960-12-31 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "!=", "from 1961-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "!=", "from 1961-01-02 to 1961-01-03", True),
|
||||
("from 1960-01-01 to 1961-01-01", "==", "from 1958-01-01 to 1959-12-31", False),
|
||||
("from 1960-01-01 to 1961-01-01", "==", "from 1958-01-01 to 1960-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", "==", "from 1958-01-01 to 1961-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", "==", "from 1958-01-01 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", "==", "from 1960-01-01 to 1960-12-31", True),
|
||||
("from 1960-01-01 to 1961-01-01", "==", "from 1960-01-01 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "==", "from 1960-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "==", "from 1960-12-31 to 1961-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", "==", "from 1960-12-31 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", "==", "from 1961-01-01 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", "==", "from 1961-01-02 to 1961-01-03", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<", "from 1958-01-01 to 1959-12-31", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<", "from 1958-01-01 to 1960-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<", "from 1958-01-01 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<", "from 1958-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<", "from 1960-01-01 to 1960-12-31", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<", "from 1960-01-01 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<", "from 1960-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<", "from 1960-12-31 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<", "from 1960-12-31 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<", "from 1961-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<", "from 1961-01-02 to 1961-01-03", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">", "from 1958-01-01 to 1959-12-31", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">", "from 1958-01-01 to 1960-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">", "from 1958-01-01 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">", "from 1958-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">", "from 1960-01-01 to 1960-12-31", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">", "from 1960-01-01 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">", "from 1960-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">", "from 1960-12-31 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">", "from 1960-12-31 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">", "from 1961-01-01 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">", "from 1961-01-02 to 1961-01-03", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<<", "from 1958-01-01 to 1959-12-31", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<<", "from 1958-01-01 to 1960-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<<", "from 1958-01-01 to 1961-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<<", "from 1958-01-01 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<<", "from 1960-01-01 to 1960-12-31", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<<", "from 1960-01-01 to 1961-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<<", "from 1960-01-01 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<<", "from 1960-12-31 to 1961-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<<", "from 1960-12-31 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<<", "from 1961-01-01 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<<", "from 1961-01-02 to 1961-01-03", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">>", "from 1958-01-01 to 1959-12-31", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">>", "from 1958-01-01 to 1960-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">>", "from 1958-01-01 to 1961-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">>", "from 1958-01-01 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">>", "from 1960-01-01 to 1960-12-31", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">>", "from 1960-01-01 to 1961-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">>", "from 1960-01-01 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">>", "from 1960-12-31 to 1961-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">>", "from 1960-12-31 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">>", "from 1961-01-01 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">>", "from 1961-01-02 to 1961-01-03", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<=", "from 1958-01-01 to 1959-12-31", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<=", "from 1958-01-01 to 1960-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<=", "from 1958-01-01 to 1961-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<=", "from 1958-01-01 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", "<=", "from 1960-01-01 to 1960-12-31", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<=", "from 1960-01-01 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<=", "from 1960-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<=", "from 1960-12-31 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<=", "from 1960-12-31 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<=", "from 1961-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", "<=", "from 1961-01-02 to 1961-01-03", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">=", "from 1958-01-01 to 1959-12-31", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">=", "from 1958-01-01 to 1960-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">=", "from 1958-01-01 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">=", "from 1958-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">=", "from 1960-01-01 to 1960-12-31", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">=", "from 1960-01-01 to 1961-01-01", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">=", "from 1960-01-01 to 1961-01-02", True),
|
||||
("from 1960-01-01 to 1961-01-01", ">=", "from 1960-12-31 to 1961-01-01", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">=", "from 1960-12-31 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">=", "from 1961-01-01 to 1961-01-02", False),
|
||||
("from 1960-01-01 to 1961-01-01", ">=", "from 1961-01-02 to 1961-01-03", False),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"=",
|
||||
"from 1958-01-01 to 1959-12-31",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"=",
|
||||
"from 1958-01-01 to 1960-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"=",
|
||||
"from 1958-01-01 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"=",
|
||||
"from 1958-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"=",
|
||||
"from 1960-01-01 to 1960-12-31",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"=",
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"=",
|
||||
"from 1960-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"=",
|
||||
"from 1960-12-31 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"=",
|
||||
"from 1960-12-31 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"=",
|
||||
"from 1961-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"=",
|
||||
"from 1961-01-02 to 1961-01-03",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"!=",
|
||||
"from 1958-01-01 to 1959-12-31",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"!=",
|
||||
"from 1958-01-01 to 1960-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"!=",
|
||||
"from 1958-01-01 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"!=",
|
||||
"from 1958-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"!=",
|
||||
"from 1960-01-01 to 1960-12-31",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"!=",
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"!=",
|
||||
"from 1960-01-01 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"!=",
|
||||
"from 1960-12-31 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"!=",
|
||||
"from 1960-12-31 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"!=",
|
||||
"from 1961-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"!=",
|
||||
"from 1961-01-02 to 1961-01-03",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"==",
|
||||
"from 1958-01-01 to 1959-12-31",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"==",
|
||||
"from 1958-01-01 to 1960-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"==",
|
||||
"from 1958-01-01 to 1961-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"==",
|
||||
"from 1958-01-01 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"==",
|
||||
"from 1960-01-01 to 1960-12-31",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"==",
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"==",
|
||||
"from 1960-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"==",
|
||||
"from 1960-12-31 to 1961-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"==",
|
||||
"from 1960-12-31 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"==",
|
||||
"from 1961-01-01 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"==",
|
||||
"from 1961-01-02 to 1961-01-03",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<",
|
||||
"from 1958-01-01 to 1959-12-31",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<",
|
||||
"from 1958-01-01 to 1960-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<",
|
||||
"from 1958-01-01 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<",
|
||||
"from 1958-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<",
|
||||
"from 1960-01-01 to 1960-12-31",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<",
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<",
|
||||
"from 1960-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<",
|
||||
"from 1960-12-31 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<",
|
||||
"from 1960-12-31 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<",
|
||||
"from 1961-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<",
|
||||
"from 1961-01-02 to 1961-01-03",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">",
|
||||
"from 1958-01-01 to 1959-12-31",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">",
|
||||
"from 1958-01-01 to 1960-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">",
|
||||
"from 1958-01-01 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">",
|
||||
"from 1958-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">",
|
||||
"from 1960-01-01 to 1960-12-31",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">",
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">",
|
||||
"from 1960-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">",
|
||||
"from 1960-12-31 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">",
|
||||
"from 1960-12-31 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">",
|
||||
"from 1961-01-01 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">",
|
||||
"from 1961-01-02 to 1961-01-03",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<<",
|
||||
"from 1958-01-01 to 1959-12-31",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<<",
|
||||
"from 1958-01-01 to 1960-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<<",
|
||||
"from 1958-01-01 to 1961-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<<",
|
||||
"from 1958-01-01 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<<",
|
||||
"from 1960-01-01 to 1960-12-31",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<<",
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<<",
|
||||
"from 1960-01-01 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<<",
|
||||
"from 1960-12-31 to 1961-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<<",
|
||||
"from 1960-12-31 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<<",
|
||||
"from 1961-01-01 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<<",
|
||||
"from 1961-01-02 to 1961-01-03",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">>",
|
||||
"from 1958-01-01 to 1959-12-31",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">>",
|
||||
"from 1958-01-01 to 1960-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">>",
|
||||
"from 1958-01-01 to 1961-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">>",
|
||||
"from 1958-01-01 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">>",
|
||||
"from 1960-01-01 to 1960-12-31",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">>",
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">>",
|
||||
"from 1960-01-01 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">>",
|
||||
"from 1960-12-31 to 1961-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">>",
|
||||
"from 1960-12-31 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">>",
|
||||
"from 1961-01-01 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">>",
|
||||
"from 1961-01-02 to 1961-01-03",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<=",
|
||||
"from 1958-01-01 to 1959-12-31",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<=",
|
||||
"from 1958-01-01 to 1960-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<=",
|
||||
"from 1958-01-01 to 1961-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<=",
|
||||
"from 1958-01-01 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<=",
|
||||
"from 1960-01-01 to 1960-12-31",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<=",
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<=",
|
||||
"from 1960-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<=",
|
||||
"from 1960-12-31 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<=",
|
||||
"from 1960-12-31 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<=",
|
||||
"from 1961-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
"<=",
|
||||
"from 1961-01-02 to 1961-01-03",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">=",
|
||||
"from 1958-01-01 to 1959-12-31",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">=",
|
||||
"from 1958-01-01 to 1960-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">=",
|
||||
"from 1958-01-01 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">=",
|
||||
"from 1958-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">=",
|
||||
"from 1960-01-01 to 1960-12-31",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">=",
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">=",
|
||||
"from 1960-01-01 to 1961-01-02",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">=",
|
||||
"from 1960-12-31 to 1961-01-01",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">=",
|
||||
"from 1960-12-31 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">=",
|
||||
"from 1961-01-01 to 1961-01-02",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"from 1960-01-01 to 1961-01-01",
|
||||
">=",
|
||||
"from 1961-01-02 to 1961-01-03",
|
||||
False,
|
||||
),
|
||||
]
|
||||
|
||||
def convert_to_date(self, d):
|
||||
@ -1096,7 +1622,9 @@ class SwedishDateTest(BaseDateTest):
|
||||
|
||||
def test_swedish(self):
|
||||
for date in swedish_dates:
|
||||
self.assertEqual(date.sortval, date.to_calendar("gregorian").sortval)
|
||||
self.assertEqual(
|
||||
date.sortval, date.to_calendar("gregorian").sortval
|
||||
)
|
||||
|
||||
|
||||
class Test_set2(BaseDateTest):
|
||||
@ -1150,7 +1678,9 @@ class Test_set2(BaseDateTest):
|
||||
self.assertEqual(stop, (2009, 1, 1))
|
||||
|
||||
def test_copy_ymd_preserves_orig(self):
|
||||
copied = self.date.copy_ymd(year=1000, month=10, day=10, remove_stop_date=True)
|
||||
copied = self.date.copy_ymd(
|
||||
year=1000, month=10, day=10, remove_stop_date=True
|
||||
)
|
||||
self.testStartStopSanity()
|
||||
start, stop = copied.get_start_stop_range()
|
||||
self.assertEqual(start, (1000, 10, 10))
|
||||
@ -1192,7 +1722,9 @@ class Test_set_newyear(BaseDateTest):
|
||||
for cal in Date.CALENDARS:
|
||||
d = Date(1111, 2, 3)
|
||||
should_raise = calendar_has_fixed_newyear(cal)
|
||||
message = "{name} {cal}".format(name=Date.calendar_names[cal], cal=cal)
|
||||
message = "{name} {cal}".format(
|
||||
name=Date.calendar_names[cal], cal=cal
|
||||
)
|
||||
try:
|
||||
d.set(calendar=cal, newyear=2)
|
||||
self.assertFalse(should_raise, message)
|
||||
@ -1226,12 +1758,17 @@ class EmptyDateTest(BaseDateTest):
|
||||
|
||||
def test_range_empty(self):
|
||||
d = Date()
|
||||
d.set(value=(1, 1, 1900, False, 1, 1, 1910, False), modifier=Date.MOD_RANGE)
|
||||
d.set(
|
||||
value=(1, 1, 1900, False, 1, 1, 1910, False),
|
||||
modifier=Date.MOD_RANGE,
|
||||
)
|
||||
self.assertFalse(d.is_empty())
|
||||
|
||||
def test_span_empty(self):
|
||||
d = Date()
|
||||
d.set(value=(1, 1, 1900, False, 1, 1, 1910, False), modifier=Date.MOD_SPAN)
|
||||
d.set(
|
||||
value=(1, 1, 1900, False, 1, 1, 1910, False), modifier=Date.MOD_SPAN
|
||||
)
|
||||
self.assertFalse(d.is_empty())
|
||||
|
||||
|
||||
|
@ -23,58 +23,56 @@
|
||||
import unittest
|
||||
|
||||
from .. import (
|
||||
Person,
|
||||
Surname,
|
||||
Name,
|
||||
NameType,
|
||||
Family,
|
||||
FamilyRelType,
|
||||
Event,
|
||||
EventType,
|
||||
Source,
|
||||
Place,
|
||||
PlaceName,
|
||||
Address,
|
||||
Attribute,
|
||||
AttributeType,
|
||||
ChildRef,
|
||||
ChildRefType,
|
||||
Citation,
|
||||
Date,
|
||||
Repository,
|
||||
RepositoryType,
|
||||
Event,
|
||||
EventRef,
|
||||
EventRoleType,
|
||||
EventType,
|
||||
Family,
|
||||
FamilyRelType,
|
||||
LdsOrd,
|
||||
Media,
|
||||
MediaRef,
|
||||
Name,
|
||||
NameType,
|
||||
Note,
|
||||
NoteType,
|
||||
Person,
|
||||
PersonRef,
|
||||
Place,
|
||||
PlaceName,
|
||||
PlaceType,
|
||||
RepoRef,
|
||||
Repository,
|
||||
RepositoryType,
|
||||
Source,
|
||||
SrcAttribute,
|
||||
SrcAttributeType,
|
||||
StyledText,
|
||||
StyledTextTag,
|
||||
StyledTextTagType,
|
||||
Surname,
|
||||
Tag,
|
||||
ChildRef,
|
||||
ChildRefType,
|
||||
Attribute,
|
||||
MediaRef,
|
||||
AttributeType,
|
||||
Url,
|
||||
UrlType,
|
||||
Address,
|
||||
EventRef,
|
||||
EventRoleType,
|
||||
RepoRef,
|
||||
FamilyRelType,
|
||||
LdsOrd,
|
||||
MediaRef,
|
||||
PersonRef,
|
||||
PlaceType,
|
||||
SrcAttribute,
|
||||
SrcAttributeType,
|
||||
)
|
||||
from ..privacybase import PrivacyBase
|
||||
from ..urlbase import UrlBase
|
||||
from ..addressbase import AddressBase
|
||||
from ..attrbase import AttributeBase
|
||||
from ..citationbase import CitationBase
|
||||
from ..const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from ..ldsordbase import LdsOrdBase
|
||||
from ..mediabase import MediaBase
|
||||
from ..notebase import NoteBase
|
||||
from ..citationbase import CitationBase
|
||||
from ..privacybase import PrivacyBase
|
||||
from ..surnamebase import SurnameBase
|
||||
from ..tagbase import TagBase
|
||||
from ..const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..urlbase import UrlBase
|
||||
|
||||
|
||||
class PrivacyBaseTest:
|
||||
@ -226,7 +224,9 @@ class UrlBaseCheck(unittest.TestCase):
|
||||
self.assertEqual(self.phoenix.serialize(), ref_url_list.serialize())
|
||||
|
||||
|
||||
class AddressCheck(unittest.TestCase, PrivacyBaseTest, NoteBaseTest, CitationBaseTest):
|
||||
class AddressCheck(
|
||||
unittest.TestCase, PrivacyBaseTest, NoteBaseTest, CitationBaseTest
|
||||
):
|
||||
def setUp(self):
|
||||
self.phoenix = Address()
|
||||
self.phoenix.set_city("Amsterdam")
|
||||
@ -361,7 +361,9 @@ class AttributeBaseCheck(unittest.TestCase):
|
||||
self.assertEqual(self.phoenix.serialize(), self.ref_list.serialize())
|
||||
|
||||
|
||||
class ChildRefCheck(unittest.TestCase, PrivacyBaseTest, NoteBaseTest, CitationBaseTest):
|
||||
class ChildRefCheck(
|
||||
unittest.TestCase, PrivacyBaseTest, NoteBaseTest, CitationBaseTest
|
||||
):
|
||||
def setUp(self):
|
||||
self.phoenix = ChildRef()
|
||||
self.phoenix.set_reference_handle("123456")
|
||||
@ -413,7 +415,9 @@ class EventCheck(
|
||||
self.ref_obj = Event(self.phoenix)
|
||||
|
||||
|
||||
class EventRefCheck(unittest.TestCase, PrivacyBaseTest, NoteBaseTest, AttrBaseTest):
|
||||
class EventRefCheck(
|
||||
unittest.TestCase, PrivacyBaseTest, NoteBaseTest, AttrBaseTest
|
||||
):
|
||||
def setUp(self):
|
||||
self.phoenix = EventRef()
|
||||
self.phoenix.set_reference_handle("123456")
|
||||
@ -763,7 +767,9 @@ class FamilyCheck(
|
||||
self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize())
|
||||
|
||||
|
||||
class LdsordCheck(unittest.TestCase, PrivacyBaseTest, NoteBaseTest, CitationBaseTest):
|
||||
class LdsordCheck(
|
||||
unittest.TestCase, PrivacyBaseTest, NoteBaseTest, CitationBaseTest
|
||||
):
|
||||
def setUp(self):
|
||||
self.phoenix = LdsOrd()
|
||||
self.phoenix.set_temple("London, England")
|
||||
@ -968,7 +974,11 @@ class MediaBaseCheck(unittest.TestCase):
|
||||
|
||||
|
||||
class MediaCheck(
|
||||
unittest.TestCase, PrivacyBaseTest, AttrBaseTest, NoteBaseTest, CitationBaseTest
|
||||
unittest.TestCase,
|
||||
PrivacyBaseTest,
|
||||
AttrBaseTest,
|
||||
NoteBaseTest,
|
||||
CitationBaseTest,
|
||||
):
|
||||
def setUp(self):
|
||||
self.phoenix = Media()
|
||||
@ -978,7 +988,11 @@ class MediaCheck(
|
||||
|
||||
|
||||
class MediaRefCheck(
|
||||
unittest.TestCase, PrivacyBaseTest, AttrBaseTest, CitationBaseTest, NoteBaseTest
|
||||
unittest.TestCase,
|
||||
PrivacyBaseTest,
|
||||
AttrBaseTest,
|
||||
CitationBaseTest,
|
||||
NoteBaseTest,
|
||||
):
|
||||
def setUp(self):
|
||||
self.phoenix = MediaRef()
|
||||
@ -1000,7 +1014,9 @@ class MediaRefCheck(
|
||||
self.assertEqual(self.phoenix.is_equivalent(self.titanic), EQUAL)
|
||||
|
||||
|
||||
class NameCheck(unittest.TestCase, PrivacyBaseTest, NoteBaseTest, CitationBaseTest):
|
||||
class NameCheck(
|
||||
unittest.TestCase, PrivacyBaseTest, NoteBaseTest, CitationBaseTest
|
||||
):
|
||||
def setUp(self):
|
||||
self.phoenix = Name()
|
||||
self.phoenix.set_first_name("Willem")
|
||||
@ -1079,7 +1095,8 @@ class NoteCheck(unittest.TestCase, PrivacyBaseTest):
|
||||
self.phoenix.add_tag("t1234")
|
||||
tag_list = self.phoenix.get_referenced_handles()
|
||||
self.assertEqual(
|
||||
tag_list, [("Event", "e0000"), ("Person", "i0001"), ("Tag", "t1234")]
|
||||
tag_list,
|
||||
[("Event", "e0000"), ("Person", "i0001"), ("Tag", "t1234")],
|
||||
)
|
||||
self.assertFalse(self.phoenix.has_handle_reference("Event", "e0001"))
|
||||
|
||||
@ -1729,7 +1746,9 @@ class RepoRefCheck(unittest.TestCase, PrivacyBaseTest, NoteBaseTest):
|
||||
self.assertEqual(self.phoenix.is_equivalent(self.titanic), EQUAL)
|
||||
|
||||
|
||||
class SourceCheck(unittest.TestCase, PrivacyBaseTest, NoteBaseTest, MediaBaseTest):
|
||||
class SourceCheck(
|
||||
unittest.TestCase, PrivacyBaseTest, NoteBaseTest, MediaBaseTest
|
||||
):
|
||||
def setUp(self):
|
||||
self.phoenix = Source()
|
||||
self.phoenix.set_title("Source 1")
|
||||
@ -1914,7 +1933,9 @@ class CitationBaseCheck(unittest.TestCase):
|
||||
self.assertEqual(self.phoenix.serialize(), self.obj_list.serialize())
|
||||
|
||||
|
||||
class CitationCheck(unittest.TestCase, PrivacyBaseTest, MediaBaseTest, NoteBaseTest):
|
||||
class CitationCheck(
|
||||
unittest.TestCase, PrivacyBaseTest, MediaBaseTest, NoteBaseTest
|
||||
):
|
||||
def setUp(self):
|
||||
self.phoenix = Citation()
|
||||
self.phoenix.set_reference_handle("123456")
|
||||
|
@ -20,27 +20,28 @@
|
||||
|
||||
""" Unittest for JSON schema """
|
||||
|
||||
import json
|
||||
import os
|
||||
import unittest
|
||||
import json
|
||||
|
||||
import jsonschema
|
||||
|
||||
from ...const import DATA_DIR
|
||||
from ...db.utils import import_as_dict
|
||||
from ...user import User
|
||||
from .. import (
|
||||
Person,
|
||||
Family,
|
||||
Citation,
|
||||
Event,
|
||||
Family,
|
||||
Media,
|
||||
Note,
|
||||
Person,
|
||||
Place,
|
||||
Repository,
|
||||
Source,
|
||||
Citation,
|
||||
Media,
|
||||
Note,
|
||||
Tag,
|
||||
)
|
||||
from ..serialize import to_json
|
||||
from ...db.utils import import_as_dict
|
||||
from ...const import DATA_DIR
|
||||
from ...user import User
|
||||
|
||||
TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests"))
|
||||
EXAMPLE = os.path.join(TEST_DIR, "example.gramps")
|
||||
|
@ -20,25 +20,25 @@
|
||||
|
||||
""" Unittest for to_json, from_json """
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from ...const import DATA_DIR
|
||||
from ...db.utils import import_as_dict
|
||||
from ...user import User
|
||||
from .. import (
|
||||
Person,
|
||||
Family,
|
||||
Event,
|
||||
Source,
|
||||
Place,
|
||||
Citation,
|
||||
Repository,
|
||||
Event,
|
||||
Family,
|
||||
Media,
|
||||
Note,
|
||||
Person,
|
||||
Place,
|
||||
Repository,
|
||||
Source,
|
||||
Tag,
|
||||
)
|
||||
from ..serialize import to_json, from_json
|
||||
from ...db.utils import import_as_dict
|
||||
from ...const import DATA_DIR
|
||||
from ...user import User
|
||||
from ..serialize import from_json, to_json
|
||||
|
||||
TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests"))
|
||||
EXAMPLE = os.path.join(TEST_DIR, "example.gramps")
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
import unittest
|
||||
from copy import deepcopy
|
||||
|
||||
from ..styledtext import StyledText
|
||||
from ..styledtexttag import StyledTextTag
|
||||
from ..styledtexttagtype import StyledTextTagType
|
||||
@ -32,7 +33,9 @@ class Test1(unittest.TestCase):
|
||||
T2 = StyledTextTag(StyledTextTagType(2), "v2", [(1, 3), (3, 5), (0, 7)])
|
||||
T3 = StyledTextTag(StyledTextTagType(0), "v3", [(0, 1)])
|
||||
T4 = StyledTextTag(StyledTextTagType(2), "v2", [(8, 10), (10, 12), (7, 14)])
|
||||
T5 = StyledTextTag(StyledTextTagType(2), "v2", [(19, 21), (21, 23), (18, 25)])
|
||||
T5 = StyledTextTag(
|
||||
StyledTextTagType(2), "v2", [(19, 21), (21, 23), (18, 25)]
|
||||
)
|
||||
|
||||
A = StyledText("123X456", [T1])
|
||||
B = StyledText("abcXdef", [T2])
|
||||
|
@ -26,22 +26,22 @@ Url class for Gramps.
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# standard python modules
|
||||
# Python modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from warnings import warn
|
||||
from urllib.parse import urlparse
|
||||
from warnings import warn
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .privacybase import PrivacyBase
|
||||
from .urltype import UrlType
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from .privacybase import PrivacyBase
|
||||
from .secondaryobj import SecondaryObject
|
||||
from .urltype import UrlType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -122,11 +122,9 @@ class Url(SecondaryObject, PrivacyBase):
|
||||
or self.desc != other.desc
|
||||
):
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.get_privacy() != other.get_privacy():
|
||||
return EQUAL
|
||||
else:
|
||||
return IDENTICAL
|
||||
if self.get_privacy() != other.get_privacy():
|
||||
return EQUAL
|
||||
return IDENTICAL
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
@ -196,9 +194,8 @@ class Url(SecondaryObject, PrivacyBase):
|
||||
"""
|
||||
if self.type == UrlType.EMAIL and not self.path.startswith("mailto:"):
|
||||
return "mailto:" + self.path
|
||||
elif self.type == UrlType.WEB_FTP and not self.path.startswith("ftp://"):
|
||||
if self.type == UrlType.WEB_FTP and not self.path.startswith("ftp://"):
|
||||
return "ftp://" + self.path
|
||||
elif self.parse_path().scheme == "":
|
||||
if self.parse_path().scheme == "":
|
||||
return "http://" + self.path
|
||||
else:
|
||||
return self.path
|
||||
return self.path
|
||||
|
@ -27,13 +27,13 @@ UrlBase class for Gramps.
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .const import EQUAL, IDENTICAL
|
||||
from .url import Url
|
||||
from .const import IDENTICAL, EQUAL
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# UrlBase classes
|
||||
# UrlBase class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class UrlBase:
|
||||
@ -98,7 +98,7 @@ class UrlBase:
|
||||
equi = url.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
if equi == EQUAL:
|
||||
url.merge(addendum)
|
||||
break
|
||||
else:
|
||||
@ -130,5 +130,4 @@ class UrlBase:
|
||||
if url in self.urls:
|
||||
self.urls.remove(url)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
@ -27,13 +27,22 @@ URL types
|
||||
# Gramps modules
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
from .grampstype import GrampsType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
from .grampstype import GrampsType
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# UrlType class
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
class UrlType(GrampsType):
|
||||
"""
|
||||
Class encapsulating the type of a url.
|
||||
"""
|
||||
|
||||
UNKNOWN = -1
|
||||
CUSTOM = 0
|
||||
EMAIL = 1
|
||||
|
Loading…
Reference in New Issue
Block a user