10
10
"""
11
11
12
12
from .models import GitHubCore
13
- from re import match
14
13
15
14
16
15
class LegacyIssue (GitHubCore ):
@@ -30,16 +29,9 @@ def __init__(self, issue, session=None):
30
29
#: Number of votes on this issue. Probably effectively deprecated
31
30
self .votes = issue .get ('votes' , 0 )
32
31
#: datetime object representing the creation of the issue
33
- self .created_at = None
34
- if issue .get ('created_at' ):
35
- created = issue .get ('created_at' )[:- 6 ] + 'Z'
36
- self .created_at = self ._strptime (created )
37
-
32
+ self .created_at = self ._strptime (issue .get ('created_at' ))
38
33
#: datetime object representing the last time the issue was updated
39
- self .updated_at = None
40
- if issue .get ('updated_at' ):
41
- updated = issue .get ('updated_at' )[:- 6 ] + 'Z'
42
- self .updated_at = self ._strptime (updated )
34
+ self .updated_at = issue .get (issue .get ('updated_at' ))
43
35
#: Number of comments on the issue
44
36
self .comments = issue .get ('comments' , 0 )
45
37
#: Body of the issue
@@ -65,10 +57,7 @@ class LegacyRepo(GitHubCore):
65
57
def __init__ (self , repo , session = None ):
66
58
super (LegacyRepo , self ).__init__ (repo , session )
67
59
#: datetime object representing the date of creation of this repo
68
- self .created_at = None
69
- if repo .get ('created' ):
70
- created = repo .get ('created' )[:- 6 ] + 'Z'
71
- self .created_at = self ._strptime (created )
60
+ self .created_at = self ._strptime (repo .get ('created' ))
72
61
#: datetime object representing the date of creation of this repo
73
62
self .created = self .created_at
74
63
#: description of this repository
@@ -97,10 +86,7 @@ def __init__(self, repo, session=None):
97
86
#: Whether the repository is private or not
98
87
self .private = repo .get ('private' , False )
99
88
#: datetime object representing the last time the repo was pushed to
100
- self .pushed = None
101
- if repo .get ('pushed_at' ):
102
- pushed = repo .get ('pushed_at' )[:- 6 ] + 'Z' # (No coverage)
103
- self .pushed = self ._strptime (pushed ) # (No coverage)
89
+ self .pushed = self ._strptime (repo .get ('pushed_at' ))
104
90
#: datetime object representing the last time the repo was pushed to
105
91
self .pushed_at = self .pushed
106
92
#: Score
@@ -131,12 +117,7 @@ class LegacyUser(GitHubCore):
131
117
def __init__ (self , user , session = None ):
132
118
super (LegacyUser , self ).__init__ (user , session )
133
119
#: datetime object representing when the account was created
134
- self .created = None
135
- if user .get ('created' ):
136
- created = user .get ('created' )
137
- if not match (r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$' , created ):
138
- created = created [:- 6 ] + 'Z'
139
- self .created = self ._strptime (created )
120
+ self .created = self ._strptime (user .get ('created' ))
140
121
#: datetime object representing when the account was created
141
122
self .created_at = self .created
142
123
@@ -161,22 +142,15 @@ def __init__(self, user, session=None):
161
142
self .name = user .get ('fullname' , '' )
162
143
#: Number of public repos owned by this user
163
144
self .public_repo_count = user .get ('public_repo_count' , 0 )
164
- #: datetime representing the last time this user pushed
165
- self .pushed = None
166
- if user .get ('pushed' ):
167
- pushed = user .get ('pushed' )[:- 5 ] + 'Z' # (No coverage)
168
- self .pushed = self ._strptime (pushed ) # (No coverage)
169
- #: datetime representing the last time this user pushed
170
- self .pushed_at = self .pushed
171
- #: User's record
172
- self .record = user .get ('record' , '' )
173
145
#: Number of repos owned by the user
174
146
self .repos = user .get ('repos' , 0 )
175
147
#: Score
176
148
self .score = user .get ('score' , 0.0 )
177
149
#: Type of user
178
150
self .type = user .get ('type' , 'user' )
179
151
# username: same as login
152
+ #: User's login
153
+ self .username = user .get ('username' , '' )
180
154
181
155
def __repr__ (self ):
182
156
return '<Legacy User [{0}]>' .format (self .login )
0 commit comments