Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb273037

Browse files
committed
Add dateutil to parse timestamps
GitHub is inconsistent in the timestamps it returns for the issue importAPI. strptime has a way of handling UTC offsets a format like -0600 butnot -06:00. There's no good way to handle that with the standardlibrary, so here we must add dateutil.
1 parent232cff2 commitb273037

File tree

3 files changed

+7
-27
lines changed

3 files changed

+7
-27
lines changed

‎github3/models.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
"""This module provides the basic models used in github3.py."""
33
from __future__importunicode_literals
44

5-
fromdatetimeimportdatetime
65
fromjsonimportdumps,loads
76
fromloggingimportgetLogger
87

8+
importdateutil.parser
99
importrequests
1010
fromrequests.compatimportis_py2,urlparse
1111

1212
from .importexceptions
1313
from .sessionimportGitHubSession
14-
from .utilsimportUTC
1514

16-
__timeformat__='%Y-%m-%dT%H:%M:%SZ'
1715
__logs__=getLogger(__package__)
1816

1917

@@ -145,9 +143,7 @@ def _strptime(cls, time_str):
145143
:rtype: datetime or None
146144
"""
147145
iftime_str:
148-
# Parse UTC string into naive datetime, then add timezone
149-
dt=datetime.strptime(time_str,__timeformat__)
150-
returndt.replace(tzinfo=UTC())
146+
returndateutil.parser.parse(time_str)
151147
returnNone
152148

153149
def__repr__(self):

‎github3/utils.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,6 @@ def timestamp_parameter(timestamp, allow_none=True):
4545
raiseValueError("Cannot accept type %s for timestamp"%type(timestamp))
4646

4747

48-
classUTC(datetime.tzinfo):
49-
50-
"""Yet another UTC reimplementation, to avoid a dependency on pytz or
51-
dateutil."""
52-
53-
ZERO=datetime.timedelta(0)
54-
55-
def__repr__(self):
56-
return'UTC()'
57-
58-
defdst(self,dt):
59-
returnself.ZERO
60-
61-
deftzname(self,dt):
62-
return'UTC'
63-
64-
defutcoffset(self,dt):
65-
returnself.ZERO
66-
67-
6848
defstream_response_to_file(response,path=None):
6949
"""Stream a response body to the specified file.
7050

‎setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
os.system("python setup.py bdist_wheel sdist upload")
3535
sys.exit()
3636

37-
requires.extend(["requests >= 2.18","uritemplate >= 3.0.0"])
37+
requires.extend([
38+
"requests >= 2.18",
39+
"uritemplate >= 3.0.0",
40+
"python-dateutil >= 2.6.0",
41+
])
3842

3943
__version__=''
4044
withopen('github3/__about__.py','r')asfd:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp