2007-06-26 Don Allingham <don@gramps-project.org>
* src/Bookmarks.py: pylint * src/DateEdit.py: pylint * src/AutoComp.py: pylint * src/BaseDoc.py: pylint * src/DateHandler/_DateParser.py: pylint * src/DateHandler/_Date_fi.py: pylint * src/DateHandler/_DateUtils.py: pylint * src/DateHandler/__init__.py: pylint * src/DateHandler/_DateDisplay.py: pylint * src/DateHandler/_Date_fr.py: pylint * src/DateHandler/_Date_es.py: pylint * src/DateHandler/_Date_nl.py: pylint * src/DateHandler/_Date_sk.py: pylint * src/DateHandler/_DateHandler.py: pylint * src/DateHandler/_Date_lt.py: pylint * src/DateHandler/_Date_ru.py: pylint * src/DateHandler/_Date_sv.py: pylint * src/DateHandler/_Date_de.py: pylint svn: r8675
This commit is contained in:
20
ChangeLog
20
ChangeLog
@@ -1,3 +1,23 @@
|
||||
2007-06-26 Don Allingham <don@gramps-project.org>
|
||||
* src/Bookmarks.py: pylint
|
||||
* src/DateEdit.py: pylint
|
||||
* src/AutoComp.py: pylint
|
||||
* src/BaseDoc.py: pylint
|
||||
* src/DateHandler/_DateParser.py: pylint
|
||||
* src/DateHandler/_Date_fi.py: pylint
|
||||
* src/DateHandler/_DateUtils.py: pylint
|
||||
* src/DateHandler/__init__.py: pylint
|
||||
* src/DateHandler/_DateDisplay.py: pylint
|
||||
* src/DateHandler/_Date_fr.py: pylint
|
||||
* src/DateHandler/_Date_es.py: pylint
|
||||
* src/DateHandler/_Date_nl.py: pylint
|
||||
* src/DateHandler/_Date_sk.py: pylint
|
||||
* src/DateHandler/_DateHandler.py: pylint
|
||||
* src/DateHandler/_Date_lt.py: pylint
|
||||
* src/DateHandler/_Date_ru.py: pylint
|
||||
* src/DateHandler/_Date_sv.py: pylint
|
||||
* src/DateHandler/_Date_de.py: pylint
|
||||
|
||||
2007-06-26 Alex Roitman <shura@gramps-project.org>
|
||||
* src/plugins/ReadGrdb.py (importData): Only copy environment if
|
||||
it exists.
|
||||
|
||||
@@ -31,14 +31,6 @@ Provides autocompletion functionality.
|
||||
#-------------------------------------------------------------------------
|
||||
import locale
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# set up logging
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
log = logging.getLogger(".AutoComp")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GNOME modules
|
||||
@@ -226,34 +218,17 @@ class StandardCustomSelector:
|
||||
@param val: (int,str) tuple with the values to set.
|
||||
@type val: tuple
|
||||
"""
|
||||
i, s = val
|
||||
if i in self.mapping.keys() and i != self.custom_key:
|
||||
self.store.foreach(self.set_int_value, i)
|
||||
key, text = val
|
||||
if key in self.mapping.keys() and key != self.custom_key:
|
||||
self.store.foreach(self.set_int_value, key)
|
||||
elif self.custom_key != None:
|
||||
self.selector.child.set_text(s)
|
||||
self.selector.child.set_text(text)
|
||||
else:
|
||||
print "StandardCustomSelector.set(): Option not available:", val
|
||||
|
||||
def set_int_value(self, model, path, iter, val):
|
||||
if model.get_value(iter, 0) == val:
|
||||
self.selector.set_active_iter(iter)
|
||||
def set_int_value(self, model, path, node, val):
|
||||
if model.get_value(node, 0) == val:
|
||||
self.selector.set_active_iter(node)
|
||||
return True
|
||||
return False
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Testing code below this point
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
if __name__ == "__main__":
|
||||
def here(obj, event):
|
||||
print s.get_values()
|
||||
gtk.main_quit()
|
||||
|
||||
s = StandardCustomSelector({0:'abc', 1:'abd', 2:'bbe' }, None, 0, 1)
|
||||
s.set_values((2, 'bbe'))
|
||||
w = gtk.Dialog()
|
||||
w.child.add(s.selector)
|
||||
w.connect('delete-event', here)
|
||||
w.show_all()
|
||||
gtk.main()
|
||||
|
||||
@@ -1013,24 +1013,24 @@ class StyleSheet:
|
||||
@param obj: if not None, creates the StyleSheet from the values in
|
||||
obj, instead of creating an empty StyleSheet
|
||||
"""
|
||||
self._para_styles = {}
|
||||
self._draw_styles = {}
|
||||
self._table_styles = {}
|
||||
self._cell_styles = {}
|
||||
self.para_styles = {}
|
||||
self.draw_styles = {}
|
||||
self.table_styles = {}
|
||||
self.cell_styles = {}
|
||||
self.name = ""
|
||||
if obj != None:
|
||||
for style_name in obj._para_styles.keys():
|
||||
style = obj._para_styles[style_name]
|
||||
self._para_styles[style_name] = ParagraphStyle(style)
|
||||
for style_name in obj._draw_styles.keys():
|
||||
style = obj._draw_styles[style_name]
|
||||
self._draw_styles[style_name] = GraphicsStyle(style)
|
||||
for style_name in obj._table_styles.keys():
|
||||
style = obj._table_styles[style_name]
|
||||
self._table_styles[style_name] = TableStyle(style)
|
||||
for style_name in obj._cell_styles.keys():
|
||||
style = obj._cell_styles[style_name]
|
||||
self._cell_styles[style_name] = TableCellStyle(style)
|
||||
for style_name in obj.para_styles.keys():
|
||||
style = obj.para_styles[style_name]
|
||||
self.para_styles[style_name] = ParagraphStyle(style)
|
||||
for style_name in obj.draw_styles.keys():
|
||||
style = obj.draw_styles[style_name]
|
||||
self.draw_styles[style_name] = GraphicsStyle(style)
|
||||
for style_name in obj.table_styles.keys():
|
||||
style = obj.table_styles[style_name]
|
||||
self.table_styles[style_name] = TableStyle(style)
|
||||
for style_name in obj.cell_styles.keys():
|
||||
style = obj.cell_styles[style_name]
|
||||
self.cell_styles[style_name] = TableCellStyle(style)
|
||||
|
||||
def set_name(self, name):
|
||||
"""
|
||||
@@ -1048,10 +1048,10 @@ class StyleSheet:
|
||||
|
||||
def clear(self):
|
||||
"Removes all styles from the StyleSheet"
|
||||
self._para_styles = {}
|
||||
self._draw_styles = {}
|
||||
self._table_styles = {}
|
||||
self._cell_styles = {}
|
||||
self.para_styles = {}
|
||||
self.draw_styles = {}
|
||||
self.table_styles = {}
|
||||
self.cell_styles = {}
|
||||
|
||||
def add_paragraph_style(self, name, style):
|
||||
"""
|
||||
@@ -1060,7 +1060,7 @@ class StyleSheet:
|
||||
@param name: The name of the ParagraphStyle
|
||||
@param style: ParagraphStyle instance to be added.
|
||||
"""
|
||||
self._para_styles[name] = ParagraphStyle(style)
|
||||
self.para_styles[name] = ParagraphStyle(style)
|
||||
|
||||
def get_paragraph_style(self, name):
|
||||
"""
|
||||
@@ -1068,11 +1068,11 @@ class StyleSheet:
|
||||
|
||||
@param name: name of the ParagraphStyle that is wanted
|
||||
"""
|
||||
return ParagraphStyle(self._para_styles[name])
|
||||
return ParagraphStyle(self.para_styles[name])
|
||||
|
||||
def get_paragraph_style_names(self):
|
||||
"Returns the the list of paragraph names in the StyleSheet"
|
||||
return self._para_styles.keys()
|
||||
return self.para_styles.keys()
|
||||
|
||||
def add_draw_style(self, name, style):
|
||||
"""
|
||||
@@ -1081,7 +1081,7 @@ class StyleSheet:
|
||||
@param name: The name of the GraphicsStyle
|
||||
@param style: GraphicsStyle instance to be added.
|
||||
"""
|
||||
self._draw_styles[name] = GraphicsStyle(style)
|
||||
self.draw_styles[name] = GraphicsStyle(style)
|
||||
|
||||
def get_draw_style(self, name):
|
||||
"""
|
||||
@@ -1089,11 +1089,11 @@ class StyleSheet:
|
||||
|
||||
@param name: name of the GraphicsStyle that is wanted
|
||||
"""
|
||||
return GraphicsStyle(self._draw_styles[name])
|
||||
return GraphicsStyle(self.draw_styles[name])
|
||||
|
||||
def get_draw_style_names(self):
|
||||
"Returns the the list of draw style names in the StyleSheet"
|
||||
return self._draw_styles.keys()
|
||||
return self.draw_styles.keys()
|
||||
|
||||
def add_table_style(self, name, style):
|
||||
"""
|
||||
@@ -1102,7 +1102,7 @@ class StyleSheet:
|
||||
@param name: The name of the TableStyle
|
||||
@param style: TableStyle instance to be added.
|
||||
"""
|
||||
self._table_styles[name] = TableStyle(style)
|
||||
self.table_styles[name] = TableStyle(style)
|
||||
|
||||
def get_table_style(self, name):
|
||||
"""
|
||||
@@ -1110,11 +1110,11 @@ class StyleSheet:
|
||||
|
||||
@param name: name of the TableStyle that is wanted
|
||||
"""
|
||||
return TableStyle(self._table_styles[name])
|
||||
return TableStyle(self.table_styles[name])
|
||||
|
||||
def get_table_style_names(self):
|
||||
"Returns the the list of table style names in the StyleSheet"
|
||||
return self._table_styles.keys()
|
||||
return self.table_styles.keys()
|
||||
|
||||
def add_cell_style(self, name, style):
|
||||
"""
|
||||
@@ -1123,7 +1123,7 @@ class StyleSheet:
|
||||
@param name: The name of the TableCellStyle
|
||||
@param style: TableCellStyle instance to be added.
|
||||
"""
|
||||
self._cell_styles[name] = TableCellStyle(style)
|
||||
self.cell_styles[name] = TableCellStyle(style)
|
||||
|
||||
def get_cell_style(self, name):
|
||||
"""
|
||||
@@ -1131,11 +1131,11 @@ class StyleSheet:
|
||||
|
||||
@param name: name of the TableCellStyle that is wanted
|
||||
"""
|
||||
return TableCellStyle(self._cell_styles[name])
|
||||
return TableCellStyle(self.cell_styles[name])
|
||||
|
||||
def get_cell_style_names(self):
|
||||
"Returns the the list of cell style names in the StyleSheet"
|
||||
return self._cell_styles.keys()
|
||||
return self.cell_styles.keys()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -1299,12 +1299,12 @@ class IndexMark:
|
||||
"""
|
||||
Defines a mark to be associated with text for indexing.
|
||||
"""
|
||||
def __init__(self, key="", type=INDEX_TYPE_ALP, level=1):
|
||||
def __init__(self, key="", itype=INDEX_TYPE_ALP, level=1):
|
||||
"""
|
||||
Initialize the object with default values, unless values are specified.
|
||||
"""
|
||||
self.key = key
|
||||
self.type = type
|
||||
self.type = itype
|
||||
self.level = level
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
@@ -64,8 +64,8 @@ import Utils
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
_top = '''<ui><menubar name="MenuBar"><menu action="BookMenu">'''
|
||||
_btm = '''</menu></menubar></ui>'''
|
||||
TOP = '''<ui><menubar name="MenuBar"><menu action="BookMenu">'''
|
||||
BTM = '''</menu></menubar></ui>'''
|
||||
|
||||
DISABLED = -1
|
||||
|
||||
@@ -125,7 +125,7 @@ class Bookmarks :
|
||||
def redraw(self):
|
||||
"""Create the pulldown menu"""
|
||||
text = StringIO()
|
||||
text.write(_top)
|
||||
text.write(TOP)
|
||||
|
||||
self.undisplay()
|
||||
|
||||
@@ -150,7 +150,7 @@ class Bookmarks :
|
||||
text.write('</placeholder>')
|
||||
self.bookmarks.set(new_list)
|
||||
|
||||
text.write(_btm)
|
||||
text.write(BTM)
|
||||
self.action_group.add_actions(actions)
|
||||
self.uistate.uimanager.insert_action_group(self.action_group, 1)
|
||||
self.active = self.uistate.uimanager.add_ui_from_string(text.getvalue())
|
||||
@@ -414,5 +414,8 @@ class NoteBookmarks(ListBookmarks) :
|
||||
def connect_signals(self):
|
||||
self.dbstate.db.connect('note-delete', self.remove_handles)
|
||||
|
||||
def make_callback(n, f):
|
||||
return lambda x: f(n)
|
||||
def make_callback(handle, function):
|
||||
"""
|
||||
Builds a unique call to the function with the associated handle
|
||||
"""
|
||||
return lambda x: function(handle)
|
||||
|
||||
@@ -90,12 +90,12 @@ QUAL_TEXT = (
|
||||
(Date.QUAL_CALCULATED, _('Calculated')) )
|
||||
|
||||
CAL_TO_MONTHS_NAMES = {
|
||||
Date.CAL_GREGORIAN : DateHandler.displayer._MONS,
|
||||
Date.CAL_JULIAN : DateHandler.displayer._MONS,
|
||||
Date.CAL_HEBREW : DateHandler.displayer._hebrew,
|
||||
Date.CAL_FRENCH : DateHandler.displayer._french,
|
||||
Date.CAL_PERSIAN : DateHandler.displayer._persian,
|
||||
Date.CAL_ISLAMIC : DateHandler.displayer._islamic }
|
||||
Date.CAL_GREGORIAN : DateHandler.displayer.MONS,
|
||||
Date.CAL_JULIAN : DateHandler.displayer.MONS,
|
||||
Date.CAL_HEBREW : DateHandler.displayer.hebrew,
|
||||
Date.CAL_FRENCH : DateHandler.displayer.french,
|
||||
Date.CAL_PERSIAN : DateHandler.displayer.persian,
|
||||
Date.CAL_ISLAMIC : DateHandler.displayer.islamic }
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
@@ -52,17 +52,17 @@ import GrampsLocale
|
||||
class DateDisplay:
|
||||
|
||||
_months = GrampsLocale.long_months
|
||||
_MONS = GrampsLocale.short_months
|
||||
MONS = GrampsLocale.short_months
|
||||
|
||||
_tformat = GrampsLocale.tformat
|
||||
|
||||
_hebrew = (
|
||||
hebrew = (
|
||||
"", "Tishri", "Heshvan", "Kislev", "Tevet", "Shevat",
|
||||
"AdarI", "AdarII", "Nisan", "Iyyar", "Sivan", "Tammuz",
|
||||
"Av", "Elul"
|
||||
)
|
||||
|
||||
_french = (
|
||||
french = (
|
||||
u'',
|
||||
u"Vendémiaire",
|
||||
u'Brumaire',
|
||||
@@ -79,13 +79,13 @@ class DateDisplay:
|
||||
u'Extra',
|
||||
)
|
||||
|
||||
_persian = (
|
||||
persian = (
|
||||
"", "Farvardin", "Ordibehesht", "Khordad", "Tir",
|
||||
"Mordad", "Shahrivar", "Mehr", "Aban", "Azar",
|
||||
"Dey", "Bahman", "Esfand"
|
||||
)
|
||||
|
||||
_islamic = (
|
||||
islamic = (
|
||||
"", "Muharram", "Safar", "Rabi`al-Awwal", "Rabi`ath-Thani",
|
||||
"Jumada l-Ula", "Jumada t-Tania", "Rajab", "Sha`ban",
|
||||
"Ramadan", "Shawwal", "Dhu l-Qa`da", "Dhu l-Hijja"
|
||||
@@ -157,7 +157,8 @@ class DateDisplay:
|
||||
return "%s %s - %s%s" % (qual_str, d1, d2, self.calendar[cal])
|
||||
else:
|
||||
text = self.display_iso(start)
|
||||
return "%s%s%s%s" % (qual_str,self._mod_str[mod],text,self.calendar[cal])
|
||||
return "%s%s%s%s" % (qual_str, self._mod_str[mod], text,
|
||||
self.calendar[cal])
|
||||
|
||||
def _slash_year(self, val, slash):
|
||||
if val < 0:
|
||||
@@ -222,16 +223,18 @@ class DateDisplay:
|
||||
else:
|
||||
value = "%s %s" % (self._months[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self._months[date_val[1]],date_val[0],year)
|
||||
value = "%s %d, %s" % (self._months[date_val[1]],
|
||||
date_val[0], year)
|
||||
elif self.format == 3:
|
||||
# MON Day, Year
|
||||
if date_val[0] == 0:
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._MONS[date_val[1]],year)
|
||||
value = "%s %s" % (self.MONS[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self._MONS[date_val[1]],date_val[0],year)
|
||||
value = "%s %d, %s" % (self.MONS[date_val[1]],
|
||||
date_val[0], year)
|
||||
elif self.format == 4:
|
||||
# Day Month Year
|
||||
if date_val[0] == 0:
|
||||
@@ -240,16 +243,17 @@ class DateDisplay:
|
||||
else:
|
||||
value = "%s %s" % (self._months[date_val[1]], year)
|
||||
else:
|
||||
value = "%d %s %s" % (date_val[0],self._months[date_val[1]],year)
|
||||
value = "%d %s %s" % (date_val[0], self._months[date_val[1]],
|
||||
year)
|
||||
else:
|
||||
# Day MON Year
|
||||
if date_val[0] == 0:
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._MONS[date_val[1]],year)
|
||||
value = "%s %s" % (self.MONS[date_val[1]], year)
|
||||
else:
|
||||
value = "%d %s %s" % (date_val[0],self._MONS[date_val[1]],year)
|
||||
value = "%d %s %s" % (date_val[0], self.MONS[date_val[1]], year)
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
else:
|
||||
@@ -285,22 +289,22 @@ class DateDisplay:
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = u"%s %d" % (self._french[date_val[1]],year)
|
||||
value = u"%s %d" % (self.french[date_val[1]], year)
|
||||
else:
|
||||
value = u"%d %s %s" % (date_val[0],self._french[date_val[1]],year)
|
||||
value = u"%d %s %s" % (date_val[0], self.french[date_val[1]], year)
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
else:
|
||||
return value
|
||||
|
||||
def _display_hebrew(self, date_val):
|
||||
return self._display_calendar(date_val,self._hebrew)
|
||||
return self._display_calendar(date_val, self.hebrew)
|
||||
|
||||
def _display_persian(self, date_val):
|
||||
return self._display_calendar(date_val,self._persian)
|
||||
return self._display_calendar(date_val, self.persian)
|
||||
|
||||
def _display_islamic(self, date_val):
|
||||
return self._display_calendar(date_val,self._islamic)
|
||||
return self._display_calendar(date_val, self.islamic)
|
||||
|
||||
class DateDisplayEn(DateDisplay):
|
||||
"""
|
||||
|
||||
@@ -52,18 +52,18 @@ from _DateDisplay import DateDisplay, DateDisplayEn
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
_lang = locale.getlocale(locale.LC_TIME)[0]
|
||||
if _lang:
|
||||
_lang_short = _lang.split('_')[0]
|
||||
LANG = locale.getlocale(locale.LC_TIME)[0]
|
||||
if LANG:
|
||||
LANG_SHORT = LANG.split('_')[0]
|
||||
else:
|
||||
_lang_short = "C"
|
||||
LANG_SHORT = "C"
|
||||
|
||||
_lang_to_parser = {
|
||||
LANG_TO_PARSER = {
|
||||
'C' : DateParser,
|
||||
'en' : DateParser,
|
||||
}
|
||||
|
||||
_lang_to_display = {
|
||||
LANG_TO_DISPLAY = {
|
||||
'C' : DateDisplayEn,
|
||||
'en' : DateDisplayEn,
|
||||
'zh_CN' : DateDisplay,
|
||||
@@ -89,5 +89,5 @@ def register_datehandler(locales,parse_class,display_class):
|
||||
@type display_class: DateDisplay
|
||||
"""
|
||||
for lang_str in locales:
|
||||
_lang_to_parser[lang_str] = parse_class
|
||||
_lang_to_display[lang_str] = display_class
|
||||
LANG_TO_PARSER[lang_str] = parse_class
|
||||
LANG_TO_DISPLAY[lang_str] = display_class
|
||||
|
||||
@@ -29,7 +29,7 @@ Class handling language-specific selection for date parser and displayer.
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from DateHandler import _lang_to_display, _lang, parser, displayer
|
||||
from DateHandler import LANG_TO_DISPLAY, LANG, parser, displayer
|
||||
|
||||
#--------------------------------------------------------------
|
||||
#
|
||||
@@ -41,9 +41,9 @@ def get_date_formats():
|
||||
Returns the lists supported formats for date parsers and displayers
|
||||
"""
|
||||
try:
|
||||
return _lang_to_display[_lang].formats
|
||||
return LANG_TO_DISPLAY[LANG].formats
|
||||
except:
|
||||
return _lang_to_display["C"].formats
|
||||
return LANG_TO_DISPLAY["C"].formats
|
||||
|
||||
def set_format(value):
|
||||
try:
|
||||
|
||||
@@ -116,8 +116,10 @@ class DateParserDE(DateParser):
|
||||
|
||||
def init_strings(self):
|
||||
DateParser.init_strings(self)
|
||||
self._span = re.compile("(von|vom)\s+(?P<start>.+)\s+(bis)\s+(?P<stop>.+)",re.IGNORECASE)
|
||||
self._range = re.compile("zwischen\s+(?P<start>.+)\s+und\s+(?P<stop>.+)", re.IGNORECASE)
|
||||
self._span = re.compile("(von|vom)\s+(?P<start>.+)\s+(bis)\s+(?P<stop>.+)",
|
||||
re.IGNORECASE)
|
||||
self._range = re.compile("zwischen\s+(?P<start>.+)\s+und\s+(?P<stop>.+)",
|
||||
re.IGNORECASE)
|
||||
self._text2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._mon_str,
|
||||
re.IGNORECASE)
|
||||
self._jtext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._jmon_str,
|
||||
@@ -175,9 +177,9 @@ class DateDisplayDE(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._MONS[date_val[1]],year)
|
||||
value = "%s %s" % (self.MONS[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self._MONS[date_val[1]],date_val[0],year)
|
||||
value = "%s %d, %s" % (self.MONS[date_val[1]], date_val[0], year)
|
||||
elif self.format == 4:
|
||||
# Day Month Year
|
||||
if date_val[0] == 0:
|
||||
@@ -193,9 +195,9 @@ class DateDisplayDE(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._MONS[date_val[1]],year)
|
||||
value = "%s %s" % (self.MONS[date_val[1]], year)
|
||||
else:
|
||||
value = "%d. %s %s" % (date_val[0],self._MONS[date_val[1]],year)
|
||||
value = "%d. %s %s" % (date_val[0], self.MONS[date_val[1]], year)
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
else:
|
||||
|
||||
@@ -101,7 +101,8 @@ class DateParserFI(DateParser):
|
||||
# date, whitespace
|
||||
self._span = re.compile(u"(?P<start>.+)\s+(-)\s+(?P<stop>.+)",
|
||||
re.IGNORECASE)
|
||||
self._range = re.compile(u"(vuosien\s*)?(?P<start>.+)\s+ja\s+(?P<stop>.+)\s+välillä",
|
||||
self._range = re.compile(
|
||||
u"(vuosien\s*)?(?P<start>.+)\s+ja\s+(?P<stop>.+)\s+välillä",
|
||||
re.IGNORECASE)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -226,9 +226,9 @@ class DateDisplayFR(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._MONS[date_val[1]],year)
|
||||
value = "%s %s" % (self.MONS[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self._MONS[date_val[1]],date_val[0],year)
|
||||
value = "%s %d, %s" % (self.MONS[date_val[1]], date_val[0], year)
|
||||
elif self.format == 4:
|
||||
# Day Month Year
|
||||
if date_val[0] == 0:
|
||||
@@ -246,11 +246,11 @@ class DateDisplayFR(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._MONS[date_val[1]],year)
|
||||
value = "%s %s" % (self.MONS[date_val[1]], year)
|
||||
else:
|
||||
# base_display :
|
||||
# value = "%d %s %s" % (date_val[0],self._MONS[date_val[1]],year)
|
||||
value = "%d. %s %s" % (date_val[0],self._MONS[date_val[1]],year)
|
||||
# value = "%d %s %s" % (date_val[0], self.MONS[date_val[1]], year)
|
||||
value = "%d. %s %s" % (date_val[0], self.MONS[date_val[1]], year)
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
else:
|
||||
|
||||
@@ -81,10 +81,12 @@ class DateParserLT(DateParser):
|
||||
_span_2 = [u'iki']
|
||||
_range_1 = [u'tarp']
|
||||
_range_2 = [u'ir']
|
||||
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
|
||||
self._span = re.compile(
|
||||
"(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
|
||||
('|'.join(_span_1), '|'.join(_span_2)),
|
||||
re.IGNORECASE)
|
||||
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
|
||||
self._range = re.compile(
|
||||
"(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
|
||||
('|'.join(_range_1), '|'.join(_range_2)),
|
||||
re.IGNORECASE)
|
||||
|
||||
@@ -134,14 +136,17 @@ class DateDisplayLT(DateDisplay):
|
||||
elif mod == Date.MOD_SPAN:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return "%s%s %s %s %s%s" % (qual_str,u'nuo',d1,u'iki',d2,self.calendar[cal])
|
||||
return "%s%s %s %s %s%s" % (qual_str, u'nuo', d1, u'iki',
|
||||
d2, self.calendar[cal])
|
||||
elif mod == Date.MOD_RANGE:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return "%s%s %s %s %s%s" % (qual_str,u'tarp',d1,u'ir',d2,self.calendar[cal])
|
||||
return "%s%s %s %s %s%s" % (qual_str, u'tarp', d1, u'ir',
|
||||
d2, self.calendar[cal])
|
||||
else:
|
||||
text = self.display_cal[date.get_calendar()](start)
|
||||
return "%s%s%s%s" % (qual_str,self._mod_str[mod],text,self.calendar[cal])
|
||||
return "%s%s%s%s" % (qual_str, self._mod_str[mod], text,
|
||||
self.calendar[cal])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
@@ -181,9 +181,9 @@ class DateDisplayNL(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._MONS[date_val[1]],year)
|
||||
value = "%s %s" % (self.MONS[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self._MONS[date_val[1]],date_val[0],year)
|
||||
value = "%s %d, %s" % (self.MONS[date_val[1]], date_val[0], year)
|
||||
elif self.format == 4:
|
||||
# Day Month Year
|
||||
if date_val[0] == 0:
|
||||
@@ -199,9 +199,9 @@ class DateDisplayNL(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._MONS[date_val[1]],year)
|
||||
value = "%s %s" % (self.MONS[date_val[1]], year)
|
||||
else:
|
||||
value = "%d %s %s" % (date_val[0],self._MONS[date_val[1]],year)
|
||||
value = "%d %s %s" % (date_val[0], self.MONS[date_val[1]], year)
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
else:
|
||||
@@ -225,14 +225,17 @@ class DateDisplayNL(DateDisplay):
|
||||
elif mod == Date.MOD_SPAN:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return "%s%s %s %s %s%s" % (qual_str,u'van',d1,u'tot',d2,self.calendar[cal])
|
||||
return "%s%s %s %s %s%s" % (qual_str, u'van', d1,
|
||||
u'tot', d2, self.calendar[cal])
|
||||
elif mod == Date.MOD_RANGE:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return "%stussen %s en %s%s" % (qual_str,d1,d2,self.calendar[cal])
|
||||
return "%stussen %s en %s%s" % (qual_str, d1, d2,
|
||||
self.calendar[cal])
|
||||
else:
|
||||
text = self.display_cal[date.get_calendar()](start)
|
||||
return "%s%s%s%s" % (qual_str,self._mod_str[mod],text,self.calendar[cal])
|
||||
return "%s%s%s%s" % (qual_str, self._mod_str[mod], text,
|
||||
self.calendar[cal])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
@@ -208,7 +208,7 @@ class DateDisplayRU(DateDisplay):
|
||||
"МЕС ДД, ГГГГГ", "День Месяц, Год", "ДД МЕС, ГГГГГ"
|
||||
)
|
||||
|
||||
_hebrew = ( u"",
|
||||
hebrew = ( u"",
|
||||
u"Тишрей",
|
||||
u"Хешван",
|
||||
u"Кислев",
|
||||
@@ -224,7 +224,7 @@ class DateDisplayRU(DateDisplay):
|
||||
u"Элул",
|
||||
)
|
||||
|
||||
_islamic = ( u"",
|
||||
islamic = ( u"",
|
||||
u"Мухаррам",
|
||||
u"Сафар",
|
||||
u"Раби-аль-авваль",
|
||||
@@ -239,7 +239,7 @@ class DateDisplayRU(DateDisplay):
|
||||
u"Зуль-хиджжа",
|
||||
)
|
||||
|
||||
_persian = ( u"",
|
||||
persian = ( u"",
|
||||
u"Фарвардин",
|
||||
u"Урдбихишт",
|
||||
u"Хурдад",
|
||||
@@ -254,7 +254,7 @@ class DateDisplayRU(DateDisplay):
|
||||
u"Исфаидармуз",
|
||||
)
|
||||
|
||||
_french = ( u"",
|
||||
french = ( u"",
|
||||
u"Вандемьер",
|
||||
u"Брюмер",
|
||||
u"Фример",
|
||||
@@ -288,14 +288,17 @@ class DateDisplayRU(DateDisplay):
|
||||
elif mod == Date.MOD_SPAN:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return "%sс %s %s %s%s" % (qual_str,d1,u'по',d2,self.calendar[cal])
|
||||
return "%sс %s %s %s%s" % (qual_str, d1, u'по', d2,
|
||||
self.calendar[cal])
|
||||
elif mod == Date.MOD_RANGE:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return "%s%s %s %s %s%s" % (qual_str,u'между',d1,u'и',d2,self.calendar[cal])
|
||||
return "%s%s %s %s %s%s" % (qual_str, u'между', d1, u'и',
|
||||
d2, self.calendar[cal])
|
||||
else:
|
||||
text = self.display_cal[date.get_calendar()](start)
|
||||
return "%s%s%s%s" % (qual_str,self._mod_str[mod],text,self.calendar[cal])
|
||||
return "%s%s%s%s" % (qual_str, self._mod_str[mod],
|
||||
text, self.calendar[cal])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
@@ -132,14 +132,17 @@ class DateDisplaySK(DateDisplay):
|
||||
elif mod == Date.MOD_SPAN:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return "%s%s %s %s %s%s" % (qual_str,u'od',d1,u'do',d2,self.calendar[cal])
|
||||
return "%s%s %s %s %s%s" % (qual_str, u'od', d1,
|
||||
u'do', d2, self.calendar[cal])
|
||||
elif mod == Date.MOD_RANGE:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return "%s%s %s %s %s%s" % (qual_str,u'medzi',d1,u'a',d2,self.calendar[cal])
|
||||
return "%s%s %s %s %s%s" % (qual_str, u'medzi',
|
||||
d1, u'a', d2, self.calendar[cal])
|
||||
else:
|
||||
text = self.display_cal[date.get_calendar()](start)
|
||||
return "%s%s%s%s" % (qual_str,self._mod_str[mod],text,self.calendar[cal])
|
||||
return "%s%s%s%s" % (qual_str, self._mod_str[mod],
|
||||
text, self.calendar[cal])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
@@ -25,8 +25,8 @@ Class handling language-specific selection for date parser and displayer.
|
||||
"""
|
||||
|
||||
# import prerequisites for localized handlers
|
||||
from _DateHandler import _lang, _lang_short, \
|
||||
_lang_to_parser, _lang_to_display, register_datehandler
|
||||
from _DateHandler import LANG, LANG_SHORT, \
|
||||
LANG_TO_PARSER, LANG_TO_DISPLAY, register_datehandler
|
||||
|
||||
# Import all the localized handlers
|
||||
import _Date_de
|
||||
@@ -41,32 +41,32 @@ import _Date_sk
|
||||
|
||||
# Initialize global parser
|
||||
try:
|
||||
if _lang_to_parser.has_key(_lang):
|
||||
parser = _lang_to_parser[_lang]()
|
||||
if LANG_TO_PARSER.has_key(LANG):
|
||||
parser = LANG_TO_PARSER[LANG]()
|
||||
else:
|
||||
parser = _lang_to_parser[_lang_short]()
|
||||
parser = LANG_TO_PARSER[LANG_SHORT]()
|
||||
except:
|
||||
print "Date parser for",_lang,"not available, using default"
|
||||
parser = _lang_to_parser["C"]()
|
||||
print "Date parser for", LANG, "not available, using default"
|
||||
parser = LANG_TO_PARSER["C"]()
|
||||
|
||||
# Initialize global displayer
|
||||
try:
|
||||
import Config
|
||||
val = Config.get_date_format(_lang_to_display[_lang].formats)
|
||||
val = Config.get_date_format(LANG_TO_DISPLAY[LANG].formats)
|
||||
except:
|
||||
try:
|
||||
val = Config.get_date_format(_lang_to_display["C"].formats)
|
||||
val = Config.get_date_format(LANG_TO_DISPLAY["C"].formats)
|
||||
except:
|
||||
val = 0
|
||||
|
||||
try:
|
||||
if _lang_to_display.has_key(_lang):
|
||||
displayer = _lang_to_display[_lang](val)
|
||||
if LANG_TO_DISPLAY.has_key(LANG):
|
||||
displayer = LANG_TO_DISPLAY[LANG](val)
|
||||
else:
|
||||
displayer = _lang_to_display[_lang_short](val)
|
||||
displayer = LANG_TO_DISPLAY[LANG_SHORT](val)
|
||||
except:
|
||||
print "Date displayer for",_lang,"not available, using default"
|
||||
displayer = _lang_to_display["C"](val)
|
||||
print "Date displayer for", LANG, "not available, using default"
|
||||
displayer = LANG_TO_DISPLAY["C"](val)
|
||||
|
||||
|
||||
# Import utility functions
|
||||
|
||||
Reference in New Issue
Block a user