diff --git a/codegen/templates/GithubObject.AttributeValue.simple.py b/codegen/templates/GithubObject.AttributeValue.simple.py
index ef252328..77539093 100644
--- a/codegen/templates/GithubObject.AttributeValue.simple.py
+++ b/codegen/templates/GithubObject.AttributeValue.simple.py
@@ -1 +1 @@
-{% if attribute.type.name == "datetime" %}None if attributes[ "{{ attribute.name }}" ] is None else datetime.datetime.strptime( attributes[ "{{ attribute.name }}" ], "%Y-%m-%dT%H:%M:%SZ" ){% else %}attributes[ "{{ attribute.name }}" ]{% endif %}
\ No newline at end of file
+{% if attribute.type.name == "datetime" %}self._parseDatetime( attributes[ "{{ attribute.name }}" ] ){% else %}attributes[ "{{ attribute.name }}" ]{% endif %}
\ No newline at end of file
diff --git a/doc/ReferenceOfApis.md b/doc/ReferenceOfApis.md
index ce01775c..d9e91295 100644
--- a/doc/ReferenceOfApis.md
+++ b/doc/ReferenceOfApis.md
@@ -62,17 +62,25 @@ API `/legacy/issues/search/:owner/:repository/:state/:keyword`
* GET: `Repository.search_issues`
API `/legacy/repos/search/:keyword`
-==============================================================
+===================================
* GET: `Github.search_repos`
API `/legacy/user/search/:keyword`
-==============================================================
+==================================
* GET: `Github.search_users`
API `/legacy/user/email/:email`
-==============================================================
+===============================
* GET: `Github.search_user_by_email`
+API `/markdown`
+===============
+* POST: `Github.render_markdown`
+
+API `/markdown/raw`
+===================
+* POST: see API `/markdown`
+
API `/networks/:user/:repo/events`
==================================
* GET: `Repository.get_network_events`
diff --git a/doc/ReferenceOfClasses.md b/doc/ReferenceOfClasses.md
index 485c5348..410bfdc7 100644
--- a/doc/ReferenceOfClasses.md
+++ b/doc/ReferenceOfClasses.md
@@ -27,7 +27,7 @@ Methods
* `get_user( login )`: `NamedUser`
* `get_organization( login )`: `Organization`
* `get_gist( id )`: `Gist`
- * `id`: integer
+ * `id`: string
* `get_gists()`: iterator of `Gist`
* `search_repos( keyword )`: iterator of `Repository`
* `legacy_search_repos( keyword, [language] )`: iterator of `Repository`
@@ -37,6 +37,9 @@ Methods
* `keyword`: string
* `legacy_search_user_by_email( email )`: `NamedUser`
* `email`: string
+* `render_markdown( text, [context] )`: string
+ * `text`: string
+ * `context`: `Repository`
Class `GithubException`
=======================
@@ -56,7 +59,7 @@ Attributes
* `blog`: string
* `collaborators`: integer
* `company`: string
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `disk_usage`: integer
* `email`: string
* `followers`: integer
@@ -190,13 +193,13 @@ Class `Authorization`
Attributes
----------
* `app`: `AuthorizationApplication`
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `id`: integer
* `note`: string
* `note_url`: string
* `scopes`: list of string
* `token`: string
-* `updated_at`: datetime
+* `updated_at`: datetime.datetime
* `url`: string
Deletion
@@ -258,13 +261,13 @@ Attributes
----------
* `body`: string
* `commit_id`: string
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `html_url`: string
* `id`: integer
* `line`: integer
* `path`: string
* `position`: integer
-* `updated_at`: datetime
+* `updated_at`: datetime.datetime
* `url`: string
* `user`: `NamedUser`
@@ -313,10 +316,10 @@ Attributes
* `acl`: string
* `bucket`: string
* `content_type`: string
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `description`: string
* `download_count`: integer
-* `expirationdate`: datetime
+* `expirationdate`: datetime.datetime
* `html_url`: string
* `id`: integer
* `mime_type`: string
@@ -340,7 +343,7 @@ Class `Event`
Attributes
----------
* `actor`: `NamedUser`
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `id`: string
* `org`: `Organization`
* `payload`: dict
@@ -369,7 +372,7 @@ Class `Gist`
Attributes
----------
* `comments`: integer
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `description`: string
* `files`: dict of string to `GistFile`
* `fork_of`: `Gist`
@@ -380,7 +383,7 @@ Attributes
* `html_url`: string
* `id`: string
* `public`: bool
-* `updated_at`: datetime
+* `updated_at`: datetime.datetime
* `url`: string
* `user`: `NamedUser`
@@ -418,9 +421,9 @@ Class `GistComment`
Attributes
----------
* `body`: string
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `id`: integer
-* `updated_at`: datetime
+* `updated_at`: datetime.datetime
* `url`: string
* `user`: `NamedUser`
@@ -450,7 +453,7 @@ Class `GistHistoryState`
Attributes
----------
* `change_status`: `CommitStats`
-* `committed_at`: datetime
+* `committed_at`: datetime.datetime
* `url`: string
* `user`: `NamedUser`
* `version`: string
@@ -460,7 +463,7 @@ Class `GitAuthor`
Attributes
----------
-* `date`: string
+* `date`: datetime.datetime
* `email`: string
* `name`: string
@@ -556,12 +559,12 @@ Attributes
----------
* `active`: bool
* `config`: dict
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `events`: list of string
* `id`: integer
* `last_response`: `HookResponse`
* `name`: string
-* `updated_at`: datetime
+* `updated_at`: datetime.datetime
* `url`: string
Deletion
@@ -598,10 +601,10 @@ Attributes
----------
* `assignee`: `NamedUser`
* `body`: string
-* `closed_at`: datetime
+* `closed_at`: datetime.datetime
* `closed_by`: `NamedUser`
* `comments`: integer
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `html_url`: string
* `id`: integer
* `labels`: list of `Label`
@@ -611,7 +614,7 @@ Attributes
* `repository`: `Repository`
* `state`: string
* `title`: string
-* `updated_at`: datetime
+* `updated_at`: datetime.datetime
* `url`: string
* `user`: `NamedUser`
@@ -654,9 +657,9 @@ Class `IssueComment`
Attributes
----------
* `body`: string
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `id`: integer
-* `updated_at`: datetime
+* `updated_at`: datetime.datetime
* `url`: string
* `user`: `NamedUser`
@@ -676,7 +679,7 @@ Attributes
----------
* `actor`: `NamedUser`
* `commit_id`: string
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `event`: string
* `id`: integer
* `issue`: `Issue`
@@ -716,10 +719,10 @@ Class `Milestone`
Attributes
----------
* `closed_issues`: integer
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `creator`: `NamedUser`
* `description`: string
-* `due_on`: datetime
+* `due_on`: datetime.datetime
* `id`: integer
* `number`: integer
* `open_issues`: integer
@@ -754,7 +757,7 @@ Attributes
* `collaborators`: integer
* `company`: string
* `contributions`: integer
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `disk_usage`: integer
* `email`: string
* `followers`: integer
@@ -823,7 +826,7 @@ Attributes
* `blog`: string
* `collaborators`: integer
* `company`: string
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `disk_usage`: integer
* `email`: string
* `followers`: integer
@@ -934,10 +937,10 @@ Attributes
* `base`: `PullRequestPart`
* `body`: string
* `changed_files`: integer
-* `closed_at`: datetime
+* `closed_at`: datetime.datetime
* `comments`: integer
* `commits`: integer
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `deletions`: integer
* `diff_url`: string
* `head`: `PullRequestPart`
@@ -946,14 +949,14 @@ Attributes
* `issue_url`: string
* `mergeable`: bool
* `merged`: bool
-* `merged_at`: datetime
+* `merged_at`: datetime.datetime
* `merged_by`: `NamedUser`
* `number`: integer
* `patch_url`: string
* `review_comments`: integer
* `state`: string
* `title`: string
-* `updated_at`: datetime
+* `updated_at`: datetime.datetime
* `url`: string
* `user`: `NamedUser`
@@ -996,13 +999,13 @@ Attributes
----------
* `body`: string
* `commit_id`: string
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `id`: integer
* `original_commit_id`: string
* `original_position`: integer
* `path`: string
* `position`: integer
-* `updated_at`: datetime
+* `updated_at`: datetime.datetime
* `url`: string
* `user`: `NamedUser`
@@ -1041,7 +1044,7 @@ Class `Repository`
Attributes
----------
* `clone_url`: string
-* `created_at`: datetime
+* `created_at`: datetime.datetime
* `description`: string
* `fork`: bool
* `forks`: integer
@@ -1062,12 +1065,12 @@ Attributes
* `parent`: `Repository`
* `permissions`: `Permissions`
* `private`: bool
-* `pushed_at`: datetime
+* `pushed_at`: datetime.datetime
* `size`: integer
* `source`: `Repository`
* `ssh_url`: string
* `svn_url`: string
-* `updated_at`: datetime
+* `updated_at`: datetime.datetime
* `url`: string
* `watchers`: integer
@@ -1206,7 +1209,7 @@ Issues
* `labels`: list of `Label`
* `sort`: string
* `direction`: string
- * `since`: datetime
+ * `since`: datetime.datetime
* `legacy_search_issues( state, keyword )`: iterator of `Issue`
* `state`: "open" or "closed"
* `keyword`: string
diff --git a/github/AuthenticatedUser.py b/github/AuthenticatedUser.py
index f2becfd4..e6247558 100644
--- a/github/AuthenticatedUser.py
+++ b/github/AuthenticatedUser.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import PaginatedList
@@ -619,7 +617,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
self._company = attributes[ "company" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "disk_usage" in attributes: # pragma no branch
assert attributes[ "disk_usage" ] is None or isinstance( attributes[ "disk_usage" ], int ), attributes[ "disk_usage" ]
self._disk_usage = attributes[ "disk_usage" ]
diff --git a/github/Authorization.py b/github/Authorization.py
index 558d7919..96732f16 100644
--- a/github/Authorization.py
+++ b/github/Authorization.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import AuthorizationApplication
@@ -116,7 +114,7 @@ class Authorization( GithubObject.GithubObject ):
self._app = None if attributes[ "app" ] is None else AuthorizationApplication.AuthorizationApplication( self._requester, attributes[ "app" ], completed = False )
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
@@ -134,7 +132,7 @@ class Authorization( GithubObject.GithubObject ):
self._token = attributes[ "token" ]
if "updated_at" in attributes: # pragma no branch
assert attributes[ "updated_at" ] is None or isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ]
- self._updated_at = None if attributes[ "updated_at" ] is None else datetime.datetime.strptime( attributes[ "updated_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._updated_at = self._parseDatetime( attributes[ "updated_at" ] )
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
diff --git a/github/CommitComment.py b/github/CommitComment.py
index a12319da..f55f69a7 100644
--- a/github/CommitComment.py
+++ b/github/CommitComment.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import NamedUser
@@ -119,7 +117,7 @@ class CommitComment( GithubObject.GithubObject ):
self._commit_id = attributes[ "commit_id" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "html_url" in attributes: # pragma no branch
assert attributes[ "html_url" ] is None or isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ]
self._html_url = attributes[ "html_url" ]
@@ -137,7 +135,7 @@ class CommitComment( GithubObject.GithubObject ):
self._position = attributes[ "position" ]
if "updated_at" in attributes: # pragma no branch
assert attributes[ "updated_at" ] is None or isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ]
- self._updated_at = None if attributes[ "updated_at" ] is None else datetime.datetime.strptime( attributes[ "updated_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._updated_at = self._parseDatetime( attributes[ "updated_at" ] )
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
diff --git a/github/Download.py b/github/Download.py
index 067706e6..9edfb7cb 100644
--- a/github/Download.py
+++ b/github/Download.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
class Download( GithubObject.GithubObject ):
@@ -164,7 +162,7 @@ class Download( GithubObject.GithubObject ):
self._content_type = attributes[ "content_type" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "description" in attributes: # pragma no branch
assert attributes[ "description" ] is None or isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ]
self._description = attributes[ "description" ]
@@ -173,7 +171,7 @@ class Download( GithubObject.GithubObject ):
self._download_count = attributes[ "download_count" ]
if "expirationdate" in attributes: # pragma no branch
assert attributes[ "expirationdate" ] is None or isinstance( attributes[ "expirationdate" ], ( str, unicode ) ), attributes[ "expirationdate" ]
- self._expirationdate = None if attributes[ "expirationdate" ] is None else datetime.datetime.strptime( attributes[ "expirationdate" ], "%Y-%m-%dT%H:%M:%S.000Z" )
+ self._expirationdate = self._parseDatetime( attributes[ "expirationdate" ] )
if "html_url" in attributes: # pragma no branch
assert attributes[ "html_url" ] is None or isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ]
self._html_url = attributes[ "html_url" ]
diff --git a/github/Event.py b/github/Event.py
index c76759c3..13c794b2 100644
--- a/github/Event.py
+++ b/github/Event.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import Organization
@@ -71,7 +69,7 @@ class Event( GithubObject.BasicGithubObject ):
self._actor = None if attributes[ "actor" ] is None else NamedUser.NamedUser( self._requester, attributes[ "actor" ], completed = False )
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], ( str, unicode ) ), attributes[ "id" ]
self._id = attributes[ "id" ]
diff --git a/github/Gist.py b/github/Gist.py
index e819429a..03c7b268 100644
--- a/github/Gist.py
+++ b/github/Gist.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import PaginatedList
@@ -220,7 +218,7 @@ class Gist( GithubObject.GithubObject ):
self._comments = attributes[ "comments" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "description" in attributes: # pragma no branch
assert attributes[ "description" ] is None or isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ]
self._description = attributes[ "description" ]
@@ -262,7 +260,7 @@ class Gist( GithubObject.GithubObject ):
self._public = attributes[ "public" ]
if "updated_at" in attributes: # pragma no branch
assert attributes[ "updated_at" ] is None or isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ]
- self._updated_at = None if attributes[ "updated_at" ] is None else datetime.datetime.strptime( attributes[ "updated_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._updated_at = self._parseDatetime( attributes[ "updated_at" ] )
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
diff --git a/github/GistComment.py b/github/GistComment.py
index 6cf8dcd3..fa98ea0c 100644
--- a/github/GistComment.py
+++ b/github/GistComment.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import NamedUser
@@ -86,13 +84,13 @@ class GistComment( GithubObject.GithubObject ):
self._body = attributes[ "body" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "updated_at" in attributes: # pragma no branch
assert attributes[ "updated_at" ] is None or isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ]
- self._updated_at = None if attributes[ "updated_at" ] is None else datetime.datetime.strptime( attributes[ "updated_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._updated_at = self._parseDatetime( attributes[ "updated_at" ] )
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
diff --git a/github/GistHistoryState.py b/github/GistHistoryState.py
index e4b88789..018968ea 100644
--- a/github/GistHistoryState.py
+++ b/github/GistHistoryState.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import NamedUser
@@ -60,7 +58,7 @@ class GistHistoryState( GithubObject.GithubObject ):
self._change_status = None if attributes[ "change_status" ] is None else CommitStats.CommitStats( self._requester, attributes[ "change_status" ], completed = False )
if "committed_at" in attributes: # pragma no branch
assert attributes[ "committed_at" ] is None or isinstance( attributes[ "committed_at" ], ( str, unicode ) ), attributes[ "committed_at" ]
- self._committed_at = None if attributes[ "committed_at" ] is None else datetime.datetime.strptime( attributes[ "committed_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._committed_at = self._parseDatetime( attributes[ "committed_at" ] )
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
diff --git a/github/GitAuthor.py b/github/GitAuthor.py
index c997b499..0f9cc80e 100644
--- a/github/GitAuthor.py
+++ b/github/GitAuthor.py
@@ -37,7 +37,7 @@ class GitAuthor( GithubObject.BasicGithubObject ):
def _useAttributes( self, attributes ):
if "date" in attributes: # pragma no branch
assert attributes[ "date" ] is None or isinstance( attributes[ "date" ], ( str, unicode ) ), attributes[ "date" ]
- self._date = attributes[ "date" ]
+ self._date = self._parseDatetime( 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/Github.py b/github/Github.py
index 3b388512..53480ac1 100644
--- a/github/Github.py
+++ b/github/Github.py
@@ -31,8 +31,9 @@ class Github( object ):
def rate_limiting( self ):
return self.__requester.rate_limiting
- def get_user( self, login = None ):
- if login is None:
+ def get_user( self, login = GithubObject.NotSet ):
+ assert login is GithubObject.NotSet or isinstance( login, ( str, unicode ) ), login
+ if login is GithubObject.NotSet:
return AuthenticatedUser.AuthenticatedUser( self.__requester, { "url": "https://api.github.com/user" }, completed = False )
else:
headers, data = self.__requester.requestAndCheck(
@@ -44,6 +45,7 @@ class Github( object ):
return NamedUser.NamedUser( self.__requester, data, completed = True )
def get_organization( self, login ):
+ assert isinstance( login, ( str, unicode ) ), login
headers, data = self.__requester.requestAndCheck(
"GET",
"https://api.github.com/orgs/" + login,
@@ -53,9 +55,10 @@ class Github( object ):
return Organization.Organization( self.__requester, data, completed = True )
def get_gist( self, id ):
+ assert isinstance( id, ( str, unicode ) ), id
headers, data = self.__requester.requestAndCheck(
"GET",
- "https://api.github.com/gists/" + str( id ),
+ "https://api.github.com/gists/" + id,
None,
None
)
@@ -103,3 +106,20 @@ class Github( object ):
None
)
return NamedUser.NamedUser( self.__requester, Legacy.convertUser( data[ "user" ] ), completed = False )
+
+ def render_markdown( self, text, context = GithubObject.NotSet ):
+ assert isinstance( text, ( str, unicode ) ), text
+ assert context is GithubObject.NotSet or isinstance( context, Repository.Repository ), context
+ post_parameters = {
+ "text": text
+ }
+ if context is not GithubObject.NotSet:
+ post_parameters[ "mode" ] = "gfm"
+ post_parameters[ "context" ] = context._identity
+ status, headers, data = self.__requester.requestRaw(
+ "POST",
+ "https://api.github.com/markdown",
+ None,
+ post_parameters
+ )
+ return data
diff --git a/github/GithubObject.py b/github/GithubObject.py
index 9ce17990..22ee9c19 100644
--- a/github/GithubObject.py
+++ b/github/GithubObject.py
@@ -11,6 +11,8 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
+import datetime
+
import GithubException
class _NotSetType:
@@ -34,6 +36,17 @@ class BasicGithubObject( object ):
else:
return value
+ @staticmethod
+ def _parseDatetime( s ):
+ if s is None:
+ return None
+ 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" ) + ( 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" )
+
class GithubObject( BasicGithubObject ):
def __init__( self, requester, attributes, completed ):
BasicGithubObject.__init__( self, requester, attributes, completed )
diff --git a/github/Hook.py b/github/Hook.py
index 22725933..74de282c 100644
--- a/github/Hook.py
+++ b/github/Hook.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import HookResponse
@@ -129,7 +127,7 @@ class Hook( GithubObject.GithubObject ):
self._config = attributes[ "config" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "events" in attributes: # pragma no branch
assert attributes[ "events" ] is None or all( isinstance( element, ( str, unicode ) ) for element in attributes[ "events" ] ), attributes[ "events" ]
self._events = attributes[ "events" ]
@@ -144,7 +142,7 @@ class Hook( GithubObject.GithubObject ):
self._name = attributes[ "name" ]
if "updated_at" in attributes: # pragma no branch
assert attributes[ "updated_at" ] is None or isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ]
- self._updated_at = None if attributes[ "updated_at" ] is None else datetime.datetime.strptime( attributes[ "updated_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._updated_at = self._parseDatetime( attributes[ "updated_at" ] )
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
diff --git a/github/Issue.py b/github/Issue.py
index aeb7c0c6..333facdc 100644
--- a/github/Issue.py
+++ b/github/Issue.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import PaginatedList
@@ -281,7 +279,7 @@ class Issue( GithubObject.GithubObject ):
self._body = attributes[ "body" ]
if "closed_at" in attributes: # pragma no branch
assert attributes[ "closed_at" ] is None or isinstance( attributes[ "closed_at" ], ( str, unicode ) ), attributes[ "closed_at" ]
- self._closed_at = None if attributes[ "closed_at" ] is None else datetime.datetime.strptime( attributes[ "closed_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._closed_at = self._parseDatetime( attributes[ "closed_at" ] )
if "closed_by" in attributes: # pragma no branch
assert attributes[ "closed_by" ] is None or isinstance( attributes[ "closed_by" ], dict ), attributes[ "closed_by" ]
self._closed_by = None if attributes[ "closed_by" ] is None else NamedUser.NamedUser( self._requester, attributes[ "closed_by" ], completed = False )
@@ -290,7 +288,7 @@ class Issue( GithubObject.GithubObject ):
self._comments = attributes[ "comments" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "html_url" in attributes: # pragma no branch
assert attributes[ "html_url" ] is None or isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ]
self._html_url = attributes[ "html_url" ]
@@ -323,7 +321,7 @@ class Issue( GithubObject.GithubObject ):
self._title = attributes[ "title" ]
if "updated_at" in attributes: # pragma no branch
assert attributes[ "updated_at" ] is None or isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ]
- self._updated_at = None if attributes[ "updated_at" ] is None else datetime.datetime.strptime( attributes[ "updated_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._updated_at = self._parseDatetime( attributes[ "updated_at" ] )
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
diff --git a/github/IssueComment.py b/github/IssueComment.py
index de363fea..396e82f1 100644
--- a/github/IssueComment.py
+++ b/github/IssueComment.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import NamedUser
@@ -86,13 +84,13 @@ class IssueComment( GithubObject.GithubObject ):
self._body = attributes[ "body" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "updated_at" in attributes: # pragma no branch
assert attributes[ "updated_at" ] is None or isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ]
- self._updated_at = None if attributes[ "updated_at" ] is None else datetime.datetime.strptime( attributes[ "updated_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._updated_at = self._parseDatetime( attributes[ "updated_at" ] )
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
diff --git a/github/IssueEvent.py b/github/IssueEvent.py
index 60b816c5..0b930da0 100644
--- a/github/IssueEvent.py
+++ b/github/IssueEvent.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import Issue
@@ -75,7 +73,7 @@ class IssueEvent( GithubObject.GithubObject ):
self._commit_id = attributes[ "commit_id" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "event" in attributes: # pragma no branch
assert attributes[ "event" ] is None or isinstance( attributes[ "event" ], ( str, unicode ) ), attributes[ "event" ]
self._event = attributes[ "event" ]
diff --git a/github/Milestone.py b/github/Milestone.py
index c546910e..0682336b 100644
--- a/github/Milestone.py
+++ b/github/Milestone.py
@@ -145,7 +145,7 @@ class Milestone( GithubObject.GithubObject ):
self._closed_issues = attributes[ "closed_issues" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "creator" in attributes: # pragma no branch
assert attributes[ "creator" ] is None or isinstance( attributes[ "creator" ], dict ), attributes[ "creator" ]
self._creator = None if attributes[ "creator" ] is None else NamedUser.NamedUser( self._requester, attributes[ "creator" ], completed = False )
@@ -154,7 +154,7 @@ class Milestone( GithubObject.GithubObject ):
self._description = attributes[ "description" ]
if "due_on" in attributes: # pragma no branch
assert attributes[ "due_on" ] is None or isinstance( attributes[ "due_on" ], ( str, unicode ) ), attributes[ "due_on" ]
- self._due_on = None if attributes[ "due_on" ] is None else datetime.datetime.strptime( attributes[ "due_on" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._due_on = self._parseDatetime( attributes[ "due_on" ] )
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
diff --git a/github/NamedUser.py b/github/NamedUser.py
index 8a1e4f12..f6f806ca 100644
--- a/github/NamedUser.py
+++ b/github/NamedUser.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import PaginatedList
@@ -383,7 +381,7 @@ class NamedUser( GithubObject.GithubObject ):
self._contributions = attributes[ "contributions" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "disk_usage" in attributes: # pragma no branch
assert attributes[ "disk_usage" ] is None or isinstance( attributes[ "disk_usage" ], int ), attributes[ "disk_usage" ]
self._disk_usage = attributes[ "disk_usage" ]
diff --git a/github/Organization.py b/github/Organization.py
index 0ab91c40..2ca1af19 100644
--- a/github/Organization.py
+++ b/github/Organization.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import PaginatedList
@@ -425,7 +423,7 @@ class Organization( GithubObject.GithubObject ):
self._company = attributes[ "company" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "disk_usage" in attributes: # pragma no branch
assert attributes[ "disk_usage" ] is None or isinstance( attributes[ "disk_usage" ], int ), attributes[ "disk_usage" ]
self._disk_usage = attributes[ "disk_usage" ]
diff --git a/github/PullRequest.py b/github/PullRequest.py
index cf626f56..52b788cb 100644
--- a/github/PullRequest.py
+++ b/github/PullRequest.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import PaginatedList
@@ -312,7 +310,7 @@ class PullRequest( GithubObject.GithubObject ):
self._changed_files = attributes[ "changed_files" ]
if "closed_at" in attributes: # pragma no branch
assert attributes[ "closed_at" ] is None or isinstance( attributes[ "closed_at" ], ( str, unicode ) ), attributes[ "closed_at" ]
- self._closed_at = None if attributes[ "closed_at" ] is None else datetime.datetime.strptime( attributes[ "closed_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._closed_at = self._parseDatetime( attributes[ "closed_at" ] )
if "comments" in attributes: # pragma no branch
assert attributes[ "comments" ] is None or isinstance( attributes[ "comments" ], int ), attributes[ "comments" ]
self._comments = attributes[ "comments" ]
@@ -321,7 +319,7 @@ class PullRequest( GithubObject.GithubObject ):
self._commits = attributes[ "commits" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "deletions" in attributes: # pragma no branch
assert attributes[ "deletions" ] is None or isinstance( attributes[ "deletions" ], int ), attributes[ "deletions" ]
self._deletions = attributes[ "deletions" ]
@@ -348,7 +346,7 @@ class PullRequest( GithubObject.GithubObject ):
self._merged = attributes[ "merged" ]
if "merged_at" in attributes: # pragma no branch
assert attributes[ "merged_at" ] is None or isinstance( attributes[ "merged_at" ], ( str, unicode ) ), attributes[ "merged_at" ]
- self._merged_at = None if attributes[ "merged_at" ] is None else datetime.datetime.strptime( attributes[ "merged_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._merged_at = self._parseDatetime( attributes[ "merged_at" ] )
if "merged_by" in attributes: # pragma no branch
assert attributes[ "merged_by" ] is None or isinstance( attributes[ "merged_by" ], dict ), attributes[ "merged_by" ]
self._merged_by = None if attributes[ "merged_by" ] is None else NamedUser.NamedUser( self._requester, attributes[ "merged_by" ], completed = False )
@@ -369,7 +367,7 @@ class PullRequest( GithubObject.GithubObject ):
self._title = attributes[ "title" ]
if "updated_at" in attributes: # pragma no branch
assert attributes[ "updated_at" ] is None or isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ]
- self._updated_at = None if attributes[ "updated_at" ] is None else datetime.datetime.strptime( attributes[ "updated_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._updated_at = self._parseDatetime( attributes[ "updated_at" ] )
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
diff --git a/github/PullRequestComment.py b/github/PullRequestComment.py
index c0ca23c6..0bc86f2b 100644
--- a/github/PullRequestComment.py
+++ b/github/PullRequestComment.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
-import datetime
-
import GithubObject
import NamedUser
@@ -119,7 +117,7 @@ class PullRequestComment( GithubObject.GithubObject ):
self._commit_id = attributes[ "commit_id" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
@@ -137,7 +135,7 @@ class PullRequestComment( GithubObject.GithubObject ):
self._position = attributes[ "position" ]
if "updated_at" in attributes: # pragma no branch
assert attributes[ "updated_at" ] is None or isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ]
- self._updated_at = None if attributes[ "updated_at" ] is None else datetime.datetime.strptime( attributes[ "updated_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._updated_at = self._parseDatetime( attributes[ "updated_at" ] )
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
diff --git a/github/Repository.py b/github/Repository.py
index 32237a9f..f39f2c6a 100644
--- a/github/Repository.py
+++ b/github/Repository.py
@@ -1059,7 +1059,7 @@ class Repository( GithubObject.GithubObject ):
self._clone_url = attributes[ "clone_url" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
- self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "description" in attributes: # pragma no branch
assert attributes[ "description" ] is None or isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ]
self._description = attributes[ "description" ]
@@ -1122,7 +1122,7 @@ class Repository( GithubObject.GithubObject ):
self._private = attributes[ "private" ]
if "pushed_at" in attributes: # pragma no branch
assert attributes[ "pushed_at" ] is None or isinstance( attributes[ "pushed_at" ], ( str, unicode ) ), attributes[ "pushed_at" ]
- self._pushed_at = None if attributes[ "pushed_at" ] is None else datetime.datetime.strptime( attributes[ "pushed_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._pushed_at = self._parseDatetime( attributes[ "pushed_at" ] )
if "size" in attributes: # pragma no branch
assert attributes[ "size" ] is None or isinstance( attributes[ "size" ], int ), attributes[ "size" ]
self._size = attributes[ "size" ]
@@ -1137,7 +1137,7 @@ class Repository( GithubObject.GithubObject ):
self._svn_url = attributes[ "svn_url" ]
if "updated_at" in attributes: # pragma no branch
assert attributes[ "updated_at" ] is None or isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ]
- self._updated_at = None if attributes[ "updated_at" ] is None else datetime.datetime.strptime( attributes[ "updated_at" ], "%Y-%m-%dT%H:%M:%SZ" )
+ self._updated_at = self._parseDatetime( attributes[ "updated_at" ] )
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
diff --git a/github/Requester.py b/github/Requester.py
index 6bce409f..d6aa41ff 100644
--- a/github/Requester.py
+++ b/github/Requester.py
@@ -36,6 +36,7 @@ class Requester:
def requestAndCheck( self, verb, url, parameters, input ):
status, headers, output = self.requestRaw( verb, url, parameters, input )
+ output = self.__structuredFromJson( output )
if status >= 400:
raise GithubException.GithubException( status, output )
return headers, output
@@ -60,7 +61,7 @@ class Requester:
status = response.status
headers = dict( response.getheaders() )
- output = self.__structuredFromJson( response.read() )
+ output = response.read()
cnx.close()
diff --git a/publish.sh b/publish.sh
new file mode 100644
index 00000000..639cf20e
--- /dev/null
+++ b/publish.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+cp -r *.md doc COPYING* github
+
+python setup.py sdist
+
+rm -rf github/*.md github/doc github/COPYING*
+
+echo "Type 'yes' if everything is right and you want to publish the package"
+read yes
+if [ "x$yes" == "xyes" ]
+then
+ python setup.py upload
+fi
diff --git a/setup.py b/setup.py
index 0dbac04a..668a8ed2 100644
--- a/setup.py
+++ b/setup.py
@@ -55,7 +55,7 @@ setup(
"github",
],
package_data = {
- "github": [ "../ReadMe.md", "../COPYING*", "../doc/*.md" ]
+ "github": [ "ReadMe.md", "COPYING*", "doc/*.md" ]
},
classifiers = [
"Development Status :: 5 - Production/Stable",
diff --git a/test/GitCommit.py b/test/GitCommit.py
index 31617775..961e9f17 100644
--- a/test/GitCommit.py
+++ b/test/GitCommit.py
@@ -11,6 +11,8 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
+import datetime
+
import Framework
class GitCommit( Framework.TestCase ):
@@ -21,10 +23,12 @@ class GitCommit( Framework.TestCase ):
def testAttributes( self ):
self.assertEqual( self.commit.author.name, "Vincent Jacques" )
self.assertEqual( self.commit.author.email, "vincent@vincent-jacques.net" )
- self.assertEqual( self.commit.author.date, "2012-04-17T10:55:16-07:00" )
+ self.assertEqual( self.commit.author.date, datetime.datetime( 2012, 4, 17, 10, 55, 16 ) )
+ self.assertEqual( self.commit.author.timezone, datetime.timedelta( hours = -7 ) )
self.assertEqual( self.commit.committer.name, "Vincent Jacques" )
self.assertEqual( self.commit.committer.email, "vincent@vincent-jacques.net" )
- self.assertEqual( self.commit.committer.date, "2012-04-17T10:55:16-07:00" )
+ self.assertEqual( self.commit.committer.date, datetime.datetime( 2012, 4, 17, 10, 55, 16 ) )
+ self.assertEqual( self.commit.committer.timezone, datetime.timedelta( hours = -7 ) )
self.assertEqual( self.commit.message, "Merge branch 'develop'\n" )
self.assertEqual( len( self.commit.parents ), 2 )
self.assertEqual( self.commit.parents[ 0 ].sha, "936f4a97f1a86392637ec002bbf89ff036a5062d" )
diff --git a/test/GitTag.py b/test/GitTag.py
index 60ded04f..2518ef06 100644
--- a/test/GitTag.py
+++ b/test/GitTag.py
@@ -11,6 +11,8 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
+import datetime
+
import Framework
class GitTag( Framework.TestCase ):
@@ -25,7 +27,8 @@ class GitTag( Framework.TestCase ):
self.assertEqual( self.tag.object.url, "https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495" )
self.assertEqual( self.tag.sha, "f5f37322407b02a80de4526ad88d5f188977bc3c" )
self.assertEqual( self.tag.tag, "v0.6" )
- self.assertEqual( self.tag.tagger.date, "2012-05-10T11:14:15-07:00" )
+ self.assertEqual( self.tag.tagger.date, datetime.datetime( 2012, 5, 10, 11, 14, 15 ) )
+ self.assertEqual( self.tag.tagger.timezone, datetime.timedelta( hours = -7 ) )
self.assertEqual( self.tag.tagger.email, "vincent@vincent-jacques.net" )
self.assertEqual( self.tag.tagger.name, "Vincent Jacques" )
self.assertEqual( self.tag.url, "https://api.github.com/repos/jacquev6/PyGithub/git/tags/f5f37322407b02a80de4526ad88d5f188977bc3c" )
diff --git a/test/IntegrationTest.py b/test/IntegrationTest.py
index a2d966b6..6a61fb9d 100755
--- a/test/IntegrationTest.py
+++ b/test/IntegrationTest.py
@@ -48,10 +48,12 @@ from RepositoryKey import *
from Tag import *
from Team import *
from UserKey import *
+from Markdown import *
from PaginatedList import *
from Issue33 import *
from Issue50 import *
+from Issue54 import *
from Exceptions import *
Framework.main()
diff --git a/test/Issue54.py b/test/Issue54.py
new file mode 100644
index 00000000..52221878
--- /dev/null
+++ b/test/Issue54.py
@@ -0,0 +1,26 @@
+# Copyright 2012 Vincent Jacques
+# vincent@vincent-jacques.net
+
+# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
+
+# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+
+# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
+
+import datetime
+
+import Framework
+
+class Issue54( Framework.TestCase ):
+ def setUp( self ):
+ Framework.TestCase.setUp( self )
+ self.repo = self.g.get_user().get_repo( "TestRepo" )
+
+ 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/Markdown.py b/test/Markdown.py
new file mode 100644
index 00000000..971fa167
--- /dev/null
+++ b/test/Markdown.py
@@ -0,0 +1,26 @@
+# Copyright 2012 Vincent Jacques
+# vincent@vincent-jacques.net
+
+# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
+
+# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+
+# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see .
+
+import Framework
+
+class Markdown( Framework.TestCase ):
+ def setUp( self ):
+ Framework.TestCase.setUp( self )
+ self.text = "MyTitle\n=======\n\nIssue #1"
+ self.repo = self.g.get_user().get_repo( "PyGithub" )
+
+ def testRenderMarkdown( self ):
+ self.assertEqual( self.g.render_markdown( self.text ), '
MyTitle
Issue #1
' )
+
+ def testRenderGithubFlavoredMarkdown( self ):
+ self.assertEqual( self.g.render_markdown( self.text, self.repo ), 'MyTitle
Issue #1
' )
diff --git a/test/ReplayData/Issue54.setUp.txt b/test/ReplayData/Issue54.setUp.txt
new file mode 100644
index 00000000..ca71e9c2
--- /dev/null
+++ b/test/ReplayData/Issue54.setUp.txt
@@ -0,0 +1,10 @@
+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/Markdown.setUp.txt b/test/ReplayData/Markdown.setUp.txt
new file mode 100644
index 00000000..24cca469
--- /dev/null
+++ b/test/ReplayData/Markdown.setUp.txt
@@ -0,0 +1,10 @@
+GET /user {'Authorization': 'Basic login_and_password_removed'} null
+200
+[('status', '200 OK'), ('content-length', '801'), ('vary', 'Accept, Authorization, Cookie'), ('x-ratelimit-remaining', '4987'), ('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 11:59:58 GMT'), ('content-type', 'application/json; charset=utf-8')]
+{"disk_usage":13720,"public_repos":11,"type":"User","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","total_private_repos":3,"collaborators":0,"hireable":false,"login":"jacquev6","owned_private_repos":3,"public_gists":3,"email":"vincent@vincent-jacques.net","bio":"","private_gists":5,"created_at":"2010-07-09T06:10:06Z","blog":"http://vincent-jacques.net","following":26,"location":"Paris, France","followers":13,"name":"Vincent Jacques","company":"Criteo","plan":{"collaborators":1,"private_repos":5,"name":"micro","space":614400},"html_url":"https://github.com/jacquev6","id":327146,"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225"}
+
+GET /repos/jacquev6/PyGithub {'Authorization': 'Basic login_and_password_removed'} null
+200
+[('status', '200 OK'), ('x-ratelimit-remaining', '4986'), ('x-ratelimit-limit', '5000'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1154'), ('server', 'nginx/1.0.13'), ('last-modified', 'Thu, 12 Jul 2012 18:10:45 GMT'), ('connection', 'keep-alive'), ('etag', '"7db49a096161f262ffd7e0545292f4c3"'), ('cache-control', 'private, max-age=60'), ('date', 'Fri, 13 Jul 2012 11:59:59 GMT'), ('content-type', 'application/json; charset=utf-8')]
+{"svn_url":"https://github.com/jacquev6/PyGithub","created_at":"2012-02-25T12:53:47Z","owner":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146,"login":"jacquev6","url":"https://api.github.com/users/jacquev6"},"full_name":"jacquev6/PyGithub","has_wiki":false,"watchers":43,"git_url":"git://github.com/jacquev6/PyGithub.git","html_url":"https://github.com/jacquev6/PyGithub","pushed_at":"2012-07-11T11:29:24Z","updated_at":"2012-07-12T18:10:45Z","permissions":{"pull":true,"push":true,"admin":true},"open_issues":11,"forks":7,"clone_url":"https://github.com/jacquev6/PyGithub.git","ssh_url":"git@github.com:jacquev6/PyGithub.git","homepage":"http://vincent-jacques.net/PyGithub","size":160,"fork":false,"master_branch":"master","mirror_url":null,"has_issues":true,"name":"PyGithub","has_downloads":true,"description":"Python library implementing the full Github API v3","private":false,"id":3544490,"language":"Python","url":"https://api.github.com/repos/jacquev6/PyGithub"}
+
diff --git a/test/ReplayData/Markdown.testRenderGithubFlavoredMarkdown.txt b/test/ReplayData/Markdown.testRenderGithubFlavoredMarkdown.txt
new file mode 100644
index 00000000..7055d88a
--- /dev/null
+++ b/test/ReplayData/Markdown.testRenderGithubFlavoredMarkdown.txt
@@ -0,0 +1,5 @@
+POST /markdown {'Authorization': 'Basic login_and_password_removed'} {"text": "MyTitle\n=======\n\nIssue #1", "mode": "gfm", "context": "jacquev6/PyGithub"}
+200
+[('status', '200 OK'), ('content-length', '150'), ('x-ratelimit-remaining', '4988'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"63251bf7dbb58f62c59ae39bb72c7a38"'), ('cache-control', 'max-age=0, private, must-revalidate'), ('date', 'Fri, 13 Jul 2012 11:59:58 GMT'), ('content-type', 'text/html;charset=utf-8')]
+MyTitle
Issue #1
+
diff --git a/test/ReplayData/Markdown.testRenderMarkdown.txt b/test/ReplayData/Markdown.testRenderMarkdown.txt
new file mode 100644
index 00000000..6c72da7c
--- /dev/null
+++ b/test/ReplayData/Markdown.testRenderMarkdown.txt
@@ -0,0 +1,5 @@
+POST /markdown {'Authorization': 'Basic login_and_password_removed'} {"text": "MyTitle\n=======\n\nIssue #1"}
+200
+[('status', '200 OK'), ('content-length', '133'), ('x-ratelimit-remaining', '4985'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"4cb17c0ebe3cc45c1a7f27d4d0850c54"'), ('cache-control', 'max-age=0, private, must-revalidate'), ('date', 'Fri, 13 Jul 2012 11:59:59 GMT'), ('content-type', 'text/html;charset=utf-8')]
+MyTitle
Issue #1
+