diff --git a/doc/ReferenceOfClasses.md b/doc/ReferenceOfClasses.md index ae3cb41b..f76cc276 100644 --- a/doc/ReferenceOfClasses.md +++ b/doc/ReferenceOfClasses.md @@ -461,7 +461,6 @@ Class `GitAuthor` Attributes ---------- * `date`: datetime.datetime -* `timezone`: datetime.timedelta * `email`: string * `name`: string diff --git a/github/GitAuthor.py b/github/GitAuthor.py index 87c2cb56..0f9cc80e 100644 --- a/github/GitAuthor.py +++ b/github/GitAuthor.py @@ -21,10 +21,6 @@ class GitAuthor( GithubObject.BasicGithubObject ): def date( self ): return self._NoneIfNotSet( self._date ) - @property - def timezone( self ): - return self._NoneIfNotSet( self._timezone ) - @property def email( self ): return self._NoneIfNotSet( self._email ) @@ -35,7 +31,6 @@ class GitAuthor( GithubObject.BasicGithubObject ): def _initAttributes( self ): self._date = GithubObject.NotSet - self._timezone = GithubObject.NotSet self._email = GithubObject.NotSet self._name = GithubObject.NotSet @@ -43,7 +38,6 @@ class GitAuthor( GithubObject.BasicGithubObject ): if "date" in attributes: # pragma no branch assert attributes[ "date" ] is None or isinstance( attributes[ "date" ], ( str, unicode ) ), attributes[ "date" ] self._date = self._parseDatetime( attributes[ "date" ] ) - self._timezone = self._parseTimezone( attributes[ "date" ] ) if "email" in attributes: # pragma no branch assert attributes[ "email" ] is None or isinstance( attributes[ "email" ], ( str, unicode ) ), attributes[ "email" ] self._email = attributes[ "email" ] diff --git a/github/GithubObject.py b/github/GithubObject.py index 10d96d5c..22ee9c19 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -43,15 +43,10 @@ class BasicGithubObject( object ): elif len( s ) == 24: return datetime.datetime.strptime( s, "%Y-%m-%dT%H:%M:%S.000Z" ) elif len( s ) == 25: - return datetime.datetime.strptime( s[ : 19 ], "%Y-%m-%dT%H:%M:%S" ) + return datetime.datetime.strptime( s[ : 19 ], "%Y-%m-%dT%H:%M:%S" ) + ( 1 if s[ 19 ] == '-' else -1 ) * datetime.timedelta( hours = int( s[ 20 : 22 ] ), minutes = int( s[ 23 : 25 ] ) ) else: return datetime.datetime.strptime( s, "%Y-%m-%dT%H:%M:%SZ" ) - @staticmethod - def _parseTimezone( s ): - assert len( s ) == 25 - return ( -1 if s[ 19 ] == '-' else 1 ) * datetime.timedelta( hours = int( s[ 20 : 22 ] ), minutes = int( s[ 23 : 25 ] ) ) - class GithubObject( BasicGithubObject ): def __init__( self, requester, attributes, completed ): BasicGithubObject.__init__( self, requester, attributes, completed ) diff --git a/test/Issue54.py b/test/Issue54.py index 480728c0..52221878 100644 --- a/test/Issue54.py +++ b/test/Issue54.py @@ -18,22 +18,9 @@ import Framework class Issue54( Framework.TestCase ): def setUp( self ): Framework.TestCase.setUp( self ) - self.repo = self.g.get_user().get_repo( "PyGithub" ) + self.repo = self.g.get_user().get_repo( "TestRepo" ) - def testPositiveIntegerTimezone( self ): - commit = self.repo.get_git_commit( "4303c5b90e2216d927155e9609436ccb8984c495" ) - self.assertEqual( commit.author.timezone, datetime.timedelta( hours = 7 ) ) - - def testNegativeIntegerTimezone( self ): - commit = self.repo.get_git_commit( "4303c5b90e2216d927155e9609436ccb8984c495" ) - self.assertEqual( commit.author.timezone, datetime.timedelta( hours = -7 ) ) - - # I was not able to find a real commit with an half integer timezone, so I *forged* the associated responses from Github. - # I *hope* they are what Github would send in that case - def testPositiveHalfIntegerTimezone( self ): - commit = self.repo.get_git_commit( "4303c5b90e2216d927155e9609436ccb8984c495" ) - self.assertEqual( commit.author.timezone, datetime.timedelta( hours = 7, minutes = 30 ) ) - - def testNegativeHalfIntegerTimezone( self ): - commit = self.repo.get_git_commit( "4303c5b90e2216d927155e9609436ccb8984c495" ) - self.assertEqual( commit.author.timezone, datetime.timedelta( hours = -7, minutes = -30 ) ) + def testConversion( self ): + commit = self.repo.get_git_commit( "73f320ae06cd565cf38faca34b6a482addfc721b" ) + self.assertEqual( commit.message, "Test commit created around Fri, 13 Jul 2012 18:43:21 GMT, that is vendredi 13 juillet 2012 20:43:21 GMT+2\n" ) + self.assertEqual( commit.author.date, datetime.datetime( 2012, 7, 13, 18, 47, 10 ) ) diff --git a/test/ReplayData/Issue54.setUp.txt b/test/ReplayData/Issue54.setUp.txt index 24c3651d..ca71e9c2 100644 --- a/test/ReplayData/Issue54.setUp.txt +++ b/test/ReplayData/Issue54.setUp.txt @@ -1,10 +1,10 @@ -GET /user {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4968'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"55f0187d26f5ca2e7103006d9837865c"'), ('date', 'Thu, 10 May 2012 19:05:23 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"total_private_repos":5,"html_url":"https://github.com/jacquev6","type":"User","url":"https://api.github.com/users/jacquev6","owned_private_repos":5,"disk_usage":16676,"plan":{"private_repos":5,"collaborators":1,"space":614400,"name":"micro"},"public_gists":1,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","blog":"http://vincent-jacques.net","private_gists":5,"login":"jacquev6","public_repos":10,"email":"vincent@vincent-jacques.net","collaborators":0,"created_at":"2010-07-09T06:10:06Z","company":"Criteo","location":"Paris, France","hireable":false,"followers":13,"following":24,"name":"Vincent Jacques","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","bio":"","id":327146} - -GET /repos/jacquev6/PyGithub {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4967'), ('content-length', '1097'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"72a84ed8ad0d83f6a4c09dcd388c20a1"'), ('date', 'Thu, 10 May 2012 19:05:27 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"homepage":"http://vincent-jacques.net/PyGithub","clone_url":"https://github.com/jacquev6/PyGithub.git","html_url":"https://github.com/jacquev6/PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub","has_downloads":true,"watchers":13,"permissions":{"admin":true,"pull":true,"push":true},"mirror_url":null,"has_wiki":false,"has_issues":true,"fork":false,"forks":2,"language":"Python","size":196,"description":"Python library implementing the full Github API v3","git_url":"git://github.com/jacquev6/PyGithub.git","private":false,"created_at":"2012-02-25T12:53:47Z","open_issues":15,"svn_url":"https://github.com/jacquev6/PyGithub","owner":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146},"name":"PyGithub","pushed_at":"2012-05-10T18:49:21Z","id":3544490,"ssh_url":"git@github.com:jacquev6/PyGithub.git","updated_at":"2012-05-10T18:49:21Z"} - +GET /user {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('content-length', '801'), ('vary', 'Accept, Authorization, Cookie'), ('x-ratelimit-remaining', '4986'), ('server', 'nginx/1.0.13'), ('last-modified', 'Mon, 09 Jul 2012 06:49:53 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1bd2b9dfc8ba65f7665102d6245a1593"'), ('cache-control', 'private, max-age=60'), ('date', 'Fri, 13 Jul 2012 19:06:43 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"html_url":"https://github.com/jacquev6","type":"User","email":"vincent@vincent-jacques.net","created_at":"2010-07-09T06:10:06Z","collaborators":0,"followers":13,"company":"Criteo","plan":{"collaborators":1,"space":614400,"private_repos":5,"name":"micro"},"hireable":false,"gravatar_id":"b68de5ae38616c296fa345d2b9df2225","disk_usage":16468,"blog":"http://vincent-jacques.net","bio":"","public_gists":3,"total_private_repos":3,"public_repos":12,"private_gists":5,"name":"Vincent Jacques","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","owned_private_repos":3,"following":26,"location":"Paris, France","id":327146,"login":"jacquev6","url":"https://api.github.com/users/jacquev6"} + +GET /repos/jacquev6/TestRepo {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('x-ratelimit-limit', '5000'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1172'), ('server', 'nginx/1.0.13'), ('last-modified', 'Fri, 13 Jul 2012 18:48:49 GMT'), ('connection', 'keep-alive'), ('etag', '"385e2f22f9b54b1d56fc731de0d5c9bc"'), ('cache-control', 'private, max-age=60'), ('date', 'Fri, 13 Jul 2012 19:06:44 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"permissions":{"push":true,"admin":true,"pull":true},"open_issues":0,"clone_url":"https://github.com/jacquev6/TestRepo.git","ssh_url":"git@github.com:jacquev6/TestRepo.git","owner":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jacquev6","id":327146,"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225"},"description":"Test repository created around Fri, 13 Jul 2012 18:43:21 GMT, that is vendredi 13 juillet 2012 20:43:21 GMT+2","master_branch":"master","mirror_url":null,"has_issues":true,"html_url":"https://github.com/jacquev6/TestRepo","pushed_at":"2012-07-13T18:47:21Z","forks":1,"has_downloads":true,"created_at":"2012-07-13T18:45:21Z","full_name":"jacquev6/TestRepo","language":null,"size":96,"fork":false,"svn_url":"https://github.com/jacquev6/TestRepo","has_wiki":true,"watchers":1,"updated_at":"2012-07-13T18:48:49Z","name":"TestRepo","git_url":"git://github.com/jacquev6/TestRepo.git","private":false,"id":5023526,"homepage":null,"url":"https://api.github.com/repos/jacquev6/TestRepo"} + diff --git a/test/ReplayData/Issue54.testConversion.txt b/test/ReplayData/Issue54.testConversion.txt new file mode 100644 index 00000000..fc0800db --- /dev/null +++ b/test/ReplayData/Issue54.testConversion.txt @@ -0,0 +1,5 @@ +GET /repos/jacquev6/TestRepo/git/commits/73f320ae06cd565cf38faca34b6a482addfc721b {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('content-length', '676'), ('vary', 'Accept, Authorization, Cookie'), ('x-ratelimit-remaining', '4984'), ('server', 'nginx/1.0.13'), ('last-modified', 'Fri, 13 Jul 2012 18:47:10 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"ab832024b149674b5210a1a3b146575c"'), ('cache-control', 'private, max-age=60'), ('date', 'Fri, 13 Jul 2012 19:06:44 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"committer":{"email":"vincent@vincent-jacques.net","date":"2012-07-13T11:47:10-07:00","name":"Vincent Jacques"},"message":"Test commit created around Fri, 13 Jul 2012 18:43:21 GMT, that is vendredi 13 juillet 2012 20:43:21 GMT+2\n","sha":"73f320ae06cd565cf38faca34b6a482addfc721b","tree":{"sha":"52fe1ba4ac2b979c0a8fbeb9f87c1b1c9f177520","url":"https://api.github.com/repos/jacquev6/TestRepo/git/trees/52fe1ba4ac2b979c0a8fbeb9f87c1b1c9f177520"},"author":{"email":"vincent@vincent-jacques.net","date":"2012-07-13T11:47:10-07:00","name":"Vincent Jacques"},"parents":[],"url":"https://api.github.com/repos/jacquev6/TestRepo/git/commits/73f320ae06cd565cf38faca34b6a482addfc721b"} + diff --git a/test/ReplayData/Issue54.testNegativeHalfIntegerTimezone.txt b/test/ReplayData/Issue54.testNegativeHalfIntegerTimezone.txt deleted file mode 100644 index 0e51b344..00000000 --- a/test/ReplayData/Issue54.testNegativeHalfIntegerTimezone.txt +++ /dev/null @@ -1,5 +0,0 @@ -GET /repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495 {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4966'), ('content-length', '910'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"eabd190c639b57d447ea6d3463da7aae"'), ('date', 'Thu, 10 May 2012 19:05:28 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495","message":"Merge branch 'develop'\n","committer":{"email":"vincent@vincent-jacques.net","date":"2012-04-17T10:55:16-07:00","name":"Vincent Jacques"},"sha":"4303c5b90e2216d927155e9609436ccb8984c495","parents":[{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/936f4a97f1a86392637ec002bbf89ff036a5062d","sha":"936f4a97f1a86392637ec002bbf89ff036a5062d"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/2a7e80e6421c5d4d201d60619068dea6bae612cb","sha":"2a7e80e6421c5d4d201d60619068dea6bae612cb"}],"tree":{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/trees/f492784d8ca837779650d1fb406a1a3587a764ad","sha":"f492784d8ca837779650d1fb406a1a3587a764ad"},"author":{"email":"vincent@vincent-jacques.net","date":"2012-04-17T10:55:16-07:30","name":"Vincent Jacques"}} - diff --git a/test/ReplayData/Issue54.testNegativeIntegerTimezone.txt b/test/ReplayData/Issue54.testNegativeIntegerTimezone.txt deleted file mode 100644 index 9a2b9e94..00000000 --- a/test/ReplayData/Issue54.testNegativeIntegerTimezone.txt +++ /dev/null @@ -1,5 +0,0 @@ -GET /repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495 {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4966'), ('content-length', '910'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"eabd190c639b57d447ea6d3463da7aae"'), ('date', 'Thu, 10 May 2012 19:05:28 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495","message":"Merge branch 'develop'\n","committer":{"email":"vincent@vincent-jacques.net","date":"2012-04-17T10:55:16-07:00","name":"Vincent Jacques"},"sha":"4303c5b90e2216d927155e9609436ccb8984c495","parents":[{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/936f4a97f1a86392637ec002bbf89ff036a5062d","sha":"936f4a97f1a86392637ec002bbf89ff036a5062d"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/2a7e80e6421c5d4d201d60619068dea6bae612cb","sha":"2a7e80e6421c5d4d201d60619068dea6bae612cb"}],"tree":{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/trees/f492784d8ca837779650d1fb406a1a3587a764ad","sha":"f492784d8ca837779650d1fb406a1a3587a764ad"},"author":{"email":"vincent@vincent-jacques.net","date":"2012-04-17T10:55:16-07:00","name":"Vincent Jacques"}} - diff --git a/test/ReplayData/Issue54.testPositiveHalfIntegerTimezone.txt b/test/ReplayData/Issue54.testPositiveHalfIntegerTimezone.txt deleted file mode 100644 index d35c8dcd..00000000 --- a/test/ReplayData/Issue54.testPositiveHalfIntegerTimezone.txt +++ /dev/null @@ -1,5 +0,0 @@ -GET /repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495 {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4966'), ('content-length', '910'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"eabd190c639b57d447ea6d3463da7aae"'), ('date', 'Thu, 10 May 2012 19:05:28 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495","message":"Merge branch 'develop'\n","committer":{"email":"vincent@vincent-jacques.net","date":"2012-04-17T10:55:16-07:00","name":"Vincent Jacques"},"sha":"4303c5b90e2216d927155e9609436ccb8984c495","parents":[{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/936f4a97f1a86392637ec002bbf89ff036a5062d","sha":"936f4a97f1a86392637ec002bbf89ff036a5062d"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/2a7e80e6421c5d4d201d60619068dea6bae612cb","sha":"2a7e80e6421c5d4d201d60619068dea6bae612cb"}],"tree":{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/trees/f492784d8ca837779650d1fb406a1a3587a764ad","sha":"f492784d8ca837779650d1fb406a1a3587a764ad"},"author":{"email":"vincent@vincent-jacques.net","date":"2012-04-17T10:55:16+07:30","name":"Vincent Jacques"}} - diff --git a/test/ReplayData/Issue54.testPositiveIntegerTimezone.txt b/test/ReplayData/Issue54.testPositiveIntegerTimezone.txt deleted file mode 100644 index d614219b..00000000 --- a/test/ReplayData/Issue54.testPositiveIntegerTimezone.txt +++ /dev/null @@ -1,5 +0,0 @@ -GET /repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495 {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4966'), ('content-length', '910'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"eabd190c639b57d447ea6d3463da7aae"'), ('date', 'Thu, 10 May 2012 19:05:28 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495","message":"Merge branch 'develop'\n","committer":{"email":"vincent@vincent-jacques.net","date":"2012-04-17T10:55:16-07:00","name":"Vincent Jacques"},"sha":"4303c5b90e2216d927155e9609436ccb8984c495","parents":[{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/936f4a97f1a86392637ec002bbf89ff036a5062d","sha":"936f4a97f1a86392637ec002bbf89ff036a5062d"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/2a7e80e6421c5d4d201d60619068dea6bae612cb","sha":"2a7e80e6421c5d4d201d60619068dea6bae612cb"}],"tree":{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/trees/f492784d8ca837779650d1fb406a1a3587a764ad","sha":"f492784d8ca837779650d1fb406a1a3587a764ad"},"author":{"email":"vincent@vincent-jacques.net","date":"2012-04-17T10:55:16+07:00","name":"Vincent Jacques"}} -