mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Refactor switches in templates: step 1
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
{
|
||||
key : {% if attribute.type.name != class.name %}{{ attribute.type.name }}.{% endif %}{{ attribute.type.name }}( self._requester, element, completed = False )
|
||||
for key, element in attributes[ "{{ attribute.name }}" ].iteritems()
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
[
|
||||
{% if attribute.type.name != class.name %}{{ attribute.type.name }}.{% endif %}{{ attribute.type.name }}( self._requester, element, completed = False )
|
||||
for element in attributes[ "{{ attribute.name }}" ]
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
{% with template_name="GithubObject.AttributeValue.complex."|add:attribute.type.cardinality|add:".py" %}None if attributes[ "{{ attribute.name }}" ] is None else {% include template_name %}{% endwith %}
|
||||
@@ -0,0 +1 @@
|
||||
{% if attribute.type.name != class.name %}{{ attribute.type.name }}.{% endif %}{{ attribute.type.name }}( self._requester, attributes[ "{{ attribute.name }}" ], completed = False )
|
||||
@@ -0,0 +1 @@
|
||||
attributes[ "{{ attribute.name }}" ]
|
||||
@@ -0,0 +1 @@
|
||||
str( {{ value|join:"." }} )
|
||||
@@ -0,0 +1 @@
|
||||
str( self.{{ value|join:"." }} )
|
||||
@@ -0,0 +1 @@
|
||||
"{{ value }}"
|
||||
@@ -0,0 +1 @@
|
||||
str( {{ value|join:"." }}._identity )
|
||||
@@ -0,0 +1 @@
|
||||
self._parentUrl( {% include "GithubObject.Concatenation.py" with concatenation=value only %} )
|
||||
@@ -1 +1 @@
|
||||
{% for part in concatenation %}{% if forloop.counter0 > 0 %} + {% endif %}{% if part.type == "constant" %}"{{ part.value }}"{% endif %}{% if part.type == "argument" %}str( {{ part.value|join:"." }} ){% endif %}{% if part.type == "attribute" %}str( self.{{ part.value|join:"." }} ){% endif %}{% if part.type == "urlquote" %}urllib.quote( {% with template_name="GithubObject.Concatenation.py" %}{% include template_name with concatenation=part.value only %}{% endwith %} ){% endif %}{% if part.type == "parentUrl" %}self._parentUrl( {% with template_name="GithubObject.Concatenation.py" %}{% include template_name with concatenation=part.value only %}{% endwith %} ){% endif %}{% if part.type == "identity" %}str( {{ part.value|join:"." }}._identity ){% endif %}{% endfor %}
|
||||
{% for part in concatenation %}{% if forloop.counter0 > 0 %} + {% endif %}{% with part_template_name="GithubObject.Concatenation."|add:part.type|add:".py" %}{% include part_template_name with value=part.value only %}{% endwith %}{% endfor %}
|
||||
@@ -0,0 +1 @@
|
||||
urllib.quote( {% include "GithubObject.Concatenation.py" with concatenation=value only %} )
|
||||
@@ -1,81 +1,30 @@
|
||||
{% if class.identity %}
|
||||
@property
|
||||
def _identity( self ):
|
||||
return {% include "GithubObject.Concatenation.py" with concatenation=class.identity only %}
|
||||
{% endif %}
|
||||
{% if class.identity %}
|
||||
@property
|
||||
def _identity( self ):
|
||||
return {% include "GithubObject.Concatenation.py" with concatenation=class.identity only %}
|
||||
{% endif %}
|
||||
|
||||
def _initAttributes( self ):
|
||||
{% for attribute in class.attributes|dictsort:"name" %}
|
||||
self._{{ attribute.name }} = GithubObject.NotSet
|
||||
{% endfor %}
|
||||
|
||||
def _useAttributes( self, attributes ):
|
||||
{% for attribute in class.attributes|dictsort:"name" %}
|
||||
|
||||
def _initAttributes( self ):
|
||||
{% for attribute in class.attributes|dictsort:"name" %}
|
||||
self._{{ attribute.name }} = GithubObject.NotSet
|
||||
{% endfor %}
|
||||
|
||||
def _useAttributes( self, attributes ):
|
||||
{% for attribute in class.attributes|dictsort:"name" %}
|
||||
if "{{ attribute.name }}" in attributes: # pragma no branch
|
||||
|
||||
{% if attribute.type.cardinality == "scalar" %}
|
||||
{% if attribute.type.simple %}
|
||||
{% if attribute.type.name == "string" %}
|
||||
assert attributes[ "{{ attribute.name }}" ] is None or isinstance( attributes[ "{{ attribute.name }}" ], ( str, unicode ) ), attributes[ "{{ attribute.name }}" ]
|
||||
{% endif %}
|
||||
{% if attribute.type.name == "integer" %}
|
||||
assert attributes[ "{{ attribute.name }}" ] is None or isinstance( attributes[ "{{ attribute.name }}" ], int ), attributes[ "{{ attribute.name }}" ]
|
||||
{% endif %}
|
||||
{% if attribute.type.name == "bool" %}
|
||||
assert attributes[ "{{ attribute.name }}" ] is None or isinstance( attributes[ "{{ attribute.name }}" ], bool ), attributes[ "{{ attribute.name }}" ]
|
||||
{% endif %}
|
||||
{% if attribute.type.name == "dict" %}
|
||||
assert attributes[ "{{ attribute.name }}" ] is None or isinstance( attributes[ "{{ attribute.name }}" ], dict ), attributes[ "{{ attribute.name }}" ]
|
||||
{% endif %}
|
||||
{% else %}
|
||||
assert attributes[ "{{ attribute.name }}" ] is None or isinstance( attributes[ "{{ attribute.name }}" ], dict ), attributes[ "{{ attribute.name }}" ]
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if attribute.type.cardinality == "list" %}
|
||||
{% if attribute.type.simple %}
|
||||
{% if attribute.type.name == "string" %}
|
||||
assert all( isinstance( element, ( str, unicode ) ) for element in attributes[ "{{ attribute.name }}" ] ), attributes[ "{{ attribute.name }}" ]
|
||||
{% endif %}
|
||||
{% if attribute.type.name == "integer" %}
|
||||
assert all( isinstance( element, int ) for element in attributes[ "{{ attribute.name }}" ] ), attributes[ "{{ attribute.name }}" ]
|
||||
{% endif %}
|
||||
{% if attribute.type.name == "bool" %}
|
||||
assert all( isinstance( element, bool ) for element in attributes[ "{{ attribute.name }}" ] ), attributes[ "{{ attribute.name }}" ]
|
||||
{% endif %}
|
||||
{% else %}
|
||||
assert all( isinstance( element, dict ) for element in attributes[ "{{ attribute.name }}" ] ), attributes[ "{{ attribute.name }}" ]
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if attribute.type.cardinality == "scalar" %}
|
||||
{% if attribute.type.simple %}
|
||||
self._{{ attribute.name }} = attributes[ "{{ attribute.name }}" ]
|
||||
{% else %}
|
||||
self._{{ attribute.name }} = None if attributes[ "{{ attribute.name }}" ] is None else {% if attribute.type.name != class.name %}{{ attribute.type.name }}.{% endif %}{{ attribute.type.name }}( self._requester, attributes[ "{{ attribute.name }}" ], completed = False )
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if attribute.type.cardinality == "list" %}
|
||||
{% 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._requester, element, completed = False )
|
||||
for element in attributes[ "{{ attribute.name }}" ]
|
||||
]
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if attribute.type.cardinality == "dict" %}
|
||||
{% if attribute.type.simple %}
|
||||
self._{{ attribute.name }} = attributes[ "{{ attribute.name }}" ]
|
||||
{% else %}
|
||||
self._{{ attribute.name }} = {
|
||||
key : {% if attribute.type.name != class.name %}{{ attribute.type.name }}.{% endif %}{{ attribute.type.name }}( self._requester, element, completed = False )
|
||||
for key, element in attributes[ "{{ attribute.name }}" ].iteritems()
|
||||
}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
{% if attribute.type.name != "@todo" %}
|
||||
{% with simple_or_complex=attribute.type.simple|yesno:"simple,complex_as_dict" %}
|
||||
if "{{ attribute.name }}" in attributes: # pragma no branch
|
||||
{% with template_name="GithubObject.IsInstance."|add:attribute.type.cardinality|add:"."|add:simple_or_complex|add:".py" %}
|
||||
assert attributes[ "{{ attribute.name }}" ] is None or {% include template_name with variable="attributes[ \""|add:attribute.name|add:"\" ]"|safe type=attribute.type only %}, attributes[ "{{ attribute.name }}" ]
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% with simple_or_complex=attribute.type.simple|yesno:"simple,complex" %}
|
||||
{% with template_name="GithubObject.AttributeValue."|add:simple_or_complex|add:".py" %}
|
||||
self._{{ attribute.name }} = {% include template_name %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{% include "GithubObject.IsInstance.py" with variable=variable type="bool" only %}
|
||||
@@ -0,0 +1 @@
|
||||
all( {% include "GithubObject.IsInstance.py" with variable="element" type="dict" only %} for element in {{ variable }}.itervalues() )
|
||||
@@ -0,0 +1 @@
|
||||
{% include "GithubObject.IsInstance.py" with variable=variable type="dict" only %}
|
||||
@@ -0,0 +1 @@
|
||||
{% include "GithubObject.IsInstance.py" with variable=variable type="int" only %}
|
||||
@@ -0,0 +1 @@
|
||||
all( {% include "GithubObject.IsInstance.py" with variable="element" type=type.name|add:"."|add:type.name only %} for element in {{ variable }} )
|
||||
@@ -0,0 +1 @@
|
||||
all( {% include "GithubObject.IsInstance.py" with variable="element" type="dict" only %} for element in {{ variable }} )
|
||||
@@ -0,0 +1 @@
|
||||
all( {% with template_name="GithubObject.IsInstance."|add:type.name|add:".py" %}{% include template_name with variable="element" only %}{% endwith %} for element in {{ variable }} )
|
||||
@@ -0,0 +1 @@
|
||||
isinstance( {{ variable }}, {{ type }} )
|
||||
@@ -0,0 +1 @@
|
||||
{% include "GithubObject.IsInstance.py" with variable=variable type=type.name|add:"."|add:type.name only %}
|
||||
@@ -0,0 +1 @@
|
||||
{% include "GithubObject.IsInstance.py" with variable=variable type="dict" only %}
|
||||
@@ -0,0 +1 @@
|
||||
{% with template_name="GithubObject.IsInstance."|add:type.name|add:".py" %}{% include template_name with variable=variable only %}{% endwith %}
|
||||
@@ -0,0 +1 @@
|
||||
{% include "GithubObject.IsInstance.py" with variable=variable type="( str, unicode )" only %}
|
||||
@@ -1,94 +1,27 @@
|
||||
{% for parameter in method.mandatoryParameters %}
|
||||
{% if parameter.type.cardinality == "scalar" %}
|
||||
|
||||
{% if parameter.type.simple %}
|
||||
{% if parameter.type.name == "string" %}
|
||||
assert isinstance( {{ parameter.name }}, ( str, unicode ) ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% if parameter.type.name == "integer" %}
|
||||
assert isinstance( {{ parameter.name }}, int ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% if parameter.type.name == "bool" %}
|
||||
assert isinstance( {{ parameter.name }}, bool ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% if parameter.type.name == "dict" %}
|
||||
assert isinstance( {{ parameter.name }}, dict ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
assert isinstance( {{ parameter.name }}, {{ parameter.type.name }}.{{ parameter.type.name }} ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
|
||||
{% if parameter.type.simple %}
|
||||
{% if parameter.type.name == "string" %}
|
||||
assert all( isinstance( element, ( str, unicode ) ) for element in {{ parameter.name }} ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% if parameter.type.name == "integer" %}
|
||||
assert all( isinstance( element, int ) for element in {{ parameter.name }} ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% if parameter.type.name == "bool" %}
|
||||
assert all( isinstance( element, bool ) for element in {{ parameter.name }} ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
assert all( isinstance( element, {{ parameter.type.name }}.{{ parameter.type.name }} ) for element in {{ parameter.name }} ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for parameter in method.optionalParameters %}
|
||||
{% if parameter.type.cardinality == "scalar" %}
|
||||
|
||||
{% if parameter.type.simple %}
|
||||
{% if parameter.type.name == "string" %}
|
||||
assert {{ parameter.name }} is GithubObject.NotSet or isinstance( {{ parameter.name }}, ( str, unicode ) ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% if parameter.type.name == "integer" %}
|
||||
assert {{ parameter.name }} is GithubObject.NotSet or isinstance( {{ parameter.name }}, int ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% if parameter.type.name == "bool" %}
|
||||
assert {{ parameter.name }} is GithubObject.NotSet or isinstance( {{ parameter.name }}, bool ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% if parameter.type.name == "dict" %}
|
||||
assert {{ parameter.name }} is GithubObject.NotSet or isinstance( {{ parameter.name }}, dict ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
assert {{ parameter.name }} is GithubObject.NotSet or isinstance( {{ parameter.name }}, {{ parameter.type.name }}.{{ parameter.type.name }} ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
|
||||
{% if parameter.type.simple %}
|
||||
{% if parameter.type.name == "string" %}
|
||||
assert {{ parameter.name }} is GithubObject.NotSet or all( isinstance( element, ( str, unicode ) ) for element in {{ parameter.name }} ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% if parameter.type.name == "integer" %}
|
||||
assert {{ parameter.name }} is GithubObject.NotSet or all( isinstance( element, int ) for element in {{ parameter.name }} ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% if parameter.type.name == "bool" %}
|
||||
assert {{ parameter.name }} is GithubObject.NotSet or all( isinstance( element, bool ) for element in {{ parameter.name }} ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
assert {{ parameter.name }} is GithubObject.NotSet or all( isinstance( element, {{ parameter.type.name }}.{{ parameter.type.name }} ) for element in {{ parameter.name }} ), {{ parameter.name }}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if method.variadicParameter %}
|
||||
{% if method.variadicParameter.type.name != "@todo" %}
|
||||
{% if method.variadicParameter.type.simple %}
|
||||
{% if method.variadicParameter.type.name == "string" %}
|
||||
assert all( isinstance( {{ method.variadicParameter.name }}, ( str, unicode ) ) for {{ method.variadicParameter.name }} in {{ method.variadicParameter.name }}s ), {{ method.variadicParameter.name }}s
|
||||
{% endif %}
|
||||
{% if parameter.type.name == "integer" %}
|
||||
assert all( isinstance( {{ method.variadicParameter.name }}, int ) for {{ method.variadicParameter.name }} in {{ method.variadicParameter.name }}s ), {{ method.variadicParameter.name }}s
|
||||
{% endif %}
|
||||
{% if parameter.type.name == "bool" %}
|
||||
assert all( isinstance( {{ method.variadicParameter.name }}, bool ) for {{ method.variadicParameter.name }} in {{ method.variadicParameter.name }}s ), {{ method.variadicParameter.name }}s
|
||||
{% endif %}
|
||||
{% else %}
|
||||
assert all( isinstance( {{ method.variadicParameter.name }}, {{ method.variadicParameter.type.name }}.{{ method.variadicParameter.type.name }} ) for {{ method.variadicParameter.name }} in {{ method.variadicParameter.name }}s ), {{ method.variadicParameter.name }}s
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% for parameter in method.mandatoryParameters %}
|
||||
{% if parameter.type.name != "@todo" %}
|
||||
{% with simple_or_complex=parameter.type.simple|yesno:"simple,complex" %}
|
||||
{% with template_name="GithubObject.IsInstance."|add:parameter.type.cardinality|add:"."|add:simple_or_complex|add:".py" %}
|
||||
assert {% include template_name with variable=parameter.name type=parameter.type only %}, {{ parameter.name }}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% for parameter in method.optionalParameters %}
|
||||
{% if parameter.type.name != "@todo" %}
|
||||
{% with simple_or_complex=parameter.type.simple|yesno:"simple,complex" %}
|
||||
{% with template_name="GithubObject.IsInstance."|add:parameter.type.cardinality|add:"."|add:simple_or_complex|add:".py" %}
|
||||
assert {{ parameter.name }} is GithubObject.NotSet or {% include template_name with variable=parameter.name type=parameter.type only %}, {{ parameter.name }}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if method.variadicParameter %}
|
||||
{% with simple_or_complex=method.variadicParameter.type.simple|yesno:"simple,complex" %}
|
||||
{% with template_name="GithubObject.IsInstance.list."|add:simple_or_complex|add:".py" %}
|
||||
assert {% include template_name with variable=method.variadicParameter.name|add:"s" type=method.variadicParameter.type only %}, {{ method.variadicParameter.name }}s
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{% for attribute in class.attributes|dictsort:"name" %}
|
||||
@property
|
||||
def {{ attribute.name }}( self ):
|
||||
{% if class.isCompletable %}
|
||||
self._completeIfNotSet( self._{{ attribute.name }} )
|
||||
{% endif %}
|
||||
return self._NoneIfNotSet( self._{{ attribute.name }} )
|
||||
{% endfor %}
|
||||
{% for attribute in class.attributes|dictsort:"name" %}
|
||||
@property
|
||||
def {{ attribute.name }}( self ):
|
||||
{% if class.isCompletable %}
|
||||
self._completeIfNotSet( self._{{ attribute.name }} )
|
||||
{% endif %}
|
||||
return self._NoneIfNotSet( self._{{ attribute.name }} )
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% for method in class.methods|dictsort:"name" %}
|
||||
def {{ method.name|join:"_" }}( {% include "GithubObject.Parameters.py" with function=method only %} ):
|
||||
{% include "GithubObject.MethodBody.CheckArguments.py" %}
|
||||
{% include "GithubObject.MethodBody.DoRequest.py" %}
|
||||
{% include "GithubObject.MethodBody.UseResult.py" %}
|
||||
{% endfor %}
|
||||
{% for method in class.methods|dictsort:"name" %}
|
||||
def {{ method.name|join:"_" }}( {% include "GithubObject.Parameters.py" with function=method only %} ):
|
||||
{% include "GithubObject.MethodBody.CheckArguments.py" %}
|
||||
{% include "GithubObject.MethodBody.DoRequest.py" %}
|
||||
{% include "GithubObject.MethodBody.UseResult.py" %}
|
||||
{% endfor %}
|
||||
|
||||
@@ -141,7 +141,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
|
||||
return self._NoneIfNotSet( self._url )
|
||||
|
||||
def add_to_emails( self, *emails ):
|
||||
assert all( isinstance( email, ( str, unicode ) ) for email in emails ), emails
|
||||
assert all( isinstance( element, ( str, unicode ) ) for element in emails ), emails
|
||||
post_parameters = emails
|
||||
status, headers, data = self._request(
|
||||
"POST",
|
||||
@@ -555,7 +555,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
|
||||
return status == 204
|
||||
|
||||
def remove_from_emails( self, *emails ):
|
||||
assert all( isinstance( email, ( str, unicode ) ) for email in emails ), emails
|
||||
assert all( isinstance( element, ( str, unicode ) ) for element in emails ), emails
|
||||
post_parameters = emails
|
||||
status, headers, data = self._request(
|
||||
"DELETE",
|
||||
|
||||
@@ -114,7 +114,7 @@ class Authorization( GithubObject.GithubObject ):
|
||||
assert attributes[ "note_url" ] is None or isinstance( attributes[ "note_url" ], ( str, unicode ) ), attributes[ "note_url" ]
|
||||
self._note_url = attributes[ "note_url" ]
|
||||
if "scopes" in attributes: # pragma no branch
|
||||
assert all( isinstance( element, ( str, unicode ) ) for element in attributes[ "scopes" ] ), attributes[ "scopes" ]
|
||||
assert attributes[ "scopes" ] is None or all( isinstance( element, ( str, unicode ) ) for element in attributes[ "scopes" ] ), attributes[ "scopes" ]
|
||||
self._scopes = attributes[ "scopes" ]
|
||||
if "token" in attributes: # pragma no branch
|
||||
assert attributes[ "token" ] is None or isinstance( attributes[ "token" ], ( str, unicode ) ), attributes[ "token" ]
|
||||
|
||||
@@ -111,14 +111,14 @@ class Commit( GithubObject.GithubObject ):
|
||||
assert attributes[ "committer" ] is None or isinstance( attributes[ "committer" ], dict ), attributes[ "committer" ]
|
||||
self._committer = None if attributes[ "committer" ] is None else NamedUser.NamedUser( self._requester, attributes[ "committer" ], completed = False )
|
||||
if "files" in attributes: # pragma no branch
|
||||
assert all( isinstance( element, dict ) for element in attributes[ "files" ] ), attributes[ "files" ]
|
||||
self._files = [
|
||||
assert attributes[ "files" ] is None or all( isinstance( element, dict ) for element in attributes[ "files" ] ), attributes[ "files" ]
|
||||
self._files = None if attributes[ "files" ] is None else [
|
||||
File.File( self._requester, element, completed = False )
|
||||
for element in attributes[ "files" ]
|
||||
]
|
||||
if "parents" in attributes: # pragma no branch
|
||||
assert all( isinstance( element, dict ) for element in attributes[ "parents" ] ), attributes[ "parents" ]
|
||||
self._parents = [
|
||||
assert attributes[ "parents" ] is None or all( isinstance( element, dict ) for element in attributes[ "parents" ] ), attributes[ "parents" ]
|
||||
self._parents = None if attributes[ "parents" ] is None else [
|
||||
Commit( self._requester, element, completed = False )
|
||||
for element in attributes[ "parents" ]
|
||||
]
|
||||
|
||||
@@ -92,8 +92,8 @@ class Comparison( GithubObject.GithubObject ):
|
||||
assert attributes[ "behind_by" ] is None or isinstance( attributes[ "behind_by" ], int ), attributes[ "behind_by" ]
|
||||
self._behind_by = attributes[ "behind_by" ]
|
||||
if "commits" in attributes: # pragma no branch
|
||||
assert all( isinstance( element, dict ) for element in attributes[ "commits" ] ), attributes[ "commits" ]
|
||||
self._commits = [
|
||||
assert attributes[ "commits" ] is None or all( isinstance( element, dict ) for element in attributes[ "commits" ] ), attributes[ "commits" ]
|
||||
self._commits = None if attributes[ "commits" ] is None else [
|
||||
Commit.Commit( self._requester, element, completed = False )
|
||||
for element in attributes[ "commits" ]
|
||||
]
|
||||
@@ -101,8 +101,8 @@ class Comparison( GithubObject.GithubObject ):
|
||||
assert attributes[ "diff_url" ] is None or isinstance( attributes[ "diff_url" ], ( str, unicode ) ), attributes[ "diff_url" ]
|
||||
self._diff_url = attributes[ "diff_url" ]
|
||||
if "files" in attributes: # pragma no branch
|
||||
assert all( isinstance( element, dict ) for element in attributes[ "files" ] ), attributes[ "files" ]
|
||||
self._files = [
|
||||
assert attributes[ "files" ] is None or all( isinstance( element, dict ) for element in attributes[ "files" ] ), attributes[ "files" ]
|
||||
self._files = None if attributes[ "files" ] is None else [
|
||||
File.File( self._requester, element, completed = False )
|
||||
for element in attributes[ "files" ]
|
||||
]
|
||||
|
||||
+6
-5
@@ -216,7 +216,8 @@ class Gist( GithubObject.GithubObject ):
|
||||
assert attributes[ "description" ] is None or isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ]
|
||||
self._description = attributes[ "description" ]
|
||||
if "files" in attributes: # pragma no branch
|
||||
self._files = {
|
||||
assert attributes[ "files" ] is None or all( isinstance( element, dict ) for element in attributes[ "files" ].itervalues() ), attributes[ "files" ]
|
||||
self._files = None if attributes[ "files" ] is None else {
|
||||
key : GistFile.GistFile( self._requester, element, completed = False )
|
||||
for key, element in attributes[ "files" ].iteritems()
|
||||
}
|
||||
@@ -224,8 +225,8 @@ class Gist( GithubObject.GithubObject ):
|
||||
assert attributes[ "fork_of" ] is None or isinstance( attributes[ "fork_of" ], dict ), attributes[ "fork_of" ]
|
||||
self._fork_of = None if attributes[ "fork_of" ] is None else Gist( self._requester, attributes[ "fork_of" ], completed = False )
|
||||
if "forks" in attributes: # pragma no branch
|
||||
assert all( isinstance( element, dict ) for element in attributes[ "forks" ] ), attributes[ "forks" ]
|
||||
self._forks = [
|
||||
assert attributes[ "forks" ] is None or all( isinstance( element, dict ) for element in attributes[ "forks" ] ), attributes[ "forks" ]
|
||||
self._forks = None if attributes[ "forks" ] is None else [
|
||||
Gist( self._requester, element, completed = False )
|
||||
for element in attributes[ "forks" ]
|
||||
]
|
||||
@@ -236,8 +237,8 @@ class Gist( GithubObject.GithubObject ):
|
||||
assert attributes[ "git_push_url" ] is None or isinstance( attributes[ "git_push_url" ], ( str, unicode ) ), attributes[ "git_push_url" ]
|
||||
self._git_push_url = attributes[ "git_push_url" ]
|
||||
if "history" in attributes: # pragma no branch
|
||||
assert all( isinstance( element, dict ) for element in attributes[ "history" ] ), attributes[ "history" ]
|
||||
self._history = [
|
||||
assert attributes[ "history" ] is None or all( isinstance( element, dict ) for element in attributes[ "history" ] ), attributes[ "history" ]
|
||||
self._history = None if attributes[ "history" ] is None else [
|
||||
GistHistoryState.GistHistoryState( self._requester, element, completed = False )
|
||||
for element in attributes[ "history" ]
|
||||
]
|
||||
|
||||
@@ -63,8 +63,8 @@ class GitCommit( GithubObject.GithubObject ):
|
||||
assert attributes[ "message" ] is None or isinstance( attributes[ "message" ], ( str, unicode ) ), attributes[ "message" ]
|
||||
self._message = attributes[ "message" ]
|
||||
if "parents" in attributes: # pragma no branch
|
||||
assert all( isinstance( element, dict ) for element in attributes[ "parents" ] ), attributes[ "parents" ]
|
||||
self._parents = [
|
||||
assert attributes[ "parents" ] is None or all( isinstance( element, dict ) for element in attributes[ "parents" ] ), attributes[ "parents" ]
|
||||
self._parents = None if attributes[ "parents" ] is None else [
|
||||
GitCommit( self._requester, element, completed = False )
|
||||
for element in attributes[ "parents" ]
|
||||
]
|
||||
|
||||
@@ -31,8 +31,8 @@ class GitTree( GithubObject.GithubObject ):
|
||||
assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ]
|
||||
self._sha = attributes[ "sha" ]
|
||||
if "tree" in attributes: # pragma no branch
|
||||
assert all( isinstance( element, dict ) for element in attributes[ "tree" ] ), attributes[ "tree" ]
|
||||
self._tree = [
|
||||
assert attributes[ "tree" ] is None or all( isinstance( element, dict ) for element in attributes[ "tree" ] ), attributes[ "tree" ]
|
||||
self._tree = None if attributes[ "tree" ] is None else [
|
||||
GitTreeElement.GitTreeElement( self._requester, element, completed = False )
|
||||
for element in attributes[ "tree" ]
|
||||
]
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ class Hook( GithubObject.GithubObject ):
|
||||
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
|
||||
self._created_at = attributes[ "created_at" ]
|
||||
if "events" in attributes: # pragma no branch
|
||||
assert all( isinstance( element, ( str, unicode ) ) for element in attributes[ "events" ] ), attributes[ "events" ]
|
||||
assert attributes[ "events" ] is None or all( isinstance( element, ( str, unicode ) ) for element in attributes[ "events" ] ), attributes[ "events" ]
|
||||
self._events = attributes[ "events" ]
|
||||
if "id" in attributes: # pragma no branch
|
||||
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
|
||||
|
||||
+4
-4
@@ -104,7 +104,7 @@ class Issue( GithubObject.GithubObject ):
|
||||
return self._NoneIfNotSet( self._user )
|
||||
|
||||
def add_to_labels( self, *labels ):
|
||||
assert all( isinstance( label, Label.Label ) for label in labels ), labels
|
||||
assert all( isinstance( element, Label.Label ) for element in labels ), labels
|
||||
post_parameters = [ label._identity for label in labels ]
|
||||
status, headers, data = self._request(
|
||||
"POST",
|
||||
@@ -233,7 +233,7 @@ class Issue( GithubObject.GithubObject ):
|
||||
self._checkStatus( status, data )
|
||||
|
||||
def set_labels( self, *labels ):
|
||||
assert all( isinstance( label, Label.Label ) for label in labels ), labels
|
||||
assert all( isinstance( element, Label.Label ) for element in labels ), labels
|
||||
post_parameters = [ label._identity for label in labels ]
|
||||
status, headers, data = self._request(
|
||||
"PUT",
|
||||
@@ -289,8 +289,8 @@ class Issue( GithubObject.GithubObject ):
|
||||
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
|
||||
self._id = attributes[ "id" ]
|
||||
if "labels" in attributes: # pragma no branch
|
||||
assert all( isinstance( element, dict ) for element in attributes[ "labels" ] ), attributes[ "labels" ]
|
||||
self._labels = [
|
||||
assert attributes[ "labels" ] is None or all( isinstance( element, dict ) for element in attributes[ "labels" ] ), attributes[ "labels" ]
|
||||
self._labels = None if attributes[ "labels" ] is None else [
|
||||
Label.Label( self._requester, element, completed = False )
|
||||
for element in attributes[ "labels" ]
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user