10000 Update the legacy objects and their fixtures · dahlia/github3.py@9a7d0c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a7d0c0

Browse files
committed
Update the legacy objects and their fixtures
1 parent da7524f commit 9a7d0c0

File tree

5 files changed

+11
-37
lines changed

5 files changed

+11
-37
lines changed

github3/legacy.py

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"""
1111

1212
from .models import GitHubCore
13-
from re import match
1413

1514

1615
class LegacyIssue(GitHubCore):
@@ -30,16 +29,9 @@ def __init__(self, issue, session=None):
3029
#: Number of votes on this issue. Probably effectively deprecated
3130
self.votes = issue.get('votes', 0)
3231
#: 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'))
3833
#: 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'))
4335
#: Number of comments on the issue
4436
self.comments = issue.get('comments', 0)
4537
#: Body of the issue
@@ -65,10 +57,7 @@ class LegacyRepo(GitHubCore):
6557
def __init__(self, repo, session=None):
6658
super(LegacyRepo, self).__init__(repo, session)
6759
#: 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'))
7261
#: datetime object representing the date of creation of this repo
7362
self.created = self.created_at
7463
#: description of this repository
@@ -97,10 +86,7 @@ def __init__(self, repo, session=None):
9786
#: Whether the repository is private or not
9887
self.private = repo.get('private', False)
9988
#: 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'))
10490
#: datetime object representing the last time the repo was pushed to
10591
self.pushed_at = self.pushed
10692
#: Score
@@ -131,12 +117,7 @@ class LegacyUser(GitHubCore):
131117
def __init__(self, user, session=None):
132118
super(LegacyUser, self).__init__(user, session)
133119
#: 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'))
140121
#: datetime object representing when the account was created
141122
self.created_at = self.created
142123

@@ -161,22 +142,15 @@ def __init__(self, user, session=None):
161142
self.name = user.get('fullname', '')
162143
#: Number of public repos owned by this user
163144
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', '')
173145
#: Number of repos owned by the user
174146
self.repos = user.get('repos', 0)
175147
#: Score
176148
self.score = user.get('score', 0.0)
177149
#: Type of user
178150
self.type = user.get('type', 'user')
179151
# username: same as login
152+
#: User's login
153+
self.username = user.get('username', '')
180154

181155
def __repr__(self):
182156
return '<Legacy User [{0}]>'.format(self.login)

tests/json/legacy_email

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"user": {"username": "sigmavirus24", "name": "Ian Cordasco", "language": "Python", "created": "2010-04-09T21:07:32-07:00", "created_at": "2010-04-09T21:07:32-07:00", "followers_count": 9, "followers": 9, "location": null, "public_repo_count": 24, "login": "sigmavirus24", "fullname": "Ian Cordasco", "type": "user", "id": "user-", "repos": 24}}
1+
{"user": {"username": "sigmavirus24", "created_at": "2010-04-10T04:07:32Z", "name": "sigmavirus24", "language": "Python", "created": "2010-04-10T04:07:32Z", "repos": 40, "public_repo_count": 40, "fullname": "sigmavirus24", "followers_count": 27, "score": 22.788326000000001, "followers": 27, "location": null, "gravatar_id": "c148356d89f925e692178bee1d93acf7", "login": "sigmavirus24", "type": "user", "id": "user-240830"}}

tests/json/legacy_issue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"issues": [{"body": "", "votes": 0, "labels": ["bug"], "title": "Installation fails without requests installed", "updated_at": "2012-07-02T12:13:16-07:00", "created_at": "2012-07-01T20:29:45-07:00", "gravatar_id": "c148356d89f925e692178bee1d93acf7", "html_url": "https://github.com/sigmavirus24/github3.py/issues/2", "comments": 1, "number": 2, "state": "closed", "user": "sigmavirus24", "position": 1.0, "closed_at": "2012-07-02T12:13:16-07:00"}]}
1+
{"issues": [{"body": "This is for inclusion in Debian and other package repositories. Besides it is just good practice, even if others don't do it.", "votes": 0, "title": "Include tests in distribution", "updated_at": "2013-03-20T03:29:58Z", "created_at": "2013-03-20T03:29:58Z", "labels": [], "number": 74, "comments": 0, "html_url": "https://github.com/sigmavirus24/github3.py/issues/74", "state": "open", "user": "sigmavirus24", "gravatar_id": "c148356d89f925e692178bee1d93acf7", "position": 1.0}]}

tests/json/legacy_repo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"repositories": [{"fork": false, "username": "sigmavirus24", "watchers": 46, "description": "Python library for interfacing with the GitHub APIv3", "language": "Python", "created": "2012-03-13T12:58:53-07:00", "created_at": "2012-03-13T12:58:53-07:00", "private": false, "name": "github3.py", "pushed_at": "2012-11-13T19:37:41-08:00", "pushed": "2012-11-13T19:37:41-08:00", "followers": 46, "owner": "sigmavirus24", "forks": 9, "type": "repo", "size": 612}]}
1+
{"repositories": [{"fork": false, "has_wiki": false, "private": false, "pushed": "2013-03-20T13:26:57Z", "owner": "sigmavirus24", "size": 680, "score": 47.874415999999997, "followers": 69, "forks": 17, "homepage": "http://github3py.readthedocs.org/", "username": "sigmavirus24", "description": "Python library for interfacing with the GitHub APIv3", "has_downloads": true, "has_issues": true, "watchers": 69, "name": "github3.py", "language": "Python", "created": "2012-03-13T19:58:53Z", "url": "https://github.com/sigmavirus24/github3.py", "type": "repo", "created_at": "2012-03-13T19:58:53Z", "pushed_at": "2013-03-20T13:26:57Z", "open_issues": 4}]}

tests/json/legacy_user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"users": [{"username": "sigmavirus24", "name": "Ian Cordasco", "language": "Python", "created": "2010-04-09T21:07:32-07:00", "created_at": "2010-04-09T21:07:32-07:00", "followers_count": 9, "followers": 9, "location": null, "public_repo_count": 24, "login": "sigmavirus24", "fullname": "Ian Cordasco", "type": "user", "id": "user-", "repos": 24, "pushed": "2012-04-18T02:15:17.511Z"}]}
1+
{"users": [{"username": "sigmavirus24", "created_at": "2010-04-10T04:07:32Z", "name": "sigmavirus24", "language": "Python", "created": "2010-04-10T04:07:32Z", "repos": 40, "public_repo_count": 40, "fullname": "sigmavirus24", "followers_count": 27, "score": 22.788326000000001, "followers": 27, "location": null, "gravatar_id": "c148356d89f925e692178bee1d93acf7", "login": "sigmavirus24", "type": "user", "id": "user-240830"}]}

0 commit comments

Comments
 (0)
0