Patch from Raphael Ackermann <raphael.ackermann@gmail.com> -- Fix 0001538: tabs and spaces are mixed in some source files
svn: r9713
This commit is contained in:
@@ -207,14 +207,14 @@ class DateParser:
|
||||
self.ymd = False
|
||||
|
||||
def re_longest_first(self, keys):
|
||||
"""
|
||||
returns a string for a RE group which contains the given keys
|
||||
"""
|
||||
returns a string for a RE group which contains the given keys
|
||||
sorted so that longest keys match first. Any '.' characters
|
||||
are quoted.
|
||||
"""
|
||||
keys.sort(lambda x, y: cmp(len(y), len(x)))
|
||||
return '(' + '|'.join([key.replace('.', '\.') for key in keys]) + ')'
|
||||
|
||||
are quoted.
|
||||
"""
|
||||
keys.sort(lambda x, y: cmp(len(y), len(x)))
|
||||
return '(' + '|'.join([key.replace('.', '\.') for key in keys]) + ')'
|
||||
|
||||
def init_strings(self):
|
||||
"""
|
||||
This method compiles regular expression strings for matching dates.
|
||||
@@ -508,7 +508,7 @@ class DateParser:
|
||||
match = self._bce_re.match(text)
|
||||
bc = False
|
||||
if match:
|
||||
# bce is in the match.group(2)
|
||||
# bce is in the match.group(2)
|
||||
try:
|
||||
text = match.group(1) + match.group(3)
|
||||
except:
|
||||
|
||||
@@ -98,7 +98,7 @@ class DateParserFI(DateParser):
|
||||
|
||||
def init_strings(self):
|
||||
DateParser.init_strings(self)
|
||||
# date, whitespace
|
||||
# date, whitespace
|
||||
self._span = re.compile(u"(?P<start>.+)\s+(-)\s+(?P<stop>.+)",
|
||||
re.IGNORECASE)
|
||||
self._range = re.compile(
|
||||
@@ -142,9 +142,9 @@ class DateDisplayFI(DateDisplay):
|
||||
if start == Date.EMPTY:
|
||||
return u""
|
||||
|
||||
# select numerical date format
|
||||
self.format = 1
|
||||
|
||||
# select numerical date format
|
||||
self.format = 1
|
||||
|
||||
if mod == Date.MOD_SPAN:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
@@ -167,15 +167,15 @@ class DateDisplayFI(DateDisplay):
|
||||
text = u"noin " + text
|
||||
elif mod == Date.MOD_BEFORE:
|
||||
text = u"ennen " + text
|
||||
|
||||
|
||||
if qual:
|
||||
# prepend quality
|
||||
text = u"%s %s" % (self._qual_str[qual], text)
|
||||
if cal:
|
||||
# append calendar type
|
||||
text = u"%s %s" % (text, self.calendar[cal])
|
||||
|
||||
return text
|
||||
|
||||
return text
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
@@ -167,21 +167,21 @@ class DateParserFR(DateParser):
|
||||
self._numeric = re.compile("((\d+)[/\. ])?\s*((\d+)[/\.])?\s*(\d+)\s*$")
|
||||
self._span = re.compile(u"(de)\s+(?P<start>.+)\s+(à)\s+(?P<stop>.+)", re.IGNORECASE)
|
||||
self._range = re.compile(u"(entre|ent\.|ent)\s+(?P<start>.+)\s+(et)\s+(?P<stop>.+)", re.IGNORECASE)
|
||||
# This self._text are different from the base
|
||||
# This self._text are different from the base
|
||||
# by adding ".?" after the first date and removing "\s*$" at the end
|
||||
#gregorian and julian
|
||||
#gregorian and julian
|
||||
self._text2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._mon_str,
|
||||
re.IGNORECASE)
|
||||
#hebrew
|
||||
#hebrew
|
||||
self._jtext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._jmon_str,
|
||||
re.IGNORECASE)
|
||||
#french
|
||||
#french
|
||||
self._ftext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._fmon_str,
|
||||
re.IGNORECASE)
|
||||
#persian
|
||||
#persian
|
||||
self._ptext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._pmon_str,
|
||||
re.IGNORECASE)
|
||||
#islamic
|
||||
#islamic
|
||||
self._itext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._imon_str,
|
||||
re.IGNORECASE)
|
||||
|
||||
@@ -221,8 +221,8 @@ class DateDisplayFR(DateDisplay):
|
||||
else:
|
||||
value = self._tformat.replace('%m', str(date_val[1]))
|
||||
value = value.replace('%d', str(date_val[0]))
|
||||
# base_display :
|
||||
# value = value.replace('%Y', str(abs(date_val[2])))
|
||||
# base_display :
|
||||
# value = value.replace('%Y', str(abs(date_val[2])))
|
||||
# value = value.replace('-', '/')
|
||||
value = value.replace('%Y', str(date_val[2]))
|
||||
elif self.format == 2:
|
||||
@@ -251,8 +251,8 @@ class DateDisplayFR(DateDisplay):
|
||||
else:
|
||||
value = "%s %s" % (self._months[date_val[1]], year)
|
||||
else:
|
||||
# base_display :
|
||||
# value = "%d %s %s" % (date_val[0], self._months[date_val[1]], year)
|
||||
# base_display :
|
||||
# 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
|
||||
@@ -262,8 +262,8 @@ class DateDisplayFR(DateDisplay):
|
||||
else:
|
||||
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)
|
||||
# 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)
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
|
||||
Reference in New Issue
Block a user