GEPS008: Move Gramps locale module into the datahandler

svn: r19819
This commit is contained in:
Nick Hall 2012-06-10 15:09:49 +00:00
parent 58d7914312
commit af0b93b069
15 changed files with 22 additions and 77 deletions

View File

@ -110,7 +110,6 @@ src/gen/filters/rules/repository/Makefile
src/gen/filters/rules/note/Makefile
src/gen/filters/rules/citation/Makefile
src/gen/lib/Makefile
src/gen/locale/Makefile
src/gen/merge/Makefile
src/gen/mime/Makefile
src/gen/plug/Makefile

View File

@ -38,6 +38,7 @@ src/gen/datehandler/_date_ru.py
src/gen/datehandler/_date_sk.py
src/gen/datehandler/_date_sv.py
src/gen/datehandler/_date_zh.py
src/gen/datehandler/_grampslocale.py
src/gen/datehandler/__init__.py
# gen db API
@ -151,10 +152,6 @@ src/gen/lib/url.py
src/gen/lib/urlbase.py
src/gen/lib/witness.py
# gen.locale package
src/gen/locale/__init__.py
src/gen/locale/_grampslocale.py
# gen.merge package
src/gen/merge/__init__.py
src/gen/merge/test/merge_ref_test.py

View File

@ -49,8 +49,7 @@ LOG = logging.getLogger(".")
from gen.display.name import displayer as name_displayer
import gen.lib
from gen.errors import DatabaseError
from gen.locale import codeset
import gen.datehandler
from gen.datehandler import displayer as date_displayer, codeset
from gen.config import config
from const import TEMP_DIR, USER_HOME, GRAMPS_UUID, IMAGE_DIR
from gen.constfunc import mac, win
@ -987,7 +986,7 @@ def format_time(secs):
"""
t = time.localtime(secs)
d = gen.lib.Date(t.tm_year, t.tm_mon, t.tm_mday)
return gen.datehandler.displayer.display(d) + time.strftime(' %X', t)
return date_displayer.display(d) + time.strftime(' %X', t)
#-------------------------------------------------------------------------
#

View File

@ -10,7 +10,6 @@ SUBDIRS = \
display \
filters \
lib \
locale \
merge \
mime \
plug \

View File

@ -29,6 +29,7 @@ pkgpython_PYTHON = \
_dateparser.py\
_datehandler.py\
_dateutils.py\
_grampslocale.py\
__init__.py
pkgpyexecdir = @pkgpyexecdir@/gen/datehandler

View File

@ -79,3 +79,5 @@ except:
# Import utility functions
from _dateutils import *
from _grampslocale import (codeset, month_to_int, long_months, short_months,
long_days, short_days, tformat)

View File

@ -45,6 +45,7 @@ from gen.lib import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
import _grampslocale
#-------------------------------------------------------------------------
#
@ -270,8 +271,7 @@ class DateDisplayFR(DateDisplay):
# Replace the previous "Numérique" by a string which
# do have an explicit meaning: "System default (format)"
import gen.locale
_locale_tformat = gen.locale.tformat
_locale_tformat = _grampslocale.tformat
_locale_tformat = _locale_tformat.replace('%d', "J")
_locale_tformat = _locale_tformat.replace('%m', "M")
_locale_tformat = _locale_tformat.replace('%Y', "A")

View File

@ -39,7 +39,7 @@ log = logging.getLogger(".DateDisplay")
#
#-------------------------------------------------------------------------
from gen.lib import Date
import gen.locale
import _grampslocale
#-------------------------------------------------------------------------
#
@ -57,7 +57,7 @@ class DateDisplay(object):
short_months = ( u"", u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun",
u"Jul", u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
_tformat = gen.locale.tformat
_tformat = _grampslocale.tformat
hebrew = (
"", "Tishri", "Heshvan", "Kislev", "Tevet", "Shevat",

View File

@ -49,7 +49,7 @@ log = logging.getLogger(".DateParser")
#
#-------------------------------------------------------------------------
from gen.lib import Date, DateError
import gen.locale
import _grampslocale
#-------------------------------------------------------------------------
#
@ -140,7 +140,7 @@ class DateParser(object):
'Sep' : 9, 'Oct' : 10, 'Nov' : 11, 'Dec' : 12,
}
month_to_int = gen.locale.month_to_int
month_to_int = _grampslocale.month_to_int
# modifiers before the date
modifier_to_int = {
@ -272,7 +272,7 @@ class DateParser(object):
Date.CAL_SWEDISH : self._parse_swedish,
}
fmt = gen.locale.tformat
fmt = _grampslocale.tformat
match = self._fmt_parse.match(fmt.lower())
if match:
self.dmy = (match.groups() == ('d', 'm', 'y') or \

View File

@ -1,25 +0,0 @@
# This is the src/gen/locale level Makefile for Gramps
# $Id$
# We could use GNU make's ':=' syntax for nice wildcard use,
# but that is not necessarily portable.
# If not using GNU make, then list all .py files individually
pkgpythondir = $(datadir)/@PACKAGE@/gen/locale
pkgpython_PYTHON = \
_grampslocale.py\
__init__.py
pkgpyexecdir = @pkgpyexecdir@/gen/locale
dist_pkgdata_DATA =
# Clean up all the byte-compiled files
MOSTLYCLEANFILES = *pyc *pyo
GRAMPS_PY_MODPATH = "../../"
pycheck:
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
pychecker $(pkgpython_PYTHON));

View File

@ -1,23 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2004-2006 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
from _grampslocale import *

View File

@ -49,8 +49,7 @@ from gen.plug.report import Report
from gen.plug.report import utils as ReportUtils
from gen.plug.report import MenuReportOptions
from gen.utils.alive import probably_alive
from gen.datehandler import displayer as _dd
import gen.locale
from gen.datehandler import displayer as _dd, long_days
import gen.lib
import libholiday
@ -206,8 +205,7 @@ class Calendar(Report):
for day_col in range(7):
font_height = pt2cm(pdaynames.get_font().get_size())
self.doc.center_text("CAL-Daynames",
gen.locale.long_days[(day_col+
g2iso(self.start_dow + 1))
long_days[(day_col+ g2iso(self.start_dow + 1))
% 7 + 1].capitalize(),
day_col * cell_width + cell_width/2,
header - font_height * 1.5)
@ -447,7 +445,7 @@ class CalendarOptions(MenuReportOptions):
start_dow = EnumeratedListOption(_("First day of week"), 1)
for count in range(1, 8):
# conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below
start_dow.add_item((count+5) % 7 + 1, gen.locale.long_days[count].capitalize())
start_dow.add_item((count+5) % 7 + 1, long_days[count].capitalize())
start_dow.set_help(_("Select the first day of the week for the calendar"))
add_option("start_dow", start_dow)

View File

@ -50,8 +50,7 @@ from gen.plug.report import Report
from gen.plug.report import utils as ReportUtils
from gen.plug.report import MenuReportOptions
from gen.utils.alive import probably_alive
import gen.locale
from gen.datehandler import displayer as _dd
from gen.datehandler import displayer as _dd, long_days
import libholiday
@ -399,7 +398,7 @@ class CalendarOptions(MenuReportOptions):
start_dow = EnumeratedListOption(_("First day of week"), 1)
for count in range(1, 8):
# conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below
start_dow.add_item((count+5) % 7 + 1, gen.locale.long_days[count].capitalize())
start_dow.add_item((count+5) % 7 + 1, long_days[count].capitalize())
start_dow.set_help(_("Select the first day of the week for the calendar"))
menu.add_option(category_name, "start_dow", start_dow)

View File

@ -58,10 +58,9 @@ from gen.plug.report import MenuReportOptions
from gen.plug.menu import BooleanOption, NumberOption, StringOption, \
EnumeratedListOption, FilterOption, PersonOption, \
DestinationOption, NoteOption
import gen.locale
from Utils import xml_lang, get_researcher
from gen.utils.alive import probably_alive
from gen.datehandler import displayer as _dd
from gen.datehandler import displayer as _dd, long_days
from gen.display.name import displayer as _nd
@ -606,9 +605,9 @@ class WebCalReport(Report):
day = col2day[col]
return day_names[day]
# Note. gen.locale has sunday => 1, monday => 2, etc
# Note. gen.datehandler has sunday => 1, monday => 2, etc
# We slice out the first empty element.
day_names = gen.locale.long_days
day_names = long_days
def __get_previous_month_day(year, month, day_col):
@ -1418,7 +1417,7 @@ class WebCalOptions(MenuReportOptions):
# Default selection ????
start_dow = EnumeratedListOption(_("First day of week"), 1)
for count in range(1, 8):
start_dow.add_item(count, gen.locale.long_days[count].capitalize())
start_dow.add_item(count, long_days[count].capitalize())
start_dow.set_help(_("Select the first day of the week for the calendar"))
menu.add_option(category_name, "start_dow", start_dow)