From a48a32f2dd9a62c2b921e5caf19555e80b8923fe Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Tue, 22 Nov 2011 08:46:15 +1100 Subject: [PATCH] add not about stripping and spans; remove test that will never pass; clean up --- parse.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/parse.py b/parse.py index c404037..16ad279 100644 --- a/parse.py +++ b/parse.py @@ -63,7 +63,7 @@ Most of the `Format Specification Mini-Language`_ is supported:: The align operators will cause spaces (or specified fill character) to be stripped from the value. Similarly width is not enforced; it -just indicates there may be whitespace to strip. +just indicates there may be whitespace or "0"s to strip. The "#" format character is handled automatically by b, o and x - that is: if there is a "0b", "0o" or "0x" prefix respectively, it's ignored. @@ -170,7 +170,7 @@ named spans A dictionary mapping the names and fixed position indices matched to a 2-tuple slice range of where the match occurred in the input. - + The span does not include any stripped padding (alignment or width). ---- @@ -366,7 +366,6 @@ class Parser(object): self._groups = 0 self._format = format self._type_conversions = {} - self._group_checks = {} self._expression = '^%s$' % PARSE_RE.sub(self.replace, format) self._re = re.compile(self._expression, re.IGNORECASE|re.DOTALL) @@ -494,7 +493,6 @@ class Parser(object): else: fill = ' ' - is_numeric = d['type'] and d['type'] in 'nfdobhxX' # handle some numeric-specific things like prefix and sign @@ -873,9 +871,6 @@ class TestParse(unittest.TestCase): y('a {:x=5d} b', 'a xxx12 b', 12) y('a {:x=5d} b', 'a -xxx12 b', -12) - # TODO this should pass - # y('a {:05d} b', 'a 0000001 b', None) - def test_datetimes(self): def y(fmt, s, e, tz=None): p = compile(fmt)