mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Automatic implementation of url_parameters
This commit is contained in:
@@ -6,16 +6,28 @@
|
||||
post_parameters = [ {{ method.variadicParameter.name }}._identity for {{ method.variadicParameter.name }} in {{ method.variadicParameter.name }}s ]
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if method.mandatoryParameters %}
|
||||
post_parameters = {
|
||||
{% for parameter in method.mandatoryParameters %}
|
||||
{% for parameter in method.mandatoryParameters %}
|
||||
"{{ parameter.name }}": {{ parameter.name }},
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
}
|
||||
{% else %}
|
||||
post_parameters = dict()
|
||||
{% endif %}
|
||||
{% for parameter in method.optionalParameters %}
|
||||
if {{ parameter.name }} is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "{{ parameter.name }}" ] = {{ parameter.name }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if method.optionalParameters %}
|
||||
url_parameters = dict()
|
||||
{% for parameter in method.optionalParameters %}
|
||||
if {{ parameter.name }} is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "{{ parameter.name }}" ] = {{ parameter.name }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if method.request.urlParameters %}
|
||||
@@ -29,7 +41,7 @@
|
||||
status, headers, data = self.__requester.request(
|
||||
"{{ method.request.verb }}",
|
||||
{% include "GithubObject.Concatenation.py" with concatenation=method.request.url only %},
|
||||
{% if method.request.urlParameters %}
|
||||
{% if method.request.urlParameters or not method.request.postParameters and method.optionalParameters %}
|
||||
url_parameters,
|
||||
{% else %}
|
||||
None,
|
||||
|
||||
@@ -182,8 +182,7 @@ class AuthenticatedUser( object ):
|
||||
assert isinstance( note, ( str, unicode ) ), note
|
||||
if note_url is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( note_url, ( str, unicode ) ), note_url
|
||||
post_parameters = {
|
||||
}
|
||||
post_parameters = dict()
|
||||
if scopes is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "scopes" ] = scopes
|
||||
if note is not DefaultValueForOptionalParameters:
|
||||
@@ -293,8 +292,7 @@ class AuthenticatedUser( object ):
|
||||
assert isinstance( hireable, bool ), hireable
|
||||
if bio is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( bio, ( str, unicode ) ), bio
|
||||
post_parameters = {
|
||||
}
|
||||
post_parameters = dict()
|
||||
if name is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "name" ] = name
|
||||
if email is not DefaultValueForOptionalParameters:
|
||||
@@ -486,7 +484,7 @@ class AuthenticatedUser( object ):
|
||||
def get_repos( self, type = DefaultValueForOptionalParameters ):
|
||||
if type is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( type, ( str, unicode ) ), type
|
||||
url_parameters = {}
|
||||
url_parameters = dict()
|
||||
if type is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "type" ] = type
|
||||
status, headers, data = self.__requester.request(
|
||||
|
||||
@@ -77,8 +77,7 @@ class Authorization( object ):
|
||||
assert isinstance( note, ( str, unicode ) ), note
|
||||
if note_url is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( note_url, ( str, unicode ) ), note_url
|
||||
post_parameters = {
|
||||
}
|
||||
post_parameters = dict()
|
||||
if scopes is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "scopes" ] = scopes
|
||||
if add_scopes is not DefaultValueForOptionalParameters:
|
||||
|
||||
+1
-2
@@ -125,8 +125,7 @@ class Gist( object ):
|
||||
def edit( self, description = DefaultValueForOptionalParameters, files = DefaultValueForOptionalParameters ):
|
||||
if description is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( description, ( str, unicode ) ), description
|
||||
post_parameters = {
|
||||
}
|
||||
post_parameters = dict()
|
||||
if description is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "description" ] = description
|
||||
if files is not DefaultValueForOptionalParameters:
|
||||
|
||||
+1
-2
@@ -153,8 +153,7 @@ class Issue( object ):
|
||||
assert isinstance( milestone, int ), milestone
|
||||
if labels is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( labels, list ) and ( len( labels ) == 0 or isinstance( labels[ 0 ], ( str, unicode ) ) ), labels
|
||||
post_parameters = {
|
||||
}
|
||||
post_parameters = dict()
|
||||
if title is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "title" ] = title
|
||||
if body is not DefaultValueForOptionalParameters:
|
||||
|
||||
@@ -292,10 +292,13 @@ class NamedUser( object ):
|
||||
def get_repos( self, type = DefaultValueForOptionalParameters ):
|
||||
if type is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( type, ( str, unicode ) ), type
|
||||
url_parameters = dict()
|
||||
if type is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "type" ] = type
|
||||
status, headers, data = self.__requester.request(
|
||||
"GET",
|
||||
str( self.url ) + "/repos",
|
||||
None,
|
||||
url_parameters,
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
|
||||
@@ -235,8 +235,7 @@ class Organization( object ):
|
||||
assert isinstance( location, ( str, unicode ) ), location
|
||||
if name is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( name, ( str, unicode ) ), name
|
||||
post_parameters = {
|
||||
}
|
||||
post_parameters = dict()
|
||||
if billing_email is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "billing_email" ] = billing_email
|
||||
if blog is not DefaultValueForOptionalParameters:
|
||||
@@ -312,10 +311,13 @@ class Organization( object ):
|
||||
def get_repos( self, type = DefaultValueForOptionalParameters ):
|
||||
if type is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( type, ( str, unicode ) ), type
|
||||
url_parameters = dict()
|
||||
if type is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "type" ] = type
|
||||
status, headers, data = self.__requester.request(
|
||||
"GET",
|
||||
str( self.url ) + "/repos",
|
||||
None,
|
||||
url_parameters,
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
|
||||
@@ -173,8 +173,7 @@ class PullRequest( object ):
|
||||
assert isinstance( body, ( str, unicode ) ), body
|
||||
if state is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( state, ( str, unicode ) ), state
|
||||
post_parameters = {
|
||||
}
|
||||
post_parameters = dict()
|
||||
if title is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "title" ] = title
|
||||
if body is not DefaultValueForOptionalParameters:
|
||||
@@ -253,8 +252,7 @@ class PullRequest( object ):
|
||||
def merge( self, commit_message = DefaultValueForOptionalParameters ):
|
||||
if commit_message is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( commit_message, ( str, unicode ) ), commit_message
|
||||
post_parameters = {
|
||||
}
|
||||
post_parameters = dict()
|
||||
if commit_message is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "commit_message" ] = commit_message
|
||||
status, headers, data = self.__requester.request(
|
||||
|
||||
@@ -550,10 +550,15 @@ class Repository( object ):
|
||||
assert isinstance( sha, ( str, unicode ) ), sha
|
||||
if path is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( path, ( str, unicode ) ), path
|
||||
url_parameters = dict()
|
||||
if sha is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "sha" ] = sha
|
||||
if path is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "path" ] = path
|
||||
status, headers, data = self.__requester.request(
|
||||
"GET",
|
||||
str( self.url ) + "/commits",
|
||||
None,
|
||||
url_parameters,
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
@@ -687,7 +692,7 @@ class Repository( object ):
|
||||
assert isinstance( sha, ( str, unicode ) ), sha
|
||||
if recursive is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( recursive, bool ), recursive
|
||||
url_parameters = {}
|
||||
url_parameters = dict()
|
||||
if recursive is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "recursive" ] = recursive
|
||||
status, headers, data = self.__requester.request(
|
||||
@@ -749,10 +754,27 @@ class Repository( object ):
|
||||
assert isinstance( direction, ( str, unicode ) ), direction
|
||||
if since is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( since, ( str, unicode ) ), since
|
||||
url_parameters = dict()
|
||||
if milestone is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "milestone" ] = milestone
|
||||
if state is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "state" ] = state
|
||||
if assignee is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "assignee" ] = assignee
|
||||
if mentioned is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "mentioned" ] = mentioned
|
||||
if labels is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "labels" ] = labels
|
||||
if sort is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "sort" ] = sort
|
||||
if direction is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "direction" ] = direction
|
||||
if since is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "since" ] = since
|
||||
status, headers, data = self.__requester.request(
|
||||
"GET",
|
||||
str( self.url ) + "/issues",
|
||||
None,
|
||||
url_parameters,
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
@@ -860,10 +882,17 @@ class Repository( object ):
|
||||
assert isinstance( sort, ( str, unicode ) ), sort
|
||||
if direction is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( direction, ( str, unicode ) ), direction
|
||||
url_parameters = dict()
|
||||
if state is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "state" ] = state
|
||||
if sort is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "sort" ] = sort
|
||||
if direction is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "direction" ] = direction
|
||||
status, headers, data = self.__requester.request(
|
||||
"GET",
|
||||
str( self.url ) + "/milestones",
|
||||
None,
|
||||
url_parameters,
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
@@ -900,10 +929,13 @@ class Repository( object ):
|
||||
def get_pulls( self, state = DefaultValueForOptionalParameters ):
|
||||
if state is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( state, ( str, unicode ) ), state
|
||||
url_parameters = dict()
|
||||
if state is not DefaultValueForOptionalParameters:
|
||||
url_parameters[ "state" ] = state
|
||||
status, headers, data = self.__requester.request(
|
||||
"GET",
|
||||
str( self.url ) + "/pulls",
|
||||
None,
|
||||
url_parameters,
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
|
||||
@@ -56,8 +56,7 @@ class RepositoryKey( object ):
|
||||
assert isinstance( title, ( str, unicode ) ), title
|
||||
if key is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( key, ( str, unicode ) ), key
|
||||
post_parameters = {
|
||||
}
|
||||
post_parameters = dict()
|
||||
if title is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "title" ] = title
|
||||
if key is not DefaultValueForOptionalParameters:
|
||||
|
||||
@@ -51,8 +51,7 @@ class UserKey( object ):
|
||||
assert isinstance( title, ( str, unicode ) ), title
|
||||
if key is not DefaultValueForOptionalParameters:
|
||||
assert isinstance( key, ( str, unicode ) ), key
|
||||
post_parameters = {
|
||||
}
|
||||
post_parameters = dict()
|
||||
if title is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "title" ] = title
|
||||
if key is not DefaultValueForOptionalParameters:
|
||||
|
||||
Reference in New Issue
Block a user