@@ -52,7 +52,7 @@ class LocaleTime(object):
5252
5353 def __init__ (self ):
5454 """Set all attributes.
55-
55+
5656 Order of methods called matters for dependency reasons.
5757
5858 The locale language is set at the offset and then checked again before
@@ -68,7 +68,7 @@ def __init__(self):
6868 Only other possible issue is if someone changed the timezone and did
6969 not call tz.tzset . That is an issue for the programmer, though,
7070 since changing the timezone is worthless without that call.
71-
71+
7272 """
7373 self .lang = _getlang ()
7474 self .__calc_weekday ()
@@ -155,7 +155,7 @@ def __calc_date_time(self):
155155 date_time [offset ] = current_format .replace ('11' , U_W )
156156 self .LC_date_time = date_time [0 ]
157157 self .LC_date = date_time [1 ]
158- self .LC_time = date_time [2 ]
158+ self .LC_time = date_time [2 ]
159159
160160 def __calc_timezone (self ):
161161 # Set self.timezone by using time.tzname.
@@ -178,9 +178,9 @@ class TimeRE(dict):
178178
179179 def __init__ (self , locale_time = None ):
180180 """Create keys/values.
181-
181+
182182 Order of execution is important for dependency reasons.
183-
183+
184184 """
185185 if locale_time :
186186 self .locale_time = locale_time
@@ -219,22 +219,20 @@ def __init__(self, locale_time=None):
219219
220220 def __seqToRE (self , to_convert , directive ):
221221 """Convert a list to a regex string for matching a directive.
222-
222+
223223 Want possible matching values to be from longest to shortest. This
224224 prevents the possibility of a match occuring for a value that also
225225 a substring of a larger value that should have matched (e.g., 'abc'
226226 matching when 'abcdef' should have been the match).
227-
227+
228228 """
229229 for value in to_convert :
230230 if value != '' :
231231 break
232232 else :
233233 return ''
234- to_sort = [(len (item ), item ) for item in to_convert ]
235- to_sort .sort ()
236- to_sort .reverse ()
237- to_convert = [item for length , item in to_sort ]
234+ to_convert = to_convert [:]
235+ to_convert .sort (key = len , reverse = True )
238236 regex = '|' .join (to_convert )
239237 regex = '(?P<%s>%s' % (directive , regex )
240238 return '%s)' % regex
0 commit comments