* src/DataViews/_MediaView.py: pylint
* src/DataViews/_RepositoryView.py: pylint * src/DataViews/_SourceView.py: pylint * src/DataViews/_EventView.py: pylint * src/DataViews/_FamilyList.py: pylint * src/DataViews/_PlaceView.py: pylint * src/DataViews/__init__.py: pylint * src/DataViews/_PersonView.py: pylint * src/DataViews/Makefile.am: pylint * src/DataViews/_RelationView.py: pylint * src/RelLib/_CalSdn.py: pylint * src/RelLib/_Person.py: pylint * src/RelLib/_Family.py: pylint * src/RelLib/_EventType.py: pylint * src/RelLib/_GrampsType.py: pylint * src/RelLib/_Event.py: pylint * src/RelLib/_LdsOrd.py: pylint * src/PageView.py: pylint svn: r7885
This commit is contained in:
+22
-10
@@ -20,6 +20,10 @@
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Provides calendar to sdn (serial date number) conversion.
|
||||
"""
|
||||
|
||||
__revision__ = "$Revision$"
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@@ -100,11 +104,12 @@ def _tishri1(metonic_year, molad_day, molad_halakim):
|
||||
return tishri1
|
||||
|
||||
def _tishri_molad(input_day):
|
||||
|
||||
# Estimate the metonic cycle number. Note that this may be an under
|
||||
# estimate because there are 6939.6896 days in a metonic cycle not
|
||||
# 6940, but it will never be an over estimate. The loop below will
|
||||
# correct for any error in this estimate. */
|
||||
"""
|
||||
Estimate the metonic cycle number. Note that this may be an under
|
||||
estimate because there are 6939.6896 days in a metonic cycle not
|
||||
6940, but it will never be an over estimate. The loop below will
|
||||
correct for any error in this estimate.
|
||||
"""
|
||||
|
||||
metonic_cycle = (input_day + 310) / 6940
|
||||
|
||||
@@ -124,7 +129,7 @@ def _tishri_molad(input_day):
|
||||
molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
|
||||
|
||||
# Find the molad of Tishri closest to this date.
|
||||
|
||||
|
||||
for metonic_year in range(0, 18):
|
||||
if molad_day > input_day - 74:
|
||||
break
|
||||
@@ -134,12 +139,13 @@ def _tishri_molad(input_day):
|
||||
molad_day = molad_day + (molad_halakim / _HBR_HALAKIM_PER_DAY)
|
||||
molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
|
||||
else:
|
||||
metonic_year = metonic_year + 1
|
||||
metonic_year += 1
|
||||
return (metonic_cycle, metonic_year, molad_day, molad_halakim)
|
||||
|
||||
def _molad_of_metonic_cycle(metonic_cycle):
|
||||
|
||||
# Start with the time of the first molad after creation.
|
||||
"""
|
||||
Start with the time of the first molad after creation.
|
||||
"""
|
||||
|
||||
r1 = _HBR_NEW_MOON_OF_CREATION
|
||||
|
||||
@@ -167,7 +173,9 @@ def _molad_of_metonic_cycle(metonic_cycle):
|
||||
return (molad_day, molad_halakim)
|
||||
|
||||
def _start_of_year(year):
|
||||
|
||||
"""
|
||||
calculate the start of the year.
|
||||
"""
|
||||
metonic_cycle = (year - 1) / 19;
|
||||
metonic_year = (year - 1) % 19;
|
||||
(molad_day, molad_halakim) = _molad_of_metonic_cycle(metonic_cycle)
|
||||
@@ -473,6 +481,7 @@ def french_ymd(sdn):
|
||||
return (year, month, day)
|
||||
|
||||
def persian_sdn(year, month, day):
|
||||
"""Converts an Persian date to an SDN number"""
|
||||
if year >= 0:
|
||||
epbase = year - 474
|
||||
else:
|
||||
@@ -491,6 +500,7 @@ def persian_sdn(year, month, day):
|
||||
return int(math.ceil(v1 + v2 + v3 + v4 + _PRS_EPOCH - 1))
|
||||
|
||||
def persian_ymd(sdn):
|
||||
"""Converts an SDN number to a Persian calendar date"""
|
||||
sdn = math.floor(sdn) + 0.5
|
||||
|
||||
depoch = sdn - 2121446
|
||||
@@ -516,6 +526,7 @@ def persian_ymd(sdn):
|
||||
return (int(year), int(month), int(day))
|
||||
|
||||
def islamic_sdn(year, month, day):
|
||||
"""Converts 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)
|
||||
@@ -523,6 +534,7 @@ def islamic_sdn(year, month, day):
|
||||
return int(math.ceil((day + v1 + v2 + v3 + _ISM_EPOCH) - 1))
|
||||
|
||||
def islamic_ymd(sdn):
|
||||
"""Converts 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))
|
||||
|
||||
@@ -126,15 +126,44 @@ class Event(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
NoteBase.unserialize(self, note)
|
||||
|
||||
def _has_handle_reference(self, classname, handle):
|
||||
"""
|
||||
Returns True if the object has reference to a given handle
|
||||
of given primary object type.
|
||||
|
||||
@param classname: The name of the primary object class.
|
||||
@type classname: str
|
||||
@param handle: The handle to be checked.
|
||||
@type handle: str
|
||||
@return: Returns whether the object has reference to this handle of this object type.
|
||||
@rtype: bool
|
||||
"""
|
||||
if classname == 'Place':
|
||||
return self.place == handle
|
||||
return False
|
||||
|
||||
def _remove_handle_references(self, classname, handle_list):
|
||||
"""
|
||||
Removes all references in this object to object handles in the list.
|
||||
|
||||
@param classname: The name of the primary object class.
|
||||
@type classname: str
|
||||
@param handle_list: The list of handles to be removed.
|
||||
@type handle_list: str
|
||||
"""
|
||||
if classname == 'Place' and self.place in handle_list:
|
||||
self.place = ""
|
||||
|
||||
def _replace_handle_reference(self, classname, old_handle, new_handle):
|
||||
"""
|
||||
Replaces all references to old handle with those to the new handle.
|
||||
|
||||
@param classname: The name of the primary object class.
|
||||
@type classname: str
|
||||
@param old_handle: The handle to be replaced.
|
||||
@type old_handle: str
|
||||
@param new_handle: The handle to replace the old one with.
|
||||
@type new_handle: str
|
||||
"""
|
||||
if classname == 'Place' and self.place == old_handle:
|
||||
self.place = new_handle
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@ from _GrampsType import GrampsType, init_map
|
||||
from gettext import gettext as _
|
||||
|
||||
class EventType(GrampsType):
|
||||
|
||||
"""
|
||||
Event types
|
||||
"""
|
||||
UNKNOWN = -1
|
||||
CUSTOM = 0
|
||||
MARRIAGE = 1
|
||||
|
||||
@@ -146,6 +146,17 @@ class Family(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
LdsOrdBase.unserialize(self, lds_seal_list)
|
||||
|
||||
def _has_handle_reference(self, classname, handle):
|
||||
"""
|
||||
Returns True if the object has reference to a given handle
|
||||
of given primary object type.
|
||||
|
||||
@param classname: The name of the primary object class.
|
||||
@type classname: str
|
||||
@param handle: The handle to be checked.
|
||||
@type handle: str
|
||||
@return: Returns whether the object has reference to this handle of this object type.
|
||||
@rtype: bool
|
||||
"""
|
||||
if classname == 'Event':
|
||||
return handle in [ref.ref for ref in self.event_ref_list]
|
||||
elif classname == 'Person':
|
||||
@@ -156,6 +167,14 @@ class Family(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
return False
|
||||
|
||||
def _remove_handle_references(self, classname, handle_list):
|
||||
"""
|
||||
Removes all references in this object to object handles in the list.
|
||||
|
||||
@param classname: The name of the primary object class.
|
||||
@type classname: str
|
||||
@param handle_list: The list of handles to be removed.
|
||||
@type handle_list: str
|
||||
"""
|
||||
if classname == 'Event':
|
||||
new_list = [ ref for ref in self.event_ref_list \
|
||||
if ref.ref not in handle_list ]
|
||||
@@ -174,6 +193,16 @@ class Family(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
x.place = None
|
||||
|
||||
def _replace_handle_reference(self, classname, old_handle, new_handle):
|
||||
"""
|
||||
Replaces all references to old handle with those to the new handle.
|
||||
|
||||
@param classname: The name of the primary object class.
|
||||
@type classname: str
|
||||
@param old_handle: The handle to be replaced.
|
||||
@type old_handle: str
|
||||
@param new_handle: The handle to replace the old one with.
|
||||
@type new_handle: str
|
||||
"""
|
||||
if classname == 'Event':
|
||||
handle_list = [ref.ref for ref in self.event_ref_list]
|
||||
while old_handle in handle_list:
|
||||
|
||||
@@ -29,6 +29,9 @@ __revision__ = "$Revision$"
|
||||
from gettext import gettext as _
|
||||
|
||||
def init_map(data, key_col, data_col):
|
||||
"""
|
||||
Initializes the map, building a new map from the specified columns.
|
||||
"""
|
||||
new_data = {}
|
||||
for item in data:
|
||||
new_data[item[key_col]] = item[data_col]
|
||||
@@ -47,6 +50,9 @@ class GrampsType:
|
||||
_E2IMAP = init_map(_DATAMAP, 2, 0)
|
||||
|
||||
def __init__(self, value=None):
|
||||
"""
|
||||
Creates a new type, initialize the value from one of several possible states.
|
||||
"""
|
||||
self.value = None
|
||||
self.string = None
|
||||
self.set(value)
|
||||
|
||||
@@ -199,9 +199,21 @@ class LdsOrd(SecondaryObject, SourceBase, NoteBase,
|
||||
return self.source_list
|
||||
|
||||
def get_type(self):
|
||||
"""
|
||||
Returns the type of the Event.
|
||||
|
||||
@return: Type of the Event
|
||||
@rtype: tuple
|
||||
"""
|
||||
return self.type
|
||||
|
||||
def set_type(self, ord_type):
|
||||
"""
|
||||
Sets the type of the LdsOrd to the passed (int,str) tuple.
|
||||
|
||||
@param ord_type: Type to assign to the LdsOrd
|
||||
@type ord_type: tuple
|
||||
"""
|
||||
self.type = ord_type
|
||||
|
||||
def set_family_handle(self, family):
|
||||
|
||||
@@ -199,6 +199,17 @@ class Person(PrimaryObject, SourceBase, NoteBase, MediaBase,
|
||||
NoteBase.unserialize(self, note)
|
||||
|
||||
def _has_handle_reference(self, classname, handle):
|
||||
"""
|
||||
Returns True if the object has reference to a given handle
|
||||
of given primary object type.
|
||||
|
||||
@param classname: The name of the primary object class.
|
||||
@type classname: str
|
||||
@param handle: The handle to be checked.
|
||||
@type handle: str
|
||||
@return: Returns whether the object has reference to this handle of this object type.
|
||||
@rtype: bool
|
||||
"""
|
||||
if classname == 'Event':
|
||||
return handle in [ref.ref for ref in self.event_ref_list]
|
||||
elif classname == 'Person':
|
||||
|
||||
Reference in New Issue
Block a user