Improve pylint score to above 9 for most gen.lib objects
This commit is contained in:
parent
e013122afc
commit
b8a38cd5e5
@ -28,7 +28,7 @@ AttributeRootBase class for Gramps.
|
|||||||
# Gramps modules
|
# Gramps modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from .attribute import Attribute
|
from .attribute import Attribute, AttributeRoot
|
||||||
from .srcattribute import SrcAttribute
|
from .srcattribute import SrcAttribute
|
||||||
from .const import IDENTICAL, EQUAL
|
from .const import IDENTICAL, EQUAL
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ class AttributeRootBase(object):
|
|||||||
"""
|
"""
|
||||||
Base class for attribute-aware objects.
|
Base class for attribute-aware objects.
|
||||||
"""
|
"""
|
||||||
_CLASS = None
|
_CLASS = AttributeRoot
|
||||||
|
|
||||||
def __init__(self, source=None):
|
def __init__(self, source=None):
|
||||||
"""
|
"""
|
||||||
|
@ -34,30 +34,30 @@ import math
|
|||||||
# Constants
|
# Constants
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
_GRG_SDN_OFFSET = 32045
|
_GRG_SDN_OFFSET = 32045
|
||||||
_GRG_DAYS_PER_5_MONTHS = 153
|
_GRG_DAYS_PER_5_MONTHS = 153
|
||||||
_GRG_DAYS_PER_4_YEARS = 1461
|
_GRG_DAYS_PER_4_YEARS = 1461
|
||||||
_GRG_DAYS_PER_400_YEARS = 146097
|
_GRG_DAYS_PER_400_YEARS = 146097
|
||||||
|
|
||||||
_JLN_SDN_OFFSET = 32083
|
_JLN_SDN_OFFSET = 32083
|
||||||
_JLN_DAYS_PER_5_MONTHS = 153
|
_JLN_DAYS_PER_5_MONTHS = 153
|
||||||
_JLN_DAYS_PER_4_YEARS = 1461
|
_JLN_DAYS_PER_4_YEARS = 1461
|
||||||
|
|
||||||
_HBR_HALAKIM_PER_HOUR = 1080
|
_HBR_HALAKIM_PER_HOUR = 1080
|
||||||
_HBR_HALAKIM_PER_DAY = 25920
|
_HBR_HALAKIM_PER_DAY = 25920
|
||||||
_HBR_HALAKIM_PER_LUNAR_CYCLE = 29 * _HBR_HALAKIM_PER_DAY + 13753
|
_HBR_HALAKIM_PER_LUNAR_CYCLE = 29 * _HBR_HALAKIM_PER_DAY + 13753
|
||||||
_HBR_HALAKIM_PER_METONIC_CYCLE = _HBR_HALAKIM_PER_LUNAR_CYCLE * (12 * 19 + 7)
|
_HBR_HALAKIM_PER_METONIC_CYCLE = _HBR_HALAKIM_PER_LUNAR_CYCLE * (12 * 19 + 7)
|
||||||
_HBR_SDN_OFFSET = 347997
|
_HBR_SDN_OFFSET = 347997
|
||||||
_HBR_NEW_MOON_OF_CREATION = 31524
|
_HBR_NEW_MOON_OF_CREATION = 31524
|
||||||
_HBR_NOON = 18 * _HBR_HALAKIM_PER_HOUR
|
_HBR_NOON = 18 * _HBR_HALAKIM_PER_HOUR
|
||||||
_HBR_AM3_11_20 = (9 * _HBR_HALAKIM_PER_HOUR) + 204
|
_HBR_AM3_11_20 = (9 * _HBR_HALAKIM_PER_HOUR) + 204
|
||||||
_HBR_AM9_32_43 = (15 * _HBR_HALAKIM_PER_HOUR) + 589
|
_HBR_AM9_32_43 = (15 * _HBR_HALAKIM_PER_HOUR) + 589
|
||||||
|
|
||||||
_HBR_SUNDAY = 0
|
_HBR_SUNDAY = 0
|
||||||
_HBR_MONDAY = 1
|
_HBR_MONDAY = 1
|
||||||
_HBR_TUESDAY = 2
|
_HBR_TUESDAY = 2
|
||||||
_HBR_WEDNESDAY = 3
|
_HBR_WEDNESDAY = 3
|
||||||
_HBR_FRIDAY = 5
|
_HBR_FRIDAY = 5
|
||||||
|
|
||||||
_HBR_MONTHS_PER_YEAR = [
|
_HBR_MONTHS_PER_YEAR = [
|
||||||
12, 12, 13, 12, 12, 13, 12, 13, 12, 12,
|
12, 12, 13, 12, 12, 13, 12, 13, 12, 12,
|
||||||
@ -69,25 +69,25 @@ _HBR_YEAR_OFFSET = [
|
|||||||
136, 148, 160, 173, 185, 197, 210, 222
|
136, 148, 160, 173, 185, 197, 210, 222
|
||||||
]
|
]
|
||||||
|
|
||||||
_FR_SDN_OFFSET = 2375474
|
_FR_SDN_OFFSET = 2375474
|
||||||
_FR_DAYS_PER_4_YEARS = 1461
|
_FR_DAYS_PER_4_YEARS = 1461
|
||||||
_FR_DAYS_PER_MONTH = 30
|
_FR_DAYS_PER_MONTH = 30
|
||||||
_PRS_EPOCH = 1948320.5
|
_PRS_EPOCH = 1948320.5
|
||||||
_ISM_EPOCH = 1948439.5
|
_ISM_EPOCH = 1948439.5
|
||||||
|
|
||||||
def _tishri1(metonic_year, molad_day, molad_halakim):
|
def _tishri1(metonic_year, molad_day, molad_halakim):
|
||||||
|
|
||||||
tishri1 = molad_day
|
tishri1 = molad_day
|
||||||
dow = tishri1 % 7
|
dow = tishri1 % 7
|
||||||
leap_year = metonic_year in [ 2, 5, 7, 10, 13, 16, 18]
|
leap_year = metonic_year in [2, 5, 7, 10, 13, 16, 18]
|
||||||
last_was_leap_year = metonic_year in [ 3, 6, 8, 11, 14, 17, 0]
|
last_was_leap_year = metonic_year in [3, 6, 8, 11, 14, 17, 0]
|
||||||
|
|
||||||
# Apply rules 2, 3 and 4.
|
# Apply rules 2, 3 and 4.
|
||||||
if ((molad_halakim >= _HBR_NOON) or
|
if ((molad_halakim >= _HBR_NOON) or
|
||||||
((not leap_year) and dow == _HBR_TUESDAY and
|
((not leap_year) and dow == _HBR_TUESDAY and
|
||||||
molad_halakim >= _HBR_AM3_11_20) or
|
molad_halakim >= _HBR_AM3_11_20) or
|
||||||
(last_was_leap_year and dow == _HBR_MONDAY
|
(last_was_leap_year and dow == _HBR_MONDAY
|
||||||
and molad_halakim >= _HBR_AM9_32_43)) :
|
and molad_halakim >= _HBR_AM9_32_43)):
|
||||||
tishri1 += 1
|
tishri1 += 1
|
||||||
dow += 1
|
dow += 1
|
||||||
if dow == 7:
|
if dow == 7:
|
||||||
@ -133,8 +133,8 @@ def _tishri_molad(input_day):
|
|||||||
break
|
break
|
||||||
|
|
||||||
molad_halakim += (_HBR_HALAKIM_PER_LUNAR_CYCLE
|
molad_halakim += (_HBR_HALAKIM_PER_LUNAR_CYCLE
|
||||||
* _HBR_MONTHS_PER_YEAR[metonic_year])
|
* _HBR_MONTHS_PER_YEAR[metonic_year])
|
||||||
molad_day += molad_halakim // _HBR_HALAKIM_PER_DAY
|
molad_day += molad_halakim // _HBR_HALAKIM_PER_DAY
|
||||||
molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
|
molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
|
||||||
|
|
||||||
return (metonic_cycle, metonic_year, molad_day, molad_halakim)
|
return (metonic_cycle, metonic_year, molad_day, molad_halakim)
|
||||||
@ -182,9 +182,9 @@ def _start_of_year(year):
|
|||||||
molad_day = molad_day + (molad_halakim // _HBR_HALAKIM_PER_DAY)
|
molad_day = molad_day + (molad_halakim // _HBR_HALAKIM_PER_DAY)
|
||||||
molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
|
molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
|
||||||
|
|
||||||
pTishri1 = _tishri1(metonic_year, molad_day, molad_halakim)
|
ptishri1 = _tishri1(metonic_year, molad_day, molad_halakim)
|
||||||
|
|
||||||
return (metonic_cycle, metonic_year, molad_day, molad_halakim, pTishri1)
|
return (metonic_cycle, metonic_year, molad_day, molad_halakim, ptishri1)
|
||||||
|
|
||||||
def hebrew_sdn(year, month, day):
|
def hebrew_sdn(year, month, day):
|
||||||
"""Convert a Jewish calendar date to an SDN number."""
|
"""Convert a Jewish calendar date to an SDN number."""
|
||||||
@ -225,16 +225,16 @@ def hebrew_sdn(year, month, day):
|
|||||||
molad_day, molad_halakim, tishri1_after) = _start_of_year(year+1)
|
molad_day, molad_halakim, tishri1_after) = _start_of_year(year+1)
|
||||||
|
|
||||||
if _HBR_MONTHS_PER_YEAR[(year - 1) % 19] == 12:
|
if _HBR_MONTHS_PER_YEAR[(year - 1) % 19] == 12:
|
||||||
length_of_adarI_andII = 29
|
length_of_adar_1and2 = 29
|
||||||
else:
|
else:
|
||||||
length_of_adarI_andII = 59
|
length_of_adar_1and2 = 59
|
||||||
|
|
||||||
if month == 4:
|
if month == 4:
|
||||||
sdn = tishri1_after + day - length_of_adarI_andII - 237
|
sdn = tishri1_after + day - length_of_adar_1and2 - 237
|
||||||
elif month == 5:
|
elif month == 5:
|
||||||
sdn = tishri1_after + day - length_of_adarI_andII - 208
|
sdn = tishri1_after + day - length_of_adar_1and2 - 208
|
||||||
else:
|
else:
|
||||||
sdn = tishri1_after + day - length_of_adarI_andII - 178
|
sdn = tishri1_after + day - length_of_adar_1and2 - 178
|
||||||
else:
|
else:
|
||||||
# It is Adar II or later - don't need the year length.
|
# It is Adar II or later - don't need the year length.
|
||||||
(metonic_cycle, metonic_year,
|
(metonic_cycle, metonic_year,
|
||||||
@ -284,7 +284,7 @@ def hebrew_ymd(sdn):
|
|||||||
# Tishri 1 of the next year.
|
# Tishri 1 of the next year.
|
||||||
|
|
||||||
halakim += (_HBR_HALAKIM_PER_LUNAR_CYCLE
|
halakim += (_HBR_HALAKIM_PER_LUNAR_CYCLE
|
||||||
* _HBR_MONTHS_PER_YEAR[metonic_year])
|
* _HBR_MONTHS_PER_YEAR[metonic_year])
|
||||||
day1 += halakim // _HBR_HALAKIM_PER_DAY
|
day1 += halakim // _HBR_HALAKIM_PER_DAY
|
||||||
halakim = halakim % _HBR_HALAKIM_PER_DAY
|
halakim = halakim % _HBR_HALAKIM_PER_DAY
|
||||||
tishri1_after = _tishri1((metonic_year + 1) % 19, day1, halakim)
|
tishri1_after = _tishri1((metonic_year + 1) % 19, day1, halakim)
|
||||||
@ -348,7 +348,7 @@ def hebrew_ymd(sdn):
|
|||||||
|
|
||||||
year_length = tishri1_after - tishri1
|
year_length = tishri1_after - tishri1
|
||||||
day = input_day - tishri1 - 29
|
day = input_day - tishri1 - 29
|
||||||
if year_length == 355 or year_length == 385 :
|
if year_length == 355 or year_length == 385:
|
||||||
# Heshvan has 30 days
|
# Heshvan has 30 days
|
||||||
if day <= 30:
|
if day <= 30:
|
||||||
month = 2
|
month = 2
|
||||||
@ -378,7 +378,7 @@ def julian_sdn(year, month, day):
|
|||||||
month -= 3
|
month -= 3
|
||||||
else:
|
else:
|
||||||
month += 9
|
month += 9
|
||||||
year -= 1
|
year -= 1
|
||||||
|
|
||||||
return (year * _JLN_DAYS_PER_4_YEARS) // 4 \
|
return (year * _JLN_DAYS_PER_4_YEARS) // 4 \
|
||||||
+ (month * _JLN_DAYS_PER_5_MONTHS + 2) // 5 \
|
+ (month * _JLN_DAYS_PER_5_MONTHS + 2) // 5 \
|
||||||
@ -423,13 +423,13 @@ def gregorian_sdn(year, month, day):
|
|||||||
month -= 3
|
month -= 3
|
||||||
else:
|
else:
|
||||||
month += 9
|
month += 9
|
||||||
year -= 1
|
year -= 1
|
||||||
|
|
||||||
return(((year // 100) * _GRG_DAYS_PER_400_YEARS) // 4
|
return(((year // 100) * _GRG_DAYS_PER_400_YEARS) // 4
|
||||||
+ ((year % 100) * _GRG_DAYS_PER_4_YEARS) // 4
|
+ ((year % 100) * _GRG_DAYS_PER_4_YEARS) // 4
|
||||||
+ (month * _GRG_DAYS_PER_5_MONTHS + 2) // 5
|
+ (month * _GRG_DAYS_PER_5_MONTHS + 2) // 5
|
||||||
+ day
|
+ day
|
||||||
- _GRG_SDN_OFFSET )
|
- _GRG_SDN_OFFSET)
|
||||||
|
|
||||||
def gregorian_ymd(sdn):
|
def gregorian_ymd(sdn):
|
||||||
"""Convert an SDN number to a gregorian date."""
|
"""Convert an SDN number to a gregorian date."""
|
||||||
@ -449,7 +449,7 @@ def gregorian_ymd(sdn):
|
|||||||
day = (temp % _GRG_DAYS_PER_5_MONTHS) // 5 + 1
|
day = (temp % _GRG_DAYS_PER_5_MONTHS) // 5 + 1
|
||||||
|
|
||||||
# Convert to the normal beginning of the year
|
# Convert to the normal beginning of the year
|
||||||
if month < 10 :
|
if month < 10:
|
||||||
month = month + 3
|
month = month + 3
|
||||||
else:
|
else:
|
||||||
year = year + 1
|
year = year + 1
|
||||||
@ -560,12 +560,12 @@ def swedish_sdn(year, month, day):
|
|||||||
def swedish_ymd(sdn):
|
def swedish_ymd(sdn):
|
||||||
"""Convert an SDN number to a Swedish calendar date."""
|
"""Convert an SDN number to a Swedish calendar date."""
|
||||||
if sdn == 2346425:
|
if sdn == 2346425:
|
||||||
return (1712, 2, 30)
|
return (1712, 2, 30)
|
||||||
# Swedish Calendar
|
# Swedish Calendar
|
||||||
elif 2342042 <= sdn < 2346425:
|
elif 2342042 <= sdn < 2346425:
|
||||||
return julian_ymd(sdn+1)
|
return julian_ymd(sdn+1)
|
||||||
# Gregorian Calendar (1753-03-01)
|
# Gregorian Calendar (1753-03-01)
|
||||||
elif 2361390 <= sdn:
|
elif sdn >= 2361390:
|
||||||
return gregorian_ymd(sdn)
|
return gregorian_ymd(sdn)
|
||||||
else:
|
else:
|
||||||
return julian_ymd(sdn)
|
return julian_ymd(sdn)
|
||||||
|
@ -125,14 +125,14 @@ class BasicPrimaryObject(TableObject, PrivacyBase, TagBase):
|
|||||||
"""
|
"""
|
||||||
Return labels.
|
Return labels.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
return {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
Return schema.
|
Return schema.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
return {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_label(cls, field, _):
|
def get_label(cls, field, _):
|
||||||
|
@ -105,7 +105,7 @@ class SecondaryObject(BaseObject):
|
|||||||
"""
|
"""
|
||||||
Return labels.
|
Return labels.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
return {}
|
||||||
|
|
||||||
def get_label(self, field, _):
|
def get_label(self, field, _):
|
||||||
"""
|
"""
|
||||||
|
@ -53,19 +53,3 @@ class SrcAttribute(AttributeRoot):
|
|||||||
else:
|
else:
|
||||||
self.type = SrcAttributeType()
|
self.type = SrcAttributeType()
|
||||||
self.value = ""
|
self.value = ""
|
||||||
|
|
||||||
|
|
||||||
def get_text_data_list(self):
|
|
||||||
"""
|
|
||||||
Return the list of all textual attributes of the object.
|
|
||||||
|
|
||||||
:returns: Returns the list of all textual attributes of the object.
|
|
||||||
:rtype: list
|
|
||||||
"""
|
|
||||||
sat = SrcAttributeType()
|
|
||||||
if self.type == sat.SRCTYPE:
|
|
||||||
#we convert to the native language if possible
|
|
||||||
if self.value and self.value in sat.E2I_SRCTYPEMAP:
|
|
||||||
return [sat.I2S_SRCTYPEMAP[sat.E2I_SRCTYPEMAP[self.value]]]
|
|
||||||
return [self.value]
|
|
||||||
|
|
||||||
|
@ -88,8 +88,11 @@ class StyledText(object):
|
|||||||
|
|
||||||
# special methods
|
# special methods
|
||||||
|
|
||||||
def __str__(self): return self._string.__str__()
|
def __str__(self):
|
||||||
def __repr__(self): return self._string.__repr__()
|
return self._string.__str__()
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return self._string.__repr__()
|
||||||
|
|
||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
"""Implement '+' operation on the class.
|
"""Implement '+' operation on the class.
|
||||||
@ -104,12 +107,12 @@ class StyledText(object):
|
|||||||
|
|
||||||
if isinstance(other, StyledText):
|
if isinstance(other, StyledText):
|
||||||
# need to join strings and merge tags
|
# need to join strings and merge tags
|
||||||
for tag in other._tags:
|
for tag in other.tags:
|
||||||
tag.ranges = [(start + offset, end + offset)
|
tag.ranges = [(start + offset, end + offset)
|
||||||
for (start, end) in tag.ranges]
|
for (start, end) in tag.ranges]
|
||||||
|
|
||||||
return self.__class__("".join([self._string, other._string]),
|
return self.__class__("".join([self._string, other.string]),
|
||||||
self._tags + other._tags)
|
self._tags + other.tags)
|
||||||
elif isinstance(other, str):
|
elif isinstance(other, str):
|
||||||
# tags remain the same, only text becomes longer
|
# tags remain the same, only text becomes longer
|
||||||
return self.__class__("".join([self._string, other]), self._tags)
|
return self.__class__("".join([self._string, other]), self._tags)
|
||||||
@ -118,13 +121,13 @@ class StyledText(object):
|
|||||||
self._tags)
|
self._tags)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return self._string == other._string and self._tags == other._tags
|
return self._string == other.string and self._tags == other.tags
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return self._string != other._string or self._tags != other._tags
|
return self._string != other.string or self._tags != other.tags
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
return self._string < other._string
|
return self._string < other.string
|
||||||
|
|
||||||
def __le__(self, other):
|
def __le__(self, other):
|
||||||
return self.__lt__(other) or self.__eq__(other)
|
return self.__lt__(other) or self.__eq__(other)
|
||||||
@ -138,24 +141,25 @@ class StyledText(object):
|
|||||||
def __mod__(self, other):
|
def __mod__(self, other):
|
||||||
"""Implement '%' operation on the class."""
|
"""Implement '%' operation on the class."""
|
||||||
|
|
||||||
# test whether the formatting operation is valid at all
|
# This will raise an exception if the formatting operation is invalid
|
||||||
self._string % other
|
self._string % other
|
||||||
|
|
||||||
result = self.__class__(self._string, self._tags)
|
result = self.__class__(self._string, self._tags)
|
||||||
|
|
||||||
i0 = 0
|
start = 0
|
||||||
while True:
|
while True:
|
||||||
i1 = result._string.find('%', i0)
|
idx1 = result.string.find('%', start)
|
||||||
if i1 < 0:
|
if idx1 < 0:
|
||||||
break
|
break
|
||||||
if result._string[i1+1] == '(':
|
if result.string[idx1+1] == '(':
|
||||||
i2 = result._string.find(')', i1+3)
|
idx2 = result.string.find(')', idx1+3)
|
||||||
param_name = result._string[i1+2:i2]
|
param_name = result.string[idx1+2:idx2]
|
||||||
else:
|
else:
|
||||||
i2 = i1
|
idx2 = idx1
|
||||||
param_name = None
|
param_name = None
|
||||||
for i3 in range(i2+1, len(result._string)):
|
end = idx2 + 1
|
||||||
if result._string[i3] in 'diouxXeEfFgGcrs%':
|
for end in range(idx2+1, len(result.string)):
|
||||||
|
if result.string[end] in 'diouxXeEfFgGcrs%':
|
||||||
break
|
break
|
||||||
if param_name is not None:
|
if param_name is not None:
|
||||||
param = other[param_name]
|
param = other[param_name]
|
||||||
@ -165,10 +169,12 @@ class StyledText(object):
|
|||||||
else:
|
else:
|
||||||
param = other
|
param = other
|
||||||
if not isinstance(param, StyledText):
|
if not isinstance(param, StyledText):
|
||||||
param = StyledText('%' + result._string[i2+1:i3+1] % param)
|
param_type = '%' + result.string[idx2+1:end+1]
|
||||||
(before, after) = result.split(result._string[i1:i3+1], 1)
|
param = StyledText(param_type % param)
|
||||||
result = before + param + after
|
parts = result.split(result.string[idx1:end+1], 1)
|
||||||
i0 = i3 + 1
|
if len(parts) == 2:
|
||||||
|
result = parts[0] + param + parts[1]
|
||||||
|
start = end + 1
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -194,7 +200,7 @@ class StyledText(object):
|
|||||||
|
|
||||||
for text in seq:
|
for text in seq:
|
||||||
if isinstance(text, StyledText):
|
if isinstance(text, StyledText):
|
||||||
for tag in text._tags:
|
for tag in text.tags:
|
||||||
tag.ranges = [(start + offset, end + offset)
|
tag.ranges = [(start + offset, end + offset)
|
||||||
for (start, end) in tag.ranges]
|
for (start, end) in tag.ranges]
|
||||||
new_tags += [tag]
|
new_tags += [tag]
|
||||||
@ -320,8 +326,8 @@ class StyledText(object):
|
|||||||
"""
|
"""
|
||||||
default = StyledText()
|
default = StyledText()
|
||||||
return (struct.get("string", default.string),
|
return (struct.get("string", default.string),
|
||||||
[StyledTextTag.from_struct(t)
|
[StyledTextTag.from_struct(t)
|
||||||
for t in struct.get("tags", default.tags)])
|
for t in struct.get("tags", default.tags)])
|
||||||
|
|
||||||
def unserialize(self, data):
|
def unserialize(self, data):
|
||||||
"""
|
"""
|
||||||
|
@ -78,6 +78,55 @@ class TableObject(BaseObject):
|
|||||||
self.handle = None
|
self.handle = None
|
||||||
self.change = 0
|
self.change = 0
|
||||||
|
|
||||||
|
def serialize(self):
|
||||||
|
"""
|
||||||
|
Convert the object to a serialized tuple of data.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def unserialize(self, data):
|
||||||
|
"""
|
||||||
|
Convert a serialized tuple of data to an object.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def to_struct(self):
|
||||||
|
"""
|
||||||
|
Convert the data held in this object to a structure (eg,
|
||||||
|
struct) that represents all the data elements.
|
||||||
|
|
||||||
|
This method is used to recursively convert the object into a
|
||||||
|
self-documenting form that can easily be used for various
|
||||||
|
purposes, including diffs and queries.
|
||||||
|
|
||||||
|
These structures may be primitive Python types (string,
|
||||||
|
integer, boolean, etc.) or complex Python types (lists,
|
||||||
|
tuples, or dicts). If the return type is a dict, then the keys
|
||||||
|
of the dict match the fieldname of the object. If the return
|
||||||
|
struct (or value of a dict key) is a list, then it is a list
|
||||||
|
of structs. Otherwise, the struct is just the value of the
|
||||||
|
attribute.
|
||||||
|
|
||||||
|
:returns: Returns a struct containing the data of the object.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def from_struct(self, struct):
|
||||||
|
"""
|
||||||
|
Given a struct data representation, return an object of this type.
|
||||||
|
|
||||||
|
These structures may be primitive Python types (string,
|
||||||
|
integer, boolean, etc.) or complex Python types (lists,
|
||||||
|
tuples, or dicts). If the return type is a dict, then the keys
|
||||||
|
of the dict match the fieldname of the object. If the return
|
||||||
|
struct (or value of a dict key) is a list, then it is a list
|
||||||
|
of structs. Otherwise, the struct is just the value of the
|
||||||
|
attribute.
|
||||||
|
|
||||||
|
:returns: Returns an object of this type.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_change_time(self):
|
def get_change_time(self):
|
||||||
"""
|
"""
|
||||||
Return the time that the data was last changed.
|
Return the time that the data was last changed.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user