mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 03:41:08 +00:00
dos2unix, chmod +x
This commit is contained in:
+67
-67
@@ -1,67 +1,67 @@
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
import datetime
|
||||
|
||||
import GithubException
|
||||
|
||||
class _NotSetType:
|
||||
pass
|
||||
NotSet = _NotSetType()
|
||||
|
||||
class BasicGithubObject( object ):
|
||||
def __init__( self, requester, attributes, completed ): ### 'completed' may be removed if I find a way
|
||||
self._requester = requester
|
||||
self._initAttributes()
|
||||
self._useAttributes( attributes )
|
||||
|
||||
@staticmethod
|
||||
def _parentUrl( url ):
|
||||
return "/".join( url.split( "/" )[ : -1 ] )
|
||||
|
||||
@staticmethod
|
||||
def _NoneIfNotSet( value ):
|
||||
if value is NotSet:
|
||||
return None
|
||||
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 )
|
||||
self.__completed = completed
|
||||
|
||||
def _completeIfNotSet( self, value ):
|
||||
if not self.__completed and value is NotSet:
|
||||
self.__complete()
|
||||
|
||||
def __complete( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
self._url,
|
||||
None,
|
||||
None
|
||||
)
|
||||
self._useAttributes( data )
|
||||
self._completed = True
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
import datetime
|
||||
|
||||
import GithubException
|
||||
|
||||
class _NotSetType:
|
||||
pass
|
||||
NotSet = _NotSetType()
|
||||
|
||||
class BasicGithubObject( object ):
|
||||
def __init__( self, requester, attributes, completed ): ### 'completed' may be removed if I find a way
|
||||
self._requester = requester
|
||||
self._initAttributes()
|
||||
self._useAttributes( attributes )
|
||||
|
||||
@staticmethod
|
||||
def _parentUrl( url ):
|
||||
return "/".join( url.split( "/" )[ : -1 ] )
|
||||
|
||||
@staticmethod
|
||||
def _NoneIfNotSet( value ):
|
||||
if value is NotSet:
|
||||
return None
|
||||
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 )
|
||||
self.__completed = completed
|
||||
|
||||
def _completeIfNotSet( self, value ):
|
||||
if not self.__completed and value is NotSet:
|
||||
self.__complete()
|
||||
|
||||
def __complete( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
self._url,
|
||||
None,
|
||||
None
|
||||
)
|
||||
self._useAttributes( data )
|
||||
self._completed = True
|
||||
|
||||
+22
-22
@@ -1,22 +1,22 @@
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
class InputFileContent( object ):
|
||||
def __init__( self, content ):
|
||||
self.__content = content
|
||||
|
||||
@property
|
||||
def _identity( self ):
|
||||
return {
|
||||
"content": self.__content,
|
||||
}
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
class InputFileContent( object ):
|
||||
def __init__( self, content ):
|
||||
self.__content = content
|
||||
|
||||
@property
|
||||
def _identity( self ):
|
||||
return {
|
||||
"content": self.__content,
|
||||
}
|
||||
|
||||
+26
-26
@@ -1,26 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
class InputGitAuthor( object ):
|
||||
def __init__( self, name, email, date ):
|
||||
self.__name = name
|
||||
self.__email = email
|
||||
self.__date = date
|
||||
|
||||
@property
|
||||
def _identity( self ):
|
||||
return {
|
||||
"name": self.__name,
|
||||
"email": self.__email,
|
||||
"date": self.__date,
|
||||
}
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
class InputGitAuthor( object ):
|
||||
def __init__( self, name, email, date ):
|
||||
self.__name = name
|
||||
self.__email = email
|
||||
self.__date = date
|
||||
|
||||
@property
|
||||
def _identity( self ):
|
||||
return {
|
||||
"name": self.__name,
|
||||
"email": self.__email,
|
||||
"date": self.__date,
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
import GithubObject
|
||||
|
||||
class InputGitTreeElement( object ):
|
||||
def __init__( self, path, mode, type, content = GithubObject.NotSet, sha = GithubObject.NotSet ):
|
||||
self.__path = path
|
||||
self.__mode = mode
|
||||
self.__type = type
|
||||
self.__content = content
|
||||
self.__sha = sha
|
||||
|
||||
@property
|
||||
def _identity( self ):
|
||||
identity = {
|
||||
"path": self.__path,
|
||||
"mode": self.__mode,
|
||||
"type": self.__type,
|
||||
}
|
||||
if self.__sha is not GithubObject.NotSet:
|
||||
identity[ "sha" ] = self.__sha
|
||||
if self.__content is not GithubObject.NotSet:
|
||||
identity[ "content" ] = self.__content
|
||||
return identity
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
import GithubObject
|
||||
|
||||
class InputGitTreeElement( object ):
|
||||
def __init__( self, path, mode, type, content = GithubObject.NotSet, sha = GithubObject.NotSet ):
|
||||
self.__path = path
|
||||
self.__mode = mode
|
||||
self.__type = type
|
||||
self.__content = content
|
||||
self.__sha = sha
|
||||
|
||||
@property
|
||||
def _identity( self ):
|
||||
identity = {
|
||||
"path": self.__path,
|
||||
"mode": self.__mode,
|
||||
"type": self.__type,
|
||||
}
|
||||
if self.__sha is not GithubObject.NotSet:
|
||||
identity[ "sha" ] = self.__sha
|
||||
if self.__content is not GithubObject.NotSet:
|
||||
identity[ "content" ] = self.__content
|
||||
return identity
|
||||
|
||||
+74
-74
@@ -1,74 +1,74 @@
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
from PaginatedList import PaginatedListBase
|
||||
|
||||
class PaginatedList( PaginatedListBase ):
|
||||
def __init__( self, url, args, requester, key, convert, contentClass ):
|
||||
PaginatedListBase.__init__( self, list() )
|
||||
self.__url = url
|
||||
self.__args = args
|
||||
self.__requester = requester
|
||||
self.__key = key
|
||||
self.__convert = convert
|
||||
self.__contentClass = contentClass
|
||||
self.__nextPage = 1
|
||||
self.__continue = True
|
||||
self.__elements = list()
|
||||
|
||||
def _couldGrow( self ):
|
||||
return self.__continue
|
||||
|
||||
def _fetchNextPage( self ):
|
||||
if self.__nextPage != 1:
|
||||
self.__args[ "start_page" ] = self.__nextPage
|
||||
self.__nextPage += 1
|
||||
headers, data = self.__requester.requestAndCheck(
|
||||
"GET",
|
||||
self.__url,
|
||||
self.__args,
|
||||
None
|
||||
)
|
||||
self.__continue = len( data[ self.__key ] ) > 0
|
||||
return [
|
||||
self.__contentClass( self.__requester, self.__convert( element ), completed = False )
|
||||
for element in data[ self.__key ]
|
||||
]
|
||||
|
||||
def convertUser( attributes ):
|
||||
login = attributes[ "login" ]
|
||||
return {
|
||||
"login": login,
|
||||
"url": "/users/" + login,
|
||||
}
|
||||
|
||||
def convertRepo( attributes ):
|
||||
owner = attributes[ "owner" ]
|
||||
name = attributes[ "name" ]
|
||||
return {
|
||||
"owner": { "login": owner },
|
||||
"name": name,
|
||||
"url": "/repos/" + owner + "/" + name,
|
||||
}
|
||||
|
||||
def convertIssue( attributes ):
|
||||
number = attributes[ "number" ]
|
||||
title = attributes[ "title" ]
|
||||
html_url = attributes[ "html_url" ]
|
||||
assert html_url.startswith( "https://github.com/" )
|
||||
url = html_url.replace( "https://github.com/", "/repos/" )
|
||||
return {
|
||||
"title": title,
|
||||
"number": number,
|
||||
"url": url,
|
||||
}
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
from PaginatedList import PaginatedListBase
|
||||
|
||||
class PaginatedList( PaginatedListBase ):
|
||||
def __init__( self, url, args, requester, key, convert, contentClass ):
|
||||
PaginatedListBase.__init__( self, list() )
|
||||
self.__url = url
|
||||
self.__args = args
|
||||
self.__requester = requester
|
||||
self.__key = key
|
||||
self.__convert = convert
|
||||
self.__contentClass = contentClass
|
||||
self.__nextPage = 1
|
||||
self.__continue = True
|
||||
self.__elements = list()
|
||||
|
||||
def _couldGrow( self ):
|
||||
return self.__continue
|
||||
|
||||
def _fetchNextPage( self ):
|
||||
if self.__nextPage != 1:
|
||||
self.__args[ "start_page" ] = self.__nextPage
|
||||
self.__nextPage += 1
|
||||
headers, data = self.__requester.requestAndCheck(
|
||||
"GET",
|
||||
self.__url,
|
||||
self.__args,
|
||||
None
|
||||
)
|
||||
self.__continue = len( data[ self.__key ] ) > 0
|
||||
return [
|
||||
self.__contentClass( self.__requester, self.__convert( element ), completed = False )
|
||||
for element in data[ self.__key ]
|
||||
]
|
||||
|
||||
def convertUser( attributes ):
|
||||
login = attributes[ "login" ]
|
||||
return {
|
||||
"login": login,
|
||||
"url": "/users/" + login,
|
||||
}
|
||||
|
||||
def convertRepo( attributes ):
|
||||
owner = attributes[ "owner" ]
|
||||
name = attributes[ "name" ]
|
||||
return {
|
||||
"owner": { "login": owner },
|
||||
"name": name,
|
||||
"url": "/repos/" + owner + "/" + name,
|
||||
}
|
||||
|
||||
def convertIssue( attributes ):
|
||||
number = attributes[ "number" ]
|
||||
title = attributes[ "title" ]
|
||||
html_url = attributes[ "html_url" ]
|
||||
assert html_url.startswith( "https://github.com/" )
|
||||
url = html_url.replace( "https://github.com/", "/repos/" )
|
||||
return {
|
||||
"title": title,
|
||||
"number": number,
|
||||
"url": url,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user