Skip to content

Commit

Permalink
PEP8 style fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtraschke committed Nov 9, 2015
1 parent db06520 commit fde0f1b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion pyrfc3339/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
pyRFC3339 parses and generates :RFC:`3339`-compliant timestamps using Python :class:`datetime.datetime` objects.
pyRFC3339 parses and generates :RFC:`3339`-compliant timestamps using Python
:class:`datetime.datetime` objects.
>>> from pyrfc3339 import generate, parse
>>> from datetime import datetime
Expand Down
2 changes: 1 addition & 1 deletion pyrfc3339/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def generate(dt, utc=True, accept_naive=False, microseconds=False):
ValueError: cannot generate a local timestamp from a naive datetime
'''
if dt.tzinfo == None:
if dt.tzinfo is None:
if accept_naive is True:
if utc is True:
dt = dt.replace(tzinfo=pytz.utc)
Expand Down
16 changes: 8 additions & 8 deletions pyrfc3339/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def parse(timestamp, utc=False, produce_naive=False):
'''

parse_re = re.compile(r'''^(?:(?:(?P<date_fullyear>[0-9]{4})\-(?P<date_month>[0-9]{2})\-(?P<date_mday>[0-9]{2}))T(?:(?:(?P<time_hour>[0-9]{2})\:(?P<time_minute>[0-9]{2})\:(?P<time_second>[0-9]{2})(?P<time_secfrac>(?:\.[0-9]{1,}))?)(?P<time_offset>(?:Z|(?P<time_numoffset>(?P<time_houroffset>(?:\+|\-)[0-9]{2})\:(?P<time_minuteoffset>[0-9]{2}))))))$''',
re.I | re.X)
re.I | re.X)

match = parse_re.match(timestamp)

Expand All @@ -71,13 +71,13 @@ def parse(timestamp, utc=False, produce_naive=False):
microsecond = int(round(float(secfrac) * 1000000))

dt_out = datetime(year=int(match.group('date_fullyear')),
month=int(match.group('date_month')),
day=int(match.group('date_mday')),
hour=int(match.group('time_hour')),
minute=int(match.group('time_minute')),
second=int(match.group('time_second')),
microsecond=microsecond,
tzinfo=tzinfo)
month=int(match.group('date_month')),
day=int(match.group('date_mday')),
hour=int(match.group('time_hour')),
minute=int(match.group('time_minute')),
second=int(match.group('time_second')),
microsecond=microsecond,
tzinfo=tzinfo)

if utc:
dt_out = dt_out.astimezone(pytz.utc)
Expand Down

0 comments on commit fde0f1b

Please sign in to comment.