Added revision numbering symbol to all of plugins directory if it was missing in the file.
svn: r12002
This commit is contained in:
parent
f0a3ee8094
commit
c56f46b493
@ -16,7 +16,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# $Id: $
|
||||||
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# python modules
|
# python modules
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
# $Id:WriteCD.py 9912 2008-01-22 09:17:46Z acraphae $
|
# $Id$
|
||||||
|
#
|
||||||
|
|
||||||
"Export to CD (nautilus)."
|
"Export to CD (nautilus)."
|
||||||
|
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# python modules
|
# python modules
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This Gramplet shows textual distributions of age breakdowns of various types.
|
This Gramplet shows textual distributions of age breakdowns of various types.
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# $Id: $
|
||||||
|
#
|
||||||
|
|
||||||
from DataViews import Gramplet, register
|
from DataViews import Gramplet, register
|
||||||
from BasicUtils import name_displayer
|
from BasicUtils import name_displayer
|
||||||
|
@ -16,7 +16,10 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
#
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
from DataViews import Gramplet, register
|
from DataViews import Gramplet, register
|
||||||
|
@ -1,390 +1,392 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2008-2009 Brian G. Matherly
|
# Copyright (C) 2008-2009 Brian G. Matherly
|
||||||
# Copyright (C) 2009 Rob G. Healey <robhealey1@gmail.com>
|
# Copyright (C) 2009 Rob G. Healey <robhealey1@gmail.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
#------------------------------------------------------------------------
|
# $id: $
|
||||||
#
|
#
|
||||||
# python modules
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
# python modules
|
||||||
from gettext import gettext as _
|
#
|
||||||
from xml.parsers import expat
|
#------------------------------------------------------------------------
|
||||||
import datetime
|
from gettext import gettext as _
|
||||||
import math
|
from xml.parsers import expat
|
||||||
import const
|
import datetime
|
||||||
import os
|
import math
|
||||||
|
import const
|
||||||
#------------------------------------------------------------------------
|
import os
|
||||||
#
|
|
||||||
# GRAMPS modules
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
# GRAMPS modules
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------
|
||||||
from gen.plug import PluginManager, Plugin
|
from gen.plug import PluginManager, Plugin
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Support functions
|
# Support functions
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
def g2iso(dow):
|
def g2iso(dow):
|
||||||
""" Converst GRAMPS day of week to ISO day of week """
|
""" Converst GRAMPS day of week to ISO day of week """
|
||||||
# GRAMPS: SUN = 1
|
# GRAMPS: SUN = 1
|
||||||
# ISO: MON = 1
|
# ISO: MON = 1
|
||||||
return (dow + 5) % 7 + 1
|
return (dow + 5) % 7 + 1
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# HolidayTable
|
# HolidayTable
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
class HolidayTable:
|
class HolidayTable:
|
||||||
"""
|
"""
|
||||||
HolidayTable is a class which provides holidays for various
|
HolidayTable is a class which provides holidays for various
|
||||||
countries and years.
|
countries and years.
|
||||||
"""
|
"""
|
||||||
__holiday_files = []
|
__holiday_files = []
|
||||||
__countries = []
|
__countries = []
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
Find the holiday files and load the countries if it has not already
|
Find the holiday files and load the countries if it has not already
|
||||||
been done.
|
been done.
|
||||||
"""
|
"""
|
||||||
if( not HolidayTable.__holiday_files ):
|
if( not HolidayTable.__holiday_files ):
|
||||||
self.__find_holiday_files()
|
self.__find_holiday_files()
|
||||||
|
|
||||||
if( not HolidayTable.__countries ):
|
if( not HolidayTable.__countries ):
|
||||||
self.__build_country_list()
|
self.__build_country_list()
|
||||||
|
|
||||||
# Initialize the holiday table to be empty
|
# Initialize the holiday table to be empty
|
||||||
self.__holidays = {}
|
self.__holidays = {}
|
||||||
self.__init_table()
|
self.__init_table()
|
||||||
|
|
||||||
def __find_holiday_files(self):
|
def __find_holiday_files(self):
|
||||||
""" Looks in multiple places for holidays.xml files
|
""" Looks in multiple places for holidays.xml files
|
||||||
It will search for the file in user;s plugin directories first,
|
It will search for the file in user;s plugin directories first,
|
||||||
then it will search in program's plugins directories. """
|
then it will search in program's plugins directories. """
|
||||||
|
|
||||||
holiday_file = 'holidays.xml'
|
|
||||||
|
|
||||||
# Look for holiday files in the user plugins directory and all
|
|
||||||
# subdirectories.
|
|
||||||
for (dirpath, dirnames, filenames) in os.walk(const.USER_PLUGINS):
|
|
||||||
holiday_full_path = os.path.join(dirpath, holiday_file)
|
|
||||||
if os.path.exists(holiday_full_path):
|
|
||||||
HolidayTable.__holiday_files.append(holiday_full_path)
|
|
||||||
|
|
||||||
# Look for holiday files in the installation plugins directory and all
|
holiday_file = 'holidays.xml'
|
||||||
# subdirectories.
|
|
||||||
for (dirpath, dirnames, filenames) in os.walk(const.PLUGINS_DIR):
|
# Look for holiday files in the user plugins directory and all
|
||||||
holiday_full_path = os.path.join(dirpath, holiday_file)
|
# subdirectories.
|
||||||
if os.path.exists(holiday_full_path):
|
for (dirpath, dirnames, filenames) in os.walk(const.USER_PLUGINS):
|
||||||
HolidayTable.__holiday_files.append(holiday_full_path)
|
holiday_full_path = os.path.join(dirpath, holiday_file)
|
||||||
|
if os.path.exists(holiday_full_path):
|
||||||
def __build_country_list(self):
|
HolidayTable.__holiday_files.append(holiday_full_path)
|
||||||
""" Generate the list of countries that have holiday information. """
|
|
||||||
for holiday_file_path in HolidayTable.__holiday_files:
|
# Look for holiday files in the installation plugins directory and all
|
||||||
parser = _Xml2Obj()
|
# subdirectories.
|
||||||
root_element = parser.parse(holiday_file_path)
|
for (dirpath, dirnames, filenames) in os.walk(const.PLUGINS_DIR):
|
||||||
for country_element in root_element.get_children():
|
holiday_full_path = os.path.join(dirpath, holiday_file)
|
||||||
if country_element.get_name() == "country":
|
if os.path.exists(holiday_full_path):
|
||||||
country_name = country_element.get_attribute("name")
|
HolidayTable.__holiday_files.append(holiday_full_path)
|
||||||
if country_name not in HolidayTable.__countries:
|
|
||||||
HolidayTable.__countries.append(country_name)
|
def __build_country_list(self):
|
||||||
|
""" Generate the list of countries that have holiday information. """
|
||||||
def __init_table(self):
|
for holiday_file_path in HolidayTable.__holiday_files:
|
||||||
""" Initialize the holiday table structure. """
|
parser = _Xml2Obj()
|
||||||
for month in range(1, 13):
|
root_element = parser.parse(holiday_file_path)
|
||||||
self.__holidays[month] = {}
|
for country_element in root_element.get_children():
|
||||||
for day in range(1, 32):
|
if country_element.get_name() == "country":
|
||||||
self.__holidays[month][day] = []
|
country_name = country_element.get_attribute("name")
|
||||||
|
if country_name not in HolidayTable.__countries:
|
||||||
def get_countries(self):
|
HolidayTable.__countries.append(country_name)
|
||||||
"""
|
|
||||||
Get all the country names that holidays are available for.
|
def __init_table(self):
|
||||||
|
""" Initialize the holiday table structure. """
|
||||||
@return: nothing
|
for month in range(1, 13):
|
||||||
"""
|
self.__holidays[month] = {}
|
||||||
return HolidayTable.__countries
|
for day in range(1, 32):
|
||||||
|
self.__holidays[month][day] = []
|
||||||
def load_holidays(self, year, country):
|
|
||||||
"""
|
def get_countries(self):
|
||||||
Load the holiday table for the specified year and country.
|
"""
|
||||||
This must be called before get_holidays().
|
Get all the country names that holidays are available for.
|
||||||
|
|
||||||
@param year: The year for which the holidays should be loaded.
|
@return: nothing
|
||||||
Example: 2010
|
"""
|
||||||
@type year: int
|
return HolidayTable.__countries
|
||||||
@param country: The country for which the holidays should be loaded.
|
|
||||||
Example: "United States"
|
def load_holidays(self, year, country):
|
||||||
@type country: str
|
"""
|
||||||
@return: nothing
|
Load the holiday table for the specified year and country.
|
||||||
"""
|
This must be called before get_holidays().
|
||||||
self.__init_table()
|
|
||||||
for holiday_file_path in HolidayTable.__holiday_files:
|
@param year: The year for which the holidays should be loaded.
|
||||||
parser = _Xml2Obj()
|
Example: 2010
|
||||||
element = parser.parse(holiday_file_path)
|
@type year: int
|
||||||
calendar = _Holidays(element, country)
|
@param country: The country for which the holidays should be loaded.
|
||||||
date = datetime.date(year, 1, 1)
|
Example: "United States"
|
||||||
while date.year == year:
|
@type country: str
|
||||||
holidays = calendar.check_date(date)
|
@return: nothing
|
||||||
for text in holidays:
|
"""
|
||||||
self.__holidays[date.month][date.day].append(text)
|
self.__init_table()
|
||||||
date = date.fromordinal(date.toordinal() + 1)
|
for holiday_file_path in HolidayTable.__holiday_files:
|
||||||
|
parser = _Xml2Obj()
|
||||||
def get_holidays(self, month, day):
|
element = parser.parse(holiday_file_path)
|
||||||
"""
|
calendar = _Holidays(element, country)
|
||||||
Get the holidays for the given day of the year.
|
date = datetime.date(year, 1, 1)
|
||||||
|
while date.year == year:
|
||||||
@param month: The month for the requested holidays.
|
holidays = calendar.check_date(date)
|
||||||
Example: 1
|
for text in holidays:
|
||||||
@type month: int
|
self.__holidays[date.month][date.day].append(text)
|
||||||
@param month: The day for the requested holidays.
|
date = date.fromordinal(date.toordinal() + 1)
|
||||||
Example: 1
|
|
||||||
@type month: int
|
def get_holidays(self, month, day):
|
||||||
@return: An array of strings with holiday names.
|
"""
|
||||||
@return type: [str]
|
Get the holidays for the given day of the year.
|
||||||
"""
|
|
||||||
return self.__holidays[month][day]
|
@param month: The month for the requested holidays.
|
||||||
|
Example: 1
|
||||||
#------------------------------------------------------------------------
|
@type month: int
|
||||||
#
|
@param month: The day for the requested holidays.
|
||||||
# _Element
|
Example: 1
|
||||||
#
|
@type month: int
|
||||||
#------------------------------------------------------------------------
|
@return: An array of strings with holiday names.
|
||||||
class _Element:
|
@return type: [str]
|
||||||
""" A parsed XML element """
|
"""
|
||||||
def __init__(self, name, attributes):
|
return self.__holidays[month][day]
|
||||||
'Element constructor'
|
|
||||||
# The element's tag name
|
#------------------------------------------------------------------------
|
||||||
self.__name = name
|
#
|
||||||
# The element's attribute dictionary
|
# _Element
|
||||||
self.__attributes = attributes
|
#
|
||||||
# The element's child element list (sequence)
|
#------------------------------------------------------------------------
|
||||||
self.__children = []
|
class _Element:
|
||||||
|
""" A parsed XML element """
|
||||||
def add_child(self, element):
|
def __init__(self, name, attributes):
|
||||||
'Add a reference to a child element'
|
'Element constructor'
|
||||||
self.__children.append(element)
|
# The element's tag name
|
||||||
|
self.__name = name
|
||||||
def get_attribute(self, key):
|
# The element's attribute dictionary
|
||||||
'Get an attribute value'
|
self.__attributes = attributes
|
||||||
return self.__attributes.get(key)
|
# The element's child element list (sequence)
|
||||||
|
self.__children = []
|
||||||
def get_attributes(self):
|
|
||||||
'Get all the attributes'
|
def add_child(self, element):
|
||||||
return self.__attributes
|
'Add a reference to a child element'
|
||||||
|
self.__children.append(element)
|
||||||
def get_name(self):
|
|
||||||
""" Get the name of this element. """
|
def get_attribute(self, key):
|
||||||
return self.__name
|
'Get an attribute value'
|
||||||
|
return self.__attributes.get(key)
|
||||||
def get_children(self):
|
|
||||||
""" Get the children elements for this element. """
|
def get_attributes(self):
|
||||||
return self.__children
|
'Get all the attributes'
|
||||||
|
return self.__attributes
|
||||||
#------------------------------------------------------------------------
|
|
||||||
#
|
def get_name(self):
|
||||||
# _Xml2Obj
|
""" Get the name of this element. """
|
||||||
#
|
return self.__name
|
||||||
#------------------------------------------------------------------------
|
|
||||||
class _Xml2Obj:
|
def get_children(self):
|
||||||
""" XML to Object """
|
""" Get the children elements for this element. """
|
||||||
def __init__(self):
|
return self.__children
|
||||||
self.root = None
|
|
||||||
self.nodeStack = []
|
#------------------------------------------------------------------------
|
||||||
|
#
|
||||||
def start_element(self, name, attributes):
|
# _Xml2Obj
|
||||||
'SAX start element even handler'
|
#
|
||||||
# Instantiate an Element object
|
#------------------------------------------------------------------------
|
||||||
element = _Element(name.encode(), attributes)
|
class _Xml2Obj:
|
||||||
# Push element onto the stack and make it a child of parent
|
""" XML to Object """
|
||||||
if len(self.nodeStack) > 0:
|
def __init__(self):
|
||||||
parent = self.nodeStack[-1]
|
self.root = None
|
||||||
parent.add_child(element)
|
self.nodeStack = []
|
||||||
else:
|
|
||||||
self.root = element
|
def start_element(self, name, attributes):
|
||||||
self.nodeStack.append(element)
|
'SAX start element even handler'
|
||||||
|
# Instantiate an Element object
|
||||||
def end_element(self, name):
|
element = _Element(name.encode(), attributes)
|
||||||
'SAX end element event handler'
|
# Push element onto the stack and make it a child of parent
|
||||||
self.nodeStack = self.nodeStack[:-1]
|
if len(self.nodeStack) > 0:
|
||||||
|
parent = self.nodeStack[-1]
|
||||||
def parse(self, filename):
|
parent.add_child(element)
|
||||||
'Create a SAX parser and parse filename '
|
else:
|
||||||
parser = expat.ParserCreate()
|
self.root = element
|
||||||
# SAX event handlers
|
self.nodeStack.append(element)
|
||||||
parser.StartElementHandler = self.start_element
|
|
||||||
parser.EndElementHandler = self.end_element
|
def end_element(self, name):
|
||||||
# Parse the XML File
|
'SAX end element event handler'
|
||||||
parser.Parse(open(filename, 'r').read(), 1)
|
self.nodeStack = self.nodeStack[:-1]
|
||||||
return self.root
|
|
||||||
|
def parse(self, filename):
|
||||||
#------------------------------------------------------------------------
|
'Create a SAX parser and parse filename '
|
||||||
#
|
parser = expat.ParserCreate()
|
||||||
# _Holidays
|
# SAX event handlers
|
||||||
#
|
parser.StartElementHandler = self.start_element
|
||||||
#------------------------------------------------------------------------
|
parser.EndElementHandler = self.end_element
|
||||||
class _Holidays:
|
# Parse the XML File
|
||||||
""" Class used to read XML holidays to add to calendar. """
|
parser.Parse(open(filename, 'r').read(), 1)
|
||||||
def __init__(self, elements, country="US"):
|
return self.root
|
||||||
self.debug = 0
|
|
||||||
self.elements = elements
|
#------------------------------------------------------------------------
|
||||||
self.country = country
|
#
|
||||||
self.dates = []
|
# _Holidays
|
||||||
self.initialize()
|
#
|
||||||
|
#------------------------------------------------------------------------
|
||||||
def set_country(self, country):
|
class _Holidays:
|
||||||
""" Set the contry of holidays to read """
|
""" Class used to read XML holidays to add to calendar. """
|
||||||
self.country = country
|
def __init__(self, elements, country="US"):
|
||||||
self.dates = []
|
self.debug = 0
|
||||||
self.initialize()
|
self.elements = elements
|
||||||
|
self.country = country
|
||||||
def initialize(self):
|
self.dates = []
|
||||||
""" Parse the holiday date XML items """
|
self.initialize()
|
||||||
for country_set in self.elements.get_children():
|
|
||||||
if country_set.get_name() == "country" and \
|
def set_country(self, country):
|
||||||
country_set.get_attribute("name") == self.country:
|
""" Set the contry of holidays to read """
|
||||||
for date in country_set.get_children():
|
self.country = country
|
||||||
if date.get_name() == "date":
|
self.dates = []
|
||||||
data = {"value" : "",
|
self.initialize()
|
||||||
"name" : "",
|
|
||||||
"offset": "",
|
def initialize(self):
|
||||||
"type": "",
|
""" Parse the holiday date XML items """
|
||||||
} # defaults
|
for country_set in self.elements.get_children():
|
||||||
for attr in date.get_attributes():
|
if country_set.get_name() == "country" and \
|
||||||
data[attr] = date.get_attribute(attr)
|
country_set.get_attribute("name") == self.country:
|
||||||
self.dates.append(data)
|
for date in country_set.get_children():
|
||||||
|
if date.get_name() == "date":
|
||||||
def get_daynames(self, year, month, dayname):
|
data = {"value" : "",
|
||||||
""" Get the items for a particular year/month and day of week """
|
"name" : "",
|
||||||
if self.debug:
|
"offset": "",
|
||||||
print "%s's in %d %d..." % (dayname, month, year)
|
"type": "",
|
||||||
|
} # defaults
|
||||||
retval = [0]
|
for attr in date.get_attributes():
|
||||||
dow = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'].index(dayname)
|
data[attr] = date.get_attribute(attr)
|
||||||
for day in range(1, 32):
|
self.dates.append(data)
|
||||||
try:
|
|
||||||
date = datetime.date(year, month, day)
|
def get_daynames(self, year, month, dayname):
|
||||||
except ValueError:
|
""" Get the items for a particular year/month and day of week """
|
||||||
continue
|
if self.debug:
|
||||||
if date.weekday() == dow:
|
print "%s's in %d %d..." % (dayname, month, year)
|
||||||
retval.append(day)
|
|
||||||
|
retval = [0]
|
||||||
if self.debug:
|
dow = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'].index(dayname)
|
||||||
print "dow=", dow, "days=", retval
|
for day in range(1, 32):
|
||||||
|
try:
|
||||||
return retval
|
date = datetime.date(year, month, day)
|
||||||
|
except ValueError:
|
||||||
def check_date(self, date):
|
continue
|
||||||
""" Return items that match rules """
|
if date.weekday() == dow:
|
||||||
retval = []
|
retval.append(day)
|
||||||
for rule in self.dates:
|
|
||||||
|
if self.debug:
|
||||||
if self.debug:
|
print "dow=", dow, "days=", retval
|
||||||
print "Checking ", rule["name"], "..."
|
|
||||||
|
return retval
|
||||||
offset = 0
|
|
||||||
if rule["offset"] != "":
|
def check_date(self, date):
|
||||||
if rule["offset"].isdigit():
|
""" Return items that match rules """
|
||||||
offset = int(rule["offset"])
|
retval = []
|
||||||
elif rule["offset"][0] in ["-", "+"] and \
|
for rule in self.dates:
|
||||||
rule["offset"][1:].isdigit():
|
|
||||||
offset = int(rule["offset"])
|
if self.debug:
|
||||||
else:
|
print "Checking ", rule["name"], "..."
|
||||||
# must be a dayname
|
|
||||||
offset = rule["offset"]
|
offset = 0
|
||||||
|
if rule["offset"] != "":
|
||||||
if self.debug:
|
if rule["offset"].isdigit():
|
||||||
print "rule['value']:", rule["value"]
|
offset = int(rule["offset"])
|
||||||
|
elif rule["offset"][0] in ["-", "+"] and \
|
||||||
if rule["value"].count("/") == 3: # year/num/day/month, "3rd wednesday in april"
|
rule["offset"][1:].isdigit():
|
||||||
y, num, dayname, mon = rule["value"].split("/")
|
offset = int(rule["offset"])
|
||||||
if y == "*":
|
else:
|
||||||
y = date.year
|
# must be a dayname
|
||||||
else:
|
offset = rule["offset"]
|
||||||
y = int(y)
|
|
||||||
if mon.isdigit():
|
if self.debug:
|
||||||
m = int(mon)
|
print "rule['value']:", rule["value"]
|
||||||
elif mon == "*":
|
|
||||||
m = date.month
|
if rule["value"].count("/") == 3: # year/num/day/month, "3rd wednesday in april"
|
||||||
else:
|
y, num, dayname, mon = rule["value"].split("/")
|
||||||
m = ['jan', 'feb', 'mar', 'apr', 'may', 'jun',
|
if y == "*":
|
||||||
'jul', 'aug', 'sep', 'oct', 'nov', 'dec'].index(mon) + 1
|
y = date.year
|
||||||
dates_of_dayname = self.get_daynames(y, m, dayname)
|
else:
|
||||||
|
y = int(y)
|
||||||
if self.debug:
|
if mon.isdigit():
|
||||||
print "num =", num
|
m = int(mon)
|
||||||
|
elif mon == "*":
|
||||||
d = dates_of_dayname[int(num)]
|
m = date.month
|
||||||
|
else:
|
||||||
elif rule["value"].count("/") == 2: # year/month/day
|
m = ['jan', 'feb', 'mar', 'apr', 'may', 'jun',
|
||||||
y, m, d = rule["value"].split("/")
|
'jul', 'aug', 'sep', 'oct', 'nov', 'dec'].index(mon) + 1
|
||||||
if y == "*":
|
dates_of_dayname = self.get_daynames(y, m, dayname)
|
||||||
y = date.year
|
|
||||||
else:
|
if self.debug:
|
||||||
y = int(y)
|
print "num =", num
|
||||||
if m == "*":
|
|
||||||
m = date.month
|
d = dates_of_dayname[int(num)]
|
||||||
else:
|
|
||||||
m = int(m)
|
elif rule["value"].count("/") == 2: # year/month/day
|
||||||
if d == "*":
|
y, m, d = rule["value"].split("/")
|
||||||
d = date.day
|
if y == "*":
|
||||||
else:
|
y = date.year
|
||||||
d = int(d)
|
else:
|
||||||
ndate = datetime.date(y, m, d)
|
y = int(y)
|
||||||
|
if m == "*":
|
||||||
if self.debug:
|
m = date.month
|
||||||
print ndate, offset, type(offset)
|
else:
|
||||||
|
m = int(m)
|
||||||
if isinstance(offset, int):
|
if d == "*":
|
||||||
if offset != 0:
|
d = date.day
|
||||||
ndate = ndate.fromordinal(ndate.toordinal() + offset)
|
else:
|
||||||
elif isinstance(offset, basestring):
|
d = int(d)
|
||||||
direction = 1
|
ndate = datetime.date(y, m, d)
|
||||||
if offset[0] == "-":
|
|
||||||
direction = -1
|
if self.debug:
|
||||||
offset = offset[1:]
|
print ndate, offset, type(offset)
|
||||||
if offset in ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']:
|
|
||||||
# next tuesday you come to, including this one
|
if isinstance(offset, int):
|
||||||
dow = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'].index(offset)
|
if offset != 0:
|
||||||
ordinal = ndate.toordinal()
|
ndate = ndate.fromordinal(ndate.toordinal() + offset)
|
||||||
while ndate.fromordinal(ordinal).weekday() != dow:
|
elif isinstance(offset, basestring):
|
||||||
ordinal += direction
|
direction = 1
|
||||||
ndate = ndate.fromordinal(ordinal)
|
if offset[0] == "-":
|
||||||
|
direction = -1
|
||||||
if self.debug:
|
offset = offset[1:]
|
||||||
print "ndate:", ndate, "date:", date
|
if offset in ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']:
|
||||||
|
# next tuesday you come to, including this one
|
||||||
if ndate == date:
|
dow = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'].index(offset)
|
||||||
retval.append(rule["name"])
|
ordinal = ndate.toordinal()
|
||||||
return retval
|
while ndate.fromordinal(ordinal).weekday() != dow:
|
||||||
|
ordinal += direction
|
||||||
#------------------------------------------------------------------------
|
ndate = ndate.fromordinal(ordinal)
|
||||||
#
|
|
||||||
# Register the plugins
|
if self.debug:
|
||||||
#
|
print "ndate:", ndate, "date:", date
|
||||||
#------------------------------------------------------------------------
|
|
||||||
PluginManager.get_instance().register_plugin(
|
if ndate == date:
|
||||||
Plugin(
|
retval.append(rule["name"])
|
||||||
name = __name__,
|
return retval
|
||||||
description = _("Provides holiday information for different countries."),
|
|
||||||
module_name = __name__
|
#------------------------------------------------------------------------
|
||||||
)
|
#
|
||||||
)
|
# Register the plugins
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
PluginManager.get_instance().register_plugin(
|
||||||
|
Plugin(
|
||||||
|
name = __name__,
|
||||||
|
description = _("Provides holiday information for different countries."),
|
||||||
|
module_name = __name__
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@ -17,7 +17,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# $Id: $
|
||||||
|
#
|
||||||
"""
|
"""
|
||||||
Base class for map services. Example: open place in openstreetmap.org
|
Base class for map services. Example: open place in openstreetmap.org
|
||||||
"""
|
"""
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
# $Id: $
|
||||||
|
#
|
||||||
"""
|
"""
|
||||||
Google Maps map service plugin. Open place in maps.google.com
|
Google Maps map service plugin. Open place in maps.google.com
|
||||||
"""
|
"""
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
# $id: $
|
||||||
|
#
|
||||||
"""
|
"""
|
||||||
OpenStreetMap map service plugin. Open place in openstreetmap.org
|
OpenStreetMap map service plugin. Open place in openstreetmap.org
|
||||||
"""
|
"""
|
||||||
|
@ -19,7 +19,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
#
|
||||||
"""
|
"""
|
||||||
Display references for any object
|
Display references for any object
|
||||||
"""
|
"""
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# $Id: $
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from ReportBase import CATEGORY_QR_MISC
|
from ReportBase import CATEGORY_QR_MISC
|
||||||
from Simple import SimpleAccess, SimpleDoc, SimpleTable
|
from Simple import SimpleAccess, SimpleDoc, SimpleTable
|
||||||
|
@ -18,6 +18,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# $Id: $
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Display filtered data
|
Display filtered data
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Display all events on a particular day.
|
Display all events on a particular day.
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Run a query on the tables
|
Run a query on the tables
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Display references for any object
|
Display references for any object
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Display a people who have a person's same surname or given name
|
Display a people who have a person's same surname or given name
|
||||||
|
@ -18,7 +18,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
#
|
||||||
"""
|
"""
|
||||||
Display a person's events, both personal and family
|
Display a person's events, both personal and family
|
||||||
"""
|
"""
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Display a person's relations to the home person
|
Display a person's relations to the home person
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Display a person's siblings in a report window
|
Display a person's siblings in a report window
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# $Id: $
|
||||||
|
#
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user