-
-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated regular expressions, fixed a few bugs, added tests for v0.15.0 #639
Conversation
…c format to use regex
… to inherit from value error
…g issue with ordinal dates
Note: tests seem to be passing, but we are still not at 100% coverage. |
# Before this, the ParserErrors were caught by the try/except in | ||
# _parse_multiformat() and the appropriate error message was not | ||
# transmitted to the user. | ||
class ParserMatchError(ParserError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
has_minutes = colon_count == 1 or len(time_parts[0]) == 4 | ||
has_seconds = colon_count == 2 or len(time_parts[0]) == 6 | ||
has_subseconds = re.search("[.,]", time_parts[0]) | ||
time_components = self._TIME_RE.match(time_parts[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 regex to the rescue again!
@@ -429,23 +441,23 @@ def _choice_re(choices, flags=0): | |||
|
|||
|
|||
class TzinfoParser(object): | |||
|
|||
_TZINFO_RE = re.compile(r"([+\-])?(\d\d):?(\d\d)?") | |||
# TODO: test against full timezone DB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good idea
Codecov Report
@@ Coverage Diff @@
## Version-0.15.0 #639 +/- ##
=============================================
Coverage 100% 100%
=============================================
Files 8 8
Lines 1511 1507 -4
Branches 235 233 -2
=============================================
- Hits 1511 1507 -4
Continue to review full report at Codecov.
|
self.assertEqual(self.parser.parse("01"), tz.tzoffset(None, 3600)) | ||
self.assertEqual(self.parser.parse("+01"), tz.tzoffset(None, 3600)) | ||
self.assertEqual(self.parser.parse("-01"), tz.tzoffset(None, -3600)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
X
token can now properly parse float timestamp stringstz
is present and will parse it accordingly (rather than going on the assumption that the logic defaults to UTC and ignores the Z, it is now more explicit with atzutc
object).ParserError
exceptions that were thrown when theday_of_year
logic encountered an error were not shown to the user because they were being prematurely caught. I fixed this by adding a newParserMatchError
that inherits fromParserError
that can be caught by the internal logic and allow theParserErrors
to propagate.ParserError
now inherits fromValueError
, which makes more sense then aRuntimeError
.