]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Simplify OptionParser._TIMEDELTA_ABBREV_DICT.
authorBen Darnell <ben@bendarnell.com>
Mon, 14 Sep 2015 13:50:48 +0000 (09:50 -0400)
committerBen Darnell <ben@bendarnell.com>
Tue, 15 Sep 2015 00:31:57 +0000 (20:31 -0400)
Cython doesn't like having the more complex logic at class scope.

tornado/options.py

index 961bab153b358a56826bc807c17f2a8232a27ad4..ba16b1a7fdbe2b2124d9ae6223e74b43aa5f7798 100644 (file)
@@ -487,19 +487,17 @@ class _Option(object):
                 pass
         raise Error('Unrecognized date/time format: %r' % value)
 
-    _TIMEDELTA_ABBREVS = [
-        ('hours', ['h']),
-        ('minutes', ['m', 'min']),
-        ('seconds', ['s', 'sec']),
-        ('milliseconds', ['ms']),
-        ('microseconds', ['us']),
-        ('days', ['d']),
-        ('weeks', ['w']),
-    ]
-
-    _TIMEDELTA_ABBREV_DICT = dict(
-        (abbrev, full) for full, abbrevs in _TIMEDELTA_ABBREVS
-        for abbrev in abbrevs)
+    _TIMEDELTA_ABBREV_DICT = {
+        'h': 'hours',
+        'm': 'minutes',
+        'min': 'minutes',
+        's': 'seconds',
+        'sec': 'seconds',
+        'ms': 'milliseconds',
+        'us': 'microseconds',
+        'd': 'days',
+        'w': 'weeks',
+    }
 
     _FLOAT_PATTERN = r'[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?'