mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 19:31:10 +00:00
Simplify
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
result = self.__github._{{ method.request.information }}Request(
|
||||
status, headers, data = self.__requester.request(
|
||||
"{{ method.request.verb }}",
|
||||
{% include "GithubObject.Concatenation.py" with concatenation=method.request.url only %},
|
||||
None,
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
{% if method.is_mutation %}
|
||||
self.__useAttributes( result )
|
||||
self.__useAttributes( data )
|
||||
{% endif %}
|
||||
|
||||
{% if method.type.simple %}
|
||||
|
||||
{% if method.type.name == "bool" %}
|
||||
return result == 204
|
||||
return status == 204
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
|
||||
{% if method.type.cardinality == "scalar" %}
|
||||
return {% if method.type.name != class.name %}{{ method.type.name }}.{% endif %}{{ method.type.name }}( self.__github, result, lazy = True )
|
||||
return {% if method.type.name != class.name %}{{ method.type.name }}.{% endif %}{{ method.type.name }}( self.__requester, data, lazy = True )
|
||||
{% endif %}
|
||||
|
||||
{% if method.type.cardinality == "list" %}
|
||||
return [
|
||||
{% if method.type.name != class.name %}{{ method.type.name }}.{% endif %}{{ method.type.name }}( self.__github, element, lazy = True )
|
||||
for element in result
|
||||
{% if method.type.name != class.name %}{{ method.type.name }}.{% endif %}{{ method.type.name }}( self.__requester, element, lazy = True )
|
||||
for element in data
|
||||
]
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import {{ dependency }}
|
||||
{% endfor %}
|
||||
|
||||
class {{ class.name }}( object ):
|
||||
def __init__( self, github, attributes, lazy ):
|
||||
self.__github = github
|
||||
def __init__( self, requester, attributes, lazy ):
|
||||
self.__requester = requester
|
||||
self.__completed = False
|
||||
self.__initAttributes()
|
||||
self.__useAttributes( attributes )
|
||||
@@ -39,13 +39,13 @@ class {{ class.name }}( object ):
|
||||
|
||||
# @todo Do not generate __complete if type has no url attribute
|
||||
def __complete( self ):
|
||||
result = self.__github._dataRequest(
|
||||
status, headers, data = self.__requester.request(
|
||||
"GET",
|
||||
self.__url,
|
||||
None,
|
||||
None
|
||||
)
|
||||
self.__useAttributes( result )
|
||||
self.__useAttributes( data )
|
||||
self.__completed = True
|
||||
|
||||
def __useAttributes( self, attributes ):
|
||||
@@ -55,7 +55,7 @@ class {{ class.name }}( object ):
|
||||
{% if attribute.type.simple %}
|
||||
self.__{{ attribute.name }} = attributes[ "{{ attribute.name }}" ]
|
||||
{% else %}
|
||||
self.__{{ attribute.name }} = {% if attribute.type.name != class.name %}{{ attribute.type.name }}.{% endif %}{{ attribute.type.name }}( self.__github, attributes[ "{{ attribute.name }}" ], lazy = True )
|
||||
self.__{{ attribute.name }} = {% if attribute.type.name != class.name %}{{ attribute.type.name }}.{% endif %}{{ attribute.type.name }}( self.__requester, attributes[ "{{ attribute.name }}" ], lazy = True )
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user