diff --git a/codegen/templates/GithubObject.Implementation.py b/codegen/templates/GithubObject.Implementation.py index b345ce26..027e1326 100644 --- a/codegen/templates/GithubObject.Implementation.py +++ b/codegen/templates/GithubObject.Implementation.py @@ -6,27 +6,27 @@ def _initAttributes( self ): {% for attribute in class.attributes|dictsort:"name" %} - self._{{ attribute.name }} = None + self._{{ attribute.name }} = GithubObject.NotSet {% endfor %} def _useAttributes( self, attributes ): {% for attribute in class.attributes|dictsort:"name" %} - if "{{ attribute.name }}" in attributes and attributes[ "{{ attribute.name }}" ] is not None: # pragma no branch + if "{{ attribute.name }}" in attributes: # pragma no branch {% if attribute.type.cardinality == "scalar" %} {% if attribute.type.simple %} {% if attribute.type.name == "string" %} - assert isinstance( attributes[ "{{ attribute.name }}" ], ( str, unicode ) ), attributes[ "{{ attribute.name }}" ] + assert attributes[ "{{ attribute.name }}" ] is None or isinstance( attributes[ "{{ attribute.name }}" ], ( str, unicode ) ), attributes[ "{{ attribute.name }}" ] {% endif %} {% if attribute.type.name == "integer" %} - assert isinstance( attributes[ "{{ attribute.name }}" ], int ), attributes[ "{{ attribute.name }}" ] + assert attributes[ "{{ attribute.name }}" ] is None or isinstance( attributes[ "{{ attribute.name }}" ], int ), attributes[ "{{ attribute.name }}" ] {% endif %} {% if attribute.type.name == "bool" %} - assert isinstance( attributes[ "{{ attribute.name }}" ], bool ), attributes[ "{{ attribute.name }}" ] + assert attributes[ "{{ attribute.name }}" ] is None or isinstance( attributes[ "{{ attribute.name }}" ], bool ), attributes[ "{{ attribute.name }}" ] {% endif %} {% else %} - assert isinstance( attributes[ "{{ attribute.name }}" ], dict ), attributes[ "{{ attribute.name }}" ] + assert attributes[ "{{ attribute.name }}" ] is None or isinstance( attributes[ "{{ attribute.name }}" ], dict ), attributes[ "{{ attribute.name }}" ] {% endif %} {% else %} @@ -52,7 +52,7 @@ {% 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, attributes[ "{{ attribute.name }}" ], completed = False ) + 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 %} {% else %} diff --git a/codegen/templates/GithubObject.MethodBody.CheckArguments.py b/codegen/templates/GithubObject.MethodBody.CheckArguments.py index 499aa9a3..c35e9cc7 100644 --- a/codegen/templates/GithubObject.MethodBody.CheckArguments.py +++ b/codegen/templates/GithubObject.MethodBody.CheckArguments.py @@ -35,7 +35,7 @@ {% endfor %} {% for parameter in method.optionalParameters %} {% if parameter.type.name != "@todo" %} - if {{ parameter.name }} is not DefaultValueForOptionalParameters: + if {{ parameter.name }} is not GithubObject.NotSet: {% endif %} {% if parameter.type.cardinality == "scalar" %} diff --git a/codegen/templates/GithubObject.MethodBody.DoRequest.py b/codegen/templates/GithubObject.MethodBody.DoRequest.py index d43ec1b8..87d543cc 100644 --- a/codegen/templates/GithubObject.MethodBody.DoRequest.py +++ b/codegen/templates/GithubObject.MethodBody.DoRequest.py @@ -16,7 +16,7 @@ post_parameters = dict() {% endif %} {% for parameter in method.optionalParameters %} - if {{ parameter.name }} is not DefaultValueForOptionalParameters: + if {{ parameter.name }} is not GithubObject.NotSet: post_parameters[ "{{ parameter.name }}" ] = {{ parameter.name }} {% endfor %} {% endif %} @@ -24,7 +24,7 @@ {% if method.optionalParameters %} url_parameters = dict() {% for parameter in method.optionalParameters %} - if {{ parameter.name }} is not DefaultValueForOptionalParameters: + if {{ parameter.name }} is not GithubObject.NotSet: url_parameters[ "{{ parameter.name }}" ] = {{ parameter.name }} {% endfor %} {% endif %} diff --git a/codegen/templates/GithubObject.Parameters.py b/codegen/templates/GithubObject.Parameters.py index 2267e7b3..aca39680 100644 --- a/codegen/templates/GithubObject.Parameters.py +++ b/codegen/templates/GithubObject.Parameters.py @@ -1 +1 @@ -self{% for parameter in function.mandatoryParameters %}, {{ parameter.name }}{% endfor %}{% for parameter in function.optionalParameters %}, {{ parameter.name }} = DefaultValueForOptionalParameters{% endfor %}{% if function.variadicParameter %}, *{{ function.variadicParameter.name }}s{% endif %} \ No newline at end of file +self{% for parameter in function.mandatoryParameters %}, {{ parameter.name }}{% endfor %}{% for parameter in function.optionalParameters %}, {{ parameter.name }} = GithubObject.NotSet{% endfor %}{% if function.variadicParameter %}, *{{ function.variadicParameter.name }}s{% endif %} \ No newline at end of file diff --git a/codegen/templates/GithubObject.PublicAttributes.py b/codegen/templates/GithubObject.PublicAttributes.py index d51b49dc..c92f927e 100644 --- a/codegen/templates/GithubObject.PublicAttributes.py +++ b/codegen/templates/GithubObject.PublicAttributes.py @@ -2,7 +2,7 @@ @property def {{ attribute.name }}( self ): {% if class.isCompletable %} - self._completeIfNeeded( self._{{ attribute.name }} ) + self._completeIfNotSet( self._{{ attribute.name }} ) {% endif %} - return self._{{ attribute.name }} + return self._NoneIfNotSet( self._{{ attribute.name }} ) {% endfor %} diff --git a/codegen/templates/GithubObject.py b/codegen/templates/GithubObject.py index 31694485..18ab33f4 100644 --- a/codegen/templates/GithubObject.py +++ b/codegen/templates/GithubObject.py @@ -7,9 +7,6 @@ import GithubObject {% if class.needsPaginatedList %} import PaginatedList {% endif %} -{% if class.needsDefaultValue %} -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters -{% endif %} {% if class.dependencies %} ########## diff --git a/src/github/AuthenticatedUser.py b/src/github/AuthenticatedUser.py index f82809aa..b84b1cf8 100644 --- a/src/github/AuthenticatedUser.py +++ b/src/github/AuthenticatedUser.py @@ -3,7 +3,6 @@ import GithubObject import PaginatedList -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import Gist import Repository @@ -18,128 +17,128 @@ import Authorization class AuthenticatedUser( GithubObject.GithubObject ): @property def avatar_url( self ): - self._completeIfNeeded( self._avatar_url ) - return self._avatar_url + self._completeIfNotSet( self._avatar_url ) + return self._NoneIfNotSet( self._avatar_url ) @property def bio( self ): - self._completeIfNeeded( self._bio ) - return self._bio + self._completeIfNotSet( self._bio ) + return self._NoneIfNotSet( self._bio ) @property def blog( self ): - self._completeIfNeeded( self._blog ) - return self._blog + self._completeIfNotSet( self._blog ) + return self._NoneIfNotSet( self._blog ) @property def collaborators( self ): - self._completeIfNeeded( self._collaborators ) - return self._collaborators + self._completeIfNotSet( self._collaborators ) + return self._NoneIfNotSet( self._collaborators ) @property def company( self ): - self._completeIfNeeded( self._company ) - return self._company + self._completeIfNotSet( self._company ) + return self._NoneIfNotSet( self._company ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def disk_usage( self ): - self._completeIfNeeded( self._disk_usage ) - return self._disk_usage + self._completeIfNotSet( self._disk_usage ) + return self._NoneIfNotSet( self._disk_usage ) @property def email( self ): - self._completeIfNeeded( self._email ) - return self._email + self._completeIfNotSet( self._email ) + return self._NoneIfNotSet( self._email ) @property def followers( self ): - self._completeIfNeeded( self._followers ) - return self._followers + self._completeIfNotSet( self._followers ) + return self._NoneIfNotSet( self._followers ) @property def following( self ): - self._completeIfNeeded( self._following ) - return self._following + self._completeIfNotSet( self._following ) + return self._NoneIfNotSet( self._following ) @property def gravatar_id( self ): - self._completeIfNeeded( self._gravatar_id ) - return self._gravatar_id + self._completeIfNotSet( self._gravatar_id ) + return self._NoneIfNotSet( self._gravatar_id ) @property def hireable( self ): - self._completeIfNeeded( self._hireable ) - return self._hireable + self._completeIfNotSet( self._hireable ) + return self._NoneIfNotSet( self._hireable ) @property def html_url( self ): - self._completeIfNeeded( self._html_url ) - return self._html_url + self._completeIfNotSet( self._html_url ) + return self._NoneIfNotSet( self._html_url ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def location( self ): - self._completeIfNeeded( self._location ) - return self._location + self._completeIfNotSet( self._location ) + return self._NoneIfNotSet( self._location ) @property def login( self ): - self._completeIfNeeded( self._login ) - return self._login + self._completeIfNotSet( self._login ) + return self._NoneIfNotSet( self._login ) @property def name( self ): - self._completeIfNeeded( self._name ) - return self._name + self._completeIfNotSet( self._name ) + return self._NoneIfNotSet( self._name ) @property def owned_private_repos( self ): - self._completeIfNeeded( self._owned_private_repos ) - return self._owned_private_repos + self._completeIfNotSet( self._owned_private_repos ) + return self._NoneIfNotSet( self._owned_private_repos ) @property def plan( self ): - self._completeIfNeeded( self._plan ) - return self._plan + self._completeIfNotSet( self._plan ) + return self._NoneIfNotSet( self._plan ) @property def private_gists( self ): - self._completeIfNeeded( self._private_gists ) - return self._private_gists + self._completeIfNotSet( self._private_gists ) + return self._NoneIfNotSet( self._private_gists ) @property def public_gists( self ): - self._completeIfNeeded( self._public_gists ) - return self._public_gists + self._completeIfNotSet( self._public_gists ) + return self._NoneIfNotSet( self._public_gists ) @property def public_repos( self ): - self._completeIfNeeded( self._public_repos ) - return self._public_repos + self._completeIfNotSet( self._public_repos ) + return self._NoneIfNotSet( self._public_repos ) @property def total_private_repos( self ): - self._completeIfNeeded( self._total_private_repos ) - return self._total_private_repos + self._completeIfNotSet( self._total_private_repos ) + return self._NoneIfNotSet( self._total_private_repos ) @property def type( self ): - self._completeIfNeeded( self._type ) - return self._type + self._completeIfNotSet( self._type ) + return self._NoneIfNotSet( self._type ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def add_to_emails( self, *emails ): assert all( isinstance( email, ( str, unicode ) ) for email in emails ), emails @@ -172,19 +171,19 @@ class AuthenticatedUser( GithubObject.GithubObject ): ) self._checkStatus( status, data ) - def create_authorization( self, scopes = DefaultValueForOptionalParameters, note = DefaultValueForOptionalParameters, note_url = DefaultValueForOptionalParameters ): - if scopes is not DefaultValueForOptionalParameters: + def create_authorization( self, scopes = GithubObject.NotSet, note = GithubObject.NotSet, note_url = GithubObject.NotSet ): + if scopes is not GithubObject.NotSet: assert all( isinstance( element, ( str, unicode ) ) for element in scopes ), scopes - if note is not DefaultValueForOptionalParameters: + if note is not GithubObject.NotSet: assert isinstance( note, ( str, unicode ) ), note - if note_url is not DefaultValueForOptionalParameters: + if note_url is not GithubObject.NotSet: assert isinstance( note_url, ( str, unicode ) ), note_url post_parameters = dict() - if scopes is not DefaultValueForOptionalParameters: + if scopes is not GithubObject.NotSet: post_parameters[ "scopes" ] = scopes - if note is not DefaultValueForOptionalParameters: + if note is not GithubObject.NotSet: post_parameters[ "note" ] = note - if note_url is not DefaultValueForOptionalParameters: + if note_url is not GithubObject.NotSet: post_parameters[ "note_url" ] = note_url status, headers, data = self._request( "POST", @@ -206,15 +205,15 @@ class AuthenticatedUser( GithubObject.GithubObject ): self._checkStatus( status, data ) return Repository.Repository( self._requester, data, completed = True ) - def create_gist( self, public, files, description = DefaultValueForOptionalParameters ): + def create_gist( self, public, files, description = GithubObject.NotSet ): assert isinstance( public, bool ), public - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: assert isinstance( description, ( str, unicode ) ), description post_parameters = { "public": public, "files": files, } - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: post_parameters[ "description" ] = description status, headers, data = self._request( "POST", @@ -241,34 +240,34 @@ class AuthenticatedUser( GithubObject.GithubObject ): self._checkStatus( status, data ) return UserKey.UserKey( self._requester, data, completed = True ) - def create_repo( self, name, description = DefaultValueForOptionalParameters, homepage = DefaultValueForOptionalParameters, private = DefaultValueForOptionalParameters, has_issues = DefaultValueForOptionalParameters, has_wiki = DefaultValueForOptionalParameters, has_downloads = DefaultValueForOptionalParameters ): + def create_repo( self, name, description = GithubObject.NotSet, homepage = GithubObject.NotSet, private = GithubObject.NotSet, has_issues = GithubObject.NotSet, has_wiki = GithubObject.NotSet, has_downloads = GithubObject.NotSet ): assert isinstance( name, ( str, unicode ) ), name - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: assert isinstance( description, ( str, unicode ) ), description - if homepage is not DefaultValueForOptionalParameters: + if homepage is not GithubObject.NotSet: assert isinstance( homepage, ( str, unicode ) ), homepage - if private is not DefaultValueForOptionalParameters: + if private is not GithubObject.NotSet: assert isinstance( private, bool ), private - if has_issues is not DefaultValueForOptionalParameters: + if has_issues is not GithubObject.NotSet: assert isinstance( has_issues, bool ), has_issues - if has_wiki is not DefaultValueForOptionalParameters: + if has_wiki is not GithubObject.NotSet: assert isinstance( has_wiki, bool ), has_wiki - if has_downloads is not DefaultValueForOptionalParameters: + if has_downloads is not GithubObject.NotSet: assert isinstance( has_downloads, bool ), has_downloads post_parameters = { "name": name, } - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: post_parameters[ "description" ] = description - if homepage is not DefaultValueForOptionalParameters: + if homepage is not GithubObject.NotSet: post_parameters[ "homepage" ] = homepage - if private is not DefaultValueForOptionalParameters: + if private is not GithubObject.NotSet: post_parameters[ "private" ] = private - if has_issues is not DefaultValueForOptionalParameters: + if has_issues is not GithubObject.NotSet: post_parameters[ "has_issues" ] = has_issues - if has_wiki is not DefaultValueForOptionalParameters: + if has_wiki is not GithubObject.NotSet: post_parameters[ "has_wiki" ] = has_wiki - if has_downloads is not DefaultValueForOptionalParameters: + if has_downloads is not GithubObject.NotSet: post_parameters[ "has_downloads" ] = has_downloads status, headers, data = self._request( "POST", @@ -279,35 +278,35 @@ class AuthenticatedUser( GithubObject.GithubObject ): self._checkStatus( status, data ) return Repository.Repository( self._requester, data, completed = True ) - def edit( self, name = DefaultValueForOptionalParameters, email = DefaultValueForOptionalParameters, blog = DefaultValueForOptionalParameters, company = DefaultValueForOptionalParameters, location = DefaultValueForOptionalParameters, hireable = DefaultValueForOptionalParameters, bio = DefaultValueForOptionalParameters ): - if name is not DefaultValueForOptionalParameters: + def edit( self, name = GithubObject.NotSet, email = GithubObject.NotSet, blog = GithubObject.NotSet, company = GithubObject.NotSet, location = GithubObject.NotSet, hireable = GithubObject.NotSet, bio = GithubObject.NotSet ): + if name is not GithubObject.NotSet: assert isinstance( name, ( str, unicode ) ), name - if email is not DefaultValueForOptionalParameters: + if email is not GithubObject.NotSet: assert isinstance( email, ( str, unicode ) ), email - if blog is not DefaultValueForOptionalParameters: + if blog is not GithubObject.NotSet: assert isinstance( blog, ( str, unicode ) ), blog - if company is not DefaultValueForOptionalParameters: + if company is not GithubObject.NotSet: assert isinstance( company, ( str, unicode ) ), company - if location is not DefaultValueForOptionalParameters: + if location is not GithubObject.NotSet: assert isinstance( location, ( str, unicode ) ), location - if hireable is not DefaultValueForOptionalParameters: + if hireable is not GithubObject.NotSet: assert isinstance( hireable, bool ), hireable - if bio is not DefaultValueForOptionalParameters: + if bio is not GithubObject.NotSet: assert isinstance( bio, ( str, unicode ) ), bio post_parameters = dict() - if name is not DefaultValueForOptionalParameters: + if name is not GithubObject.NotSet: post_parameters[ "name" ] = name - if email is not DefaultValueForOptionalParameters: + if email is not GithubObject.NotSet: post_parameters[ "email" ] = email - if blog is not DefaultValueForOptionalParameters: + if blog is not GithubObject.NotSet: post_parameters[ "blog" ] = blog - if company is not DefaultValueForOptionalParameters: + if company is not GithubObject.NotSet: post_parameters[ "company" ] = company - if location is not DefaultValueForOptionalParameters: + if location is not GithubObject.NotSet: post_parameters[ "location" ] = location - if hireable is not DefaultValueForOptionalParameters: + if hireable is not GithubObject.NotSet: post_parameters[ "hireable" ] = hireable - if bio is not DefaultValueForOptionalParameters: + if bio is not GithubObject.NotSet: post_parameters[ "bio" ] = bio status, headers, data = self._request( "PATCH", @@ -497,19 +496,19 @@ class AuthenticatedUser( GithubObject.GithubObject ): self._checkStatus( status, data ) return Repository.Repository( self._requester, data, completed = True ) - def get_repos( self, type = DefaultValueForOptionalParameters, sort = DefaultValueForOptionalParameters, direction = DefaultValueForOptionalParameters ): - if type is not DefaultValueForOptionalParameters: + def get_repos( self, type = GithubObject.NotSet, sort = GithubObject.NotSet, direction = GithubObject.NotSet ): + if type is not GithubObject.NotSet: assert isinstance( type, ( str, unicode ) ), type - if sort is not DefaultValueForOptionalParameters: + if sort is not GithubObject.NotSet: assert isinstance( sort, ( str, unicode ) ), sort - if direction is not DefaultValueForOptionalParameters: + if direction is not GithubObject.NotSet: assert isinstance( direction, ( str, unicode ) ), direction url_parameters = dict() - if type is not DefaultValueForOptionalParameters: + if type is not GithubObject.NotSet: url_parameters[ "type" ] = type - if sort is not DefaultValueForOptionalParameters: + if sort is not GithubObject.NotSet: url_parameters[ "sort" ] = sort - if direction is not DefaultValueForOptionalParameters: + if direction is not GithubObject.NotSet: url_parameters[ "direction" ] = direction status, headers, data = self._request( "GET", @@ -607,105 +606,105 @@ class AuthenticatedUser( GithubObject.GithubObject ): self._checkStatus( status, data ) def _initAttributes( self ): - self._avatar_url = None - self._bio = None - self._blog = None - self._collaborators = None - self._company = None - self._created_at = None - self._disk_usage = None - self._email = None - self._followers = None - self._following = None - self._gravatar_id = None - self._hireable = None - self._html_url = None - self._id = None - self._location = None - self._login = None - self._name = None - self._owned_private_repos = None - self._plan = None - self._private_gists = None - self._public_gists = None - self._public_repos = None - self._total_private_repos = None - self._type = None - self._url = None + self._avatar_url = GithubObject.NotSet + self._bio = GithubObject.NotSet + self._blog = GithubObject.NotSet + self._collaborators = GithubObject.NotSet + self._company = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._disk_usage = GithubObject.NotSet + self._email = GithubObject.NotSet + self._followers = GithubObject.NotSet + self._following = GithubObject.NotSet + self._gravatar_id = GithubObject.NotSet + self._hireable = GithubObject.NotSet + self._html_url = GithubObject.NotSet + self._id = GithubObject.NotSet + self._location = GithubObject.NotSet + self._login = GithubObject.NotSet + self._name = GithubObject.NotSet + self._owned_private_repos = GithubObject.NotSet + self._plan = GithubObject.NotSet + self._private_gists = GithubObject.NotSet + self._public_gists = GithubObject.NotSet + self._public_repos = GithubObject.NotSet + self._total_private_repos = GithubObject.NotSet + self._type = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "avatar_url" in attributes and attributes[ "avatar_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "avatar_url" ], ( str, unicode ) ), attributes[ "avatar_url" ] + if "avatar_url" in attributes: # pragma no branch + assert attributes[ "avatar_url" ] is None or isinstance( attributes[ "avatar_url" ], ( str, unicode ) ), attributes[ "avatar_url" ] self._avatar_url = attributes[ "avatar_url" ] - if "bio" in attributes and attributes[ "bio" ] is not None: # pragma no branch - assert isinstance( attributes[ "bio" ], ( str, unicode ) ), attributes[ "bio" ] + if "bio" in attributes: # pragma no branch + assert attributes[ "bio" ] is None or isinstance( attributes[ "bio" ], ( str, unicode ) ), attributes[ "bio" ] self._bio = attributes[ "bio" ] - if "blog" in attributes and attributes[ "blog" ] is not None: # pragma no branch - assert isinstance( attributes[ "blog" ], ( str, unicode ) ), attributes[ "blog" ] + if "blog" in attributes: # pragma no branch + assert attributes[ "blog" ] is None or isinstance( attributes[ "blog" ], ( str, unicode ) ), attributes[ "blog" ] self._blog = attributes[ "blog" ] - if "collaborators" in attributes and attributes[ "collaborators" ] is not None: # pragma no branch - assert isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ] + if "collaborators" in attributes: # pragma no branch + assert attributes[ "collaborators" ] is None or isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ] self._collaborators = attributes[ "collaborators" ] - if "company" in attributes and attributes[ "company" ] is not None: # pragma no branch - assert isinstance( attributes[ "company" ], ( str, unicode ) ), attributes[ "company" ] + if "company" in attributes: # pragma no branch + assert attributes[ "company" ] is None or isinstance( attributes[ "company" ], ( str, unicode ) ), attributes[ "company" ] self._company = attributes[ "company" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "disk_usage" in attributes and attributes[ "disk_usage" ] is not None: # pragma no branch - assert isinstance( attributes[ "disk_usage" ], int ), attributes[ "disk_usage" ] + 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" ] - if "email" in attributes and attributes[ "email" ] is not None: # pragma no branch - assert isinstance( attributes[ "email" ], ( str, unicode ) ), attributes[ "email" ] + if "email" in attributes: # pragma no branch + assert attributes[ "email" ] is None or isinstance( attributes[ "email" ], ( str, unicode ) ), attributes[ "email" ] self._email = attributes[ "email" ] - if "followers" in attributes and attributes[ "followers" ] is not None: # pragma no branch - assert isinstance( attributes[ "followers" ], int ), attributes[ "followers" ] + if "followers" in attributes: # pragma no branch + assert attributes[ "followers" ] is None or isinstance( attributes[ "followers" ], int ), attributes[ "followers" ] self._followers = attributes[ "followers" ] - if "following" in attributes and attributes[ "following" ] is not None: # pragma no branch - assert isinstance( attributes[ "following" ], int ), attributes[ "following" ] + if "following" in attributes: # pragma no branch + assert attributes[ "following" ] is None or isinstance( attributes[ "following" ], int ), attributes[ "following" ] self._following = attributes[ "following" ] - if "gravatar_id" in attributes and attributes[ "gravatar_id" ] is not None: # pragma no branch - assert isinstance( attributes[ "gravatar_id" ], ( str, unicode ) ), attributes[ "gravatar_id" ] + if "gravatar_id" in attributes: # pragma no branch + assert attributes[ "gravatar_id" ] is None or isinstance( attributes[ "gravatar_id" ], ( str, unicode ) ), attributes[ "gravatar_id" ] self._gravatar_id = attributes[ "gravatar_id" ] - if "hireable" in attributes and attributes[ "hireable" ] is not None: # pragma no branch - assert isinstance( attributes[ "hireable" ], bool ), attributes[ "hireable" ] + if "hireable" in attributes: # pragma no branch + assert attributes[ "hireable" ] is None or isinstance( attributes[ "hireable" ], bool ), attributes[ "hireable" ] self._hireable = attributes[ "hireable" ] - if "html_url" in attributes and attributes[ "html_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ] + 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" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "location" in attributes and attributes[ "location" ] is not None: # pragma no branch - assert isinstance( attributes[ "location" ], ( str, unicode ) ), attributes[ "location" ] + if "location" in attributes: # pragma no branch + assert attributes[ "location" ] is None or isinstance( attributes[ "location" ], ( str, unicode ) ), attributes[ "location" ] self._location = attributes[ "location" ] - if "login" in attributes and attributes[ "login" ] is not None: # pragma no branch - assert isinstance( attributes[ "login" ], ( str, unicode ) ), attributes[ "login" ] + if "login" in attributes: # pragma no branch + assert attributes[ "login" ] is None or isinstance( attributes[ "login" ], ( str, unicode ) ), attributes[ "login" ] self._login = attributes[ "login" ] - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] - if "owned_private_repos" in attributes and attributes[ "owned_private_repos" ] is not None: # pragma no branch - assert isinstance( attributes[ "owned_private_repos" ], int ), attributes[ "owned_private_repos" ] + if "owned_private_repos" in attributes: # pragma no branch + assert attributes[ "owned_private_repos" ] is None or isinstance( attributes[ "owned_private_repos" ], int ), attributes[ "owned_private_repos" ] self._owned_private_repos = attributes[ "owned_private_repos" ] - if "plan" in attributes and attributes[ "plan" ] is not None: # pragma no branch - assert isinstance( attributes[ "plan" ], dict ), attributes[ "plan" ] - self._plan = Plan.Plan( self._requester, attributes[ "plan" ], completed = False ) - if "private_gists" in attributes and attributes[ "private_gists" ] is not None: # pragma no branch - assert isinstance( attributes[ "private_gists" ], int ), attributes[ "private_gists" ] + if "plan" in attributes: # pragma no branch + assert attributes[ "plan" ] is None or isinstance( attributes[ "plan" ], dict ), attributes[ "plan" ] + self._plan = None if attributes[ "plan" ] is None else Plan.Plan( self._requester, attributes[ "plan" ], completed = False ) + if "private_gists" in attributes: # pragma no branch + assert attributes[ "private_gists" ] is None or isinstance( attributes[ "private_gists" ], int ), attributes[ "private_gists" ] self._private_gists = attributes[ "private_gists" ] - if "public_gists" in attributes and attributes[ "public_gists" ] is not None: # pragma no branch - assert isinstance( attributes[ "public_gists" ], int ), attributes[ "public_gists" ] + if "public_gists" in attributes: # pragma no branch + assert attributes[ "public_gists" ] is None or isinstance( attributes[ "public_gists" ], int ), attributes[ "public_gists" ] self._public_gists = attributes[ "public_gists" ] - if "public_repos" in attributes and attributes[ "public_repos" ] is not None: # pragma no branch - assert isinstance( attributes[ "public_repos" ], int ), attributes[ "public_repos" ] + if "public_repos" in attributes: # pragma no branch + assert attributes[ "public_repos" ] is None or isinstance( attributes[ "public_repos" ], int ), attributes[ "public_repos" ] self._public_repos = attributes[ "public_repos" ] - if "total_private_repos" in attributes and attributes[ "total_private_repos" ] is not None: # pragma no branch - assert isinstance( attributes[ "total_private_repos" ], int ), attributes[ "total_private_repos" ] + if "total_private_repos" in attributes: # pragma no branch + assert attributes[ "total_private_repos" ] is None or isinstance( attributes[ "total_private_repos" ], int ), attributes[ "total_private_repos" ] self._total_private_repos = attributes[ "total_private_repos" ] - if "type" in attributes and attributes[ "type" ] is not None: # pragma no branch - assert isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ] + if "type" in attributes: # pragma no branch + assert attributes[ "type" ] is None or isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ] self._type = attributes[ "type" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/Authorization.py b/src/github/Authorization.py index 84d8f84e..c656f308 100644 --- a/src/github/Authorization.py +++ b/src/github/Authorization.py @@ -2,55 +2,54 @@ # Do not modify it manually, your work would be lost. import GithubObject -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import AuthorizationApplication class Authorization( GithubObject.GithubObject ): @property def app( self ): - self._completeIfNeeded( self._app ) - return self._app + self._completeIfNotSet( self._app ) + return self._NoneIfNotSet( self._app ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def note( self ): - self._completeIfNeeded( self._note ) - return self._note + self._completeIfNotSet( self._note ) + return self._NoneIfNotSet( self._note ) @property def note_url( self ): - self._completeIfNeeded( self._note_url ) - return self._note_url + self._completeIfNotSet( self._note_url ) + return self._NoneIfNotSet( self._note_url ) @property def scopes( self ): - self._completeIfNeeded( self._scopes ) - return self._scopes + self._completeIfNotSet( self._scopes ) + return self._NoneIfNotSet( self._scopes ) @property def token( self ): - self._completeIfNeeded( self._token ) - return self._token + self._completeIfNotSet( self._token ) + return self._NoneIfNotSet( self._token ) @property def updated_at( self ): - self._completeIfNeeded( self._updated_at ) - return self._updated_at + self._completeIfNotSet( self._updated_at ) + return self._NoneIfNotSet( self._updated_at ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def delete( self ): status, headers, data = self._request( @@ -61,27 +60,27 @@ class Authorization( GithubObject.GithubObject ): ) self._checkStatus( status, data ) - def edit( self, scopes = DefaultValueForOptionalParameters, add_scopes = DefaultValueForOptionalParameters, remove_scopes = DefaultValueForOptionalParameters, note = DefaultValueForOptionalParameters, note_url = DefaultValueForOptionalParameters ): - if scopes is not DefaultValueForOptionalParameters: + def edit( self, scopes = GithubObject.NotSet, add_scopes = GithubObject.NotSet, remove_scopes = GithubObject.NotSet, note = GithubObject.NotSet, note_url = GithubObject.NotSet ): + if scopes is not GithubObject.NotSet: assert all( isinstance( element, ( str, unicode ) ) for element in scopes ), scopes - if add_scopes is not DefaultValueForOptionalParameters: + if add_scopes is not GithubObject.NotSet: assert all( isinstance( element, ( str, unicode ) ) for element in add_scopes ), add_scopes - if remove_scopes is not DefaultValueForOptionalParameters: + if remove_scopes is not GithubObject.NotSet: assert all( isinstance( element, ( str, unicode ) ) for element in remove_scopes ), remove_scopes - if note is not DefaultValueForOptionalParameters: + if note is not GithubObject.NotSet: assert isinstance( note, ( str, unicode ) ), note - if note_url is not DefaultValueForOptionalParameters: + if note_url is not GithubObject.NotSet: assert isinstance( note_url, ( str, unicode ) ), note_url post_parameters = dict() - if scopes is not DefaultValueForOptionalParameters: + if scopes is not GithubObject.NotSet: post_parameters[ "scopes" ] = scopes - if add_scopes is not DefaultValueForOptionalParameters: + if add_scopes is not GithubObject.NotSet: post_parameters[ "add_scopes" ] = add_scopes - if remove_scopes is not DefaultValueForOptionalParameters: + if remove_scopes is not GithubObject.NotSet: post_parameters[ "remove_scopes" ] = remove_scopes - if note is not DefaultValueForOptionalParameters: + if note is not GithubObject.NotSet: post_parameters[ "note" ] = note - if note_url is not DefaultValueForOptionalParameters: + if note_url is not GithubObject.NotSet: post_parameters[ "note_url" ] = note_url status, headers, data = self._request( "PATCH", @@ -93,41 +92,41 @@ class Authorization( GithubObject.GithubObject ): self._useAttributes( data ) def _initAttributes( self ): - self._app = None - self._created_at = None - self._id = None - self._note = None - self._note_url = None - self._scopes = None - self._token = None - self._updated_at = None - self._url = None + self._app = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._id = GithubObject.NotSet + self._note = GithubObject.NotSet + self._note_url = GithubObject.NotSet + self._scopes = GithubObject.NotSet + self._token = GithubObject.NotSet + self._updated_at = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "app" in attributes and attributes[ "app" ] is not None: # pragma no branch - assert isinstance( attributes[ "app" ], dict ), attributes[ "app" ] - self._app = AuthorizationApplication.AuthorizationApplication( self._requester, attributes[ "app" ], completed = False ) - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + if "app" in attributes: # pragma no branch + assert attributes[ "app" ] is None or isinstance( attributes[ "app" ], dict ), attributes[ "app" ] + 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 = attributes[ "created_at" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "note" in attributes and attributes[ "note" ] is not None: # pragma no branch - assert isinstance( attributes[ "note" ], ( str, unicode ) ), attributes[ "note" ] + if "note" in attributes: # pragma no branch + assert attributes[ "note" ] is None or isinstance( attributes[ "note" ], ( str, unicode ) ), attributes[ "note" ] self._note = attributes[ "note" ] - if "note_url" in attributes and attributes[ "note_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "note_url" ], ( str, unicode ) ), attributes[ "note_url" ] + if "note_url" in attributes: # pragma no branch + 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 and attributes[ "scopes" ] is not None: # pragma no branch + if "scopes" in attributes: # pragma no branch assert all( isinstance( element, ( str, unicode ) ) for element in attributes[ "scopes" ] ), attributes[ "scopes" ] self._scopes = attributes[ "scopes" ] - if "token" in attributes and attributes[ "token" ] is not None: # pragma no branch - assert isinstance( attributes[ "token" ], ( str, unicode ) ), attributes[ "token" ] + if "token" in attributes: # pragma no branch + assert attributes[ "token" ] is None or isinstance( attributes[ "token" ], ( str, unicode ) ), attributes[ "token" ] self._token = attributes[ "token" ] - if "updated_at" in attributes and attributes[ "updated_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ] + 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 = attributes[ "updated_at" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/AuthorizationApplication.py b/src/github/AuthorizationApplication.py index e71ced1f..e5239111 100644 --- a/src/github/AuthorizationApplication.py +++ b/src/github/AuthorizationApplication.py @@ -6,22 +6,22 @@ import GithubObject class AuthorizationApplication( GithubObject.GithubObject ): @property def name( self ): - self._completeIfNeeded( self._name ) - return self._name + self._completeIfNotSet( self._name ) + return self._NoneIfNotSet( self._name ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def _initAttributes( self ): - self._name = None - self._url = None + self._name = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/Branch.py b/src/github/Branch.py index c40dbaf4..aca66779 100644 --- a/src/github/Branch.py +++ b/src/github/Branch.py @@ -8,20 +8,20 @@ import Commit class Branch( GithubObject.BasicGithubObject ): @property def commit( self ): - return self._commit + return self._NoneIfNotSet( self._commit ) @property def name( self ): - return self._name + return self._NoneIfNotSet( self._name ) def _initAttributes( self ): - self._commit = None - self._name = None + self._commit = GithubObject.NotSet + self._name = GithubObject.NotSet def _useAttributes( self, attributes ): - if "commit" in attributes and attributes[ "commit" ] is not None: # pragma no branch - assert isinstance( attributes[ "commit" ], dict ), attributes[ "commit" ] - self._commit = Commit.Commit( self._requester, attributes[ "commit" ], completed = False ) - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "commit" in attributes: # pragma no branch + assert attributes[ "commit" ] is None or isinstance( attributes[ "commit" ], dict ), attributes[ "commit" ] + self._commit = None if attributes[ "commit" ] is None else Commit.Commit( self._requester, attributes[ "commit" ], completed = False ) + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] diff --git a/src/github/Commit.py b/src/github/Commit.py index a48cfd3c..ebc19242 100644 --- a/src/github/Commit.py +++ b/src/github/Commit.py @@ -3,7 +3,6 @@ import GithubObject import PaginatedList -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import CommitFile import NamedUser @@ -15,60 +14,60 @@ import CommitComment class Commit( GithubObject.GithubObject ): @property def author( self ): - self._completeIfNeeded( self._author ) - return self._author + self._completeIfNotSet( self._author ) + return self._NoneIfNotSet( self._author ) @property def commit( self ): - self._completeIfNeeded( self._commit ) - return self._commit + self._completeIfNotSet( self._commit ) + return self._NoneIfNotSet( self._commit ) @property def committer( self ): - self._completeIfNeeded( self._committer ) - return self._committer + self._completeIfNotSet( self._committer ) + return self._NoneIfNotSet( self._committer ) @property def files( self ): - self._completeIfNeeded( self._files ) - return self._files + self._completeIfNotSet( self._files ) + return self._NoneIfNotSet( self._files ) @property def parents( self ): - self._completeIfNeeded( self._parents ) - return self._parents + self._completeIfNotSet( self._parents ) + return self._NoneIfNotSet( self._parents ) @property def sha( self ): - self._completeIfNeeded( self._sha ) - return self._sha + self._completeIfNotSet( self._sha ) + return self._NoneIfNotSet( self._sha ) @property def stats( self ): - self._completeIfNeeded( self._stats ) - return self._stats + self._completeIfNotSet( self._stats ) + return self._NoneIfNotSet( self._stats ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) - def create_comment( self, body, line = DefaultValueForOptionalParameters, path = DefaultValueForOptionalParameters, position = DefaultValueForOptionalParameters ): + def create_comment( self, body, line = GithubObject.NotSet, path = GithubObject.NotSet, position = GithubObject.NotSet ): assert isinstance( body, ( str, unicode ) ), body - if line is not DefaultValueForOptionalParameters: + if line is not GithubObject.NotSet: assert isinstance( line, int ), line - if path is not DefaultValueForOptionalParameters: + if path is not GithubObject.NotSet: assert isinstance( path, ( str, unicode ) ), path - if position is not DefaultValueForOptionalParameters: + if position is not GithubObject.NotSet: assert isinstance( position, int ), position post_parameters = { "body": body, } - if line is not DefaultValueForOptionalParameters: + if line is not GithubObject.NotSet: post_parameters[ "line" ] = line - if path is not DefaultValueForOptionalParameters: + if path is not GithubObject.NotSet: post_parameters[ "path" ] = path - if position is not DefaultValueForOptionalParameters: + if position is not GithubObject.NotSet: post_parameters[ "position" ] = position status, headers, data = self._request( "POST", @@ -95,43 +94,43 @@ class Commit( GithubObject.GithubObject ): ) def _initAttributes( self ): - self._author = None - self._commit = None - self._committer = None - self._files = None - self._parents = None - self._sha = None - self._stats = None - self._url = None + self._author = GithubObject.NotSet + self._commit = GithubObject.NotSet + self._committer = GithubObject.NotSet + self._files = GithubObject.NotSet + self._parents = GithubObject.NotSet + self._sha = GithubObject.NotSet + self._stats = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "author" in attributes and attributes[ "author" ] is not None: # pragma no branch - assert isinstance( attributes[ "author" ], dict ), attributes[ "author" ] - self._author = NamedUser.NamedUser( self._requester, attributes[ "author" ], completed = False ) - if "commit" in attributes and attributes[ "commit" ] is not None: # pragma no branch - assert isinstance( attributes[ "commit" ], dict ), attributes[ "commit" ] - self._commit = GitCommit.GitCommit( self._requester, attributes[ "commit" ], completed = False ) - if "committer" in attributes and attributes[ "committer" ] is not None: # pragma no branch - assert isinstance( attributes[ "committer" ], dict ), attributes[ "committer" ] - self._committer = NamedUser.NamedUser( self._requester, attributes[ "committer" ], completed = False ) - if "files" in attributes and attributes[ "files" ] is not None: # pragma no branch + if "author" in attributes: # pragma no branch + assert attributes[ "author" ] is None or isinstance( attributes[ "author" ], dict ), attributes[ "author" ] + self._author = None if attributes[ "author" ] is None else NamedUser.NamedUser( self._requester, attributes[ "author" ], completed = False ) + if "commit" in attributes: # pragma no branch + assert attributes[ "commit" ] is None or isinstance( attributes[ "commit" ], dict ), attributes[ "commit" ] + self._commit = None if attributes[ "commit" ] is None else GitCommit.GitCommit( self._requester, attributes[ "commit" ], completed = False ) + if "committer" in attributes: # pragma no branch + 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 = [ CommitFile.CommitFile( self._requester, element, completed = False ) for element in attributes[ "files" ] ] - if "parents" in attributes and attributes[ "parents" ] is not None: # pragma no branch + if "parents" in attributes: # pragma no branch assert all( isinstance( element, dict ) for element in attributes[ "parents" ] ), attributes[ "parents" ] self._parents = [ Commit( self._requester, element, completed = False ) for element in attributes[ "parents" ] ] - if "sha" in attributes and attributes[ "sha" ] is not None: # pragma no branch - assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] + if "sha" in attributes: # pragma no branch + assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] self._sha = attributes[ "sha" ] - if "stats" in attributes and attributes[ "stats" ] is not None: # pragma no branch - assert isinstance( attributes[ "stats" ], dict ), attributes[ "stats" ] - self._stats = CommitStats.CommitStats( self._requester, attributes[ "stats" ], completed = False ) - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "stats" in attributes: # pragma no branch + assert attributes[ "stats" ] is None or isinstance( attributes[ "stats" ], dict ), attributes[ "stats" ] + self._stats = None if attributes[ "stats" ] is None else CommitStats.CommitStats( self._requester, attributes[ "stats" ], completed = False ) + 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/src/github/CommitComment.py b/src/github/CommitComment.py index 6ef5a8f3..a8390c5c 100644 --- a/src/github/CommitComment.py +++ b/src/github/CommitComment.py @@ -8,58 +8,58 @@ import NamedUser class CommitComment( GithubObject.GithubObject ): @property def body( self ): - self._completeIfNeeded( self._body ) - return self._body + self._completeIfNotSet( self._body ) + return self._NoneIfNotSet( self._body ) @property def commit_id( self ): - self._completeIfNeeded( self._commit_id ) - return self._commit_id + self._completeIfNotSet( self._commit_id ) + return self._NoneIfNotSet( self._commit_id ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def html_url( self ): - self._completeIfNeeded( self._html_url ) - return self._html_url + self._completeIfNotSet( self._html_url ) + return self._NoneIfNotSet( self._html_url ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def line( self ): - self._completeIfNeeded( self._line ) - return self._line + self._completeIfNotSet( self._line ) + return self._NoneIfNotSet( self._line ) @property def path( self ): - self._completeIfNeeded( self._path ) - return self._path + self._completeIfNotSet( self._path ) + return self._NoneIfNotSet( self._path ) @property def position( self ): - self._completeIfNeeded( self._position ) - return self._position + self._completeIfNotSet( self._position ) + return self._NoneIfNotSet( self._position ) @property def updated_at( self ): - self._completeIfNeeded( self._updated_at ) - return self._updated_at + self._completeIfNotSet( self._updated_at ) + return self._NoneIfNotSet( self._updated_at ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) @property def user( self ): - self._completeIfNeeded( self._user ) - return self._user + self._completeIfNotSet( self._user ) + return self._NoneIfNotSet( self._user ) def delete( self ): status, headers, data = self._request( @@ -85,49 +85,49 @@ class CommitComment( GithubObject.GithubObject ): self._useAttributes( data ) def _initAttributes( self ): - self._body = None - self._commit_id = None - self._created_at = None - self._html_url = None - self._id = None - self._line = None - self._path = None - self._position = None - self._updated_at = None - self._url = None - self._user = None + self._body = GithubObject.NotSet + self._commit_id = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._html_url = GithubObject.NotSet + self._id = GithubObject.NotSet + self._line = GithubObject.NotSet + self._path = GithubObject.NotSet + self._position = GithubObject.NotSet + self._updated_at = GithubObject.NotSet + self._url = GithubObject.NotSet + self._user = GithubObject.NotSet def _useAttributes( self, attributes ): - if "body" in attributes and attributes[ "body" ] is not None: # pragma no branch - assert isinstance( attributes[ "body" ], ( str, unicode ) ), attributes[ "body" ] + if "body" in attributes: # pragma no branch + assert attributes[ "body" ] is None or isinstance( attributes[ "body" ], ( str, unicode ) ), attributes[ "body" ] self._body = attributes[ "body" ] - if "commit_id" in attributes and attributes[ "commit_id" ] is not None: # pragma no branch - assert isinstance( attributes[ "commit_id" ], ( str, unicode ) ), attributes[ "commit_id" ] + if "commit_id" in attributes: # pragma no branch + assert attributes[ "commit_id" ] is None or isinstance( attributes[ "commit_id" ], ( str, unicode ) ), attributes[ "commit_id" ] self._commit_id = attributes[ "commit_id" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "html_url" in attributes and attributes[ "html_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ] + 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" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "line" in attributes and attributes[ "line" ] is not None: # pragma no branch - assert isinstance( attributes[ "line" ], int ), attributes[ "line" ] + if "line" in attributes: # pragma no branch + assert attributes[ "line" ] is None or isinstance( attributes[ "line" ], int ), attributes[ "line" ] self._line = attributes[ "line" ] - if "path" in attributes and attributes[ "path" ] is not None: # pragma no branch - assert isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ] + if "path" in attributes: # pragma no branch + assert attributes[ "path" ] is None or isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ] self._path = attributes[ "path" ] - if "position" in attributes and attributes[ "position" ] is not None: # pragma no branch - assert isinstance( attributes[ "position" ], int ), attributes[ "position" ] + if "position" in attributes: # pragma no branch + assert attributes[ "position" ] is None or isinstance( attributes[ "position" ], int ), attributes[ "position" ] self._position = attributes[ "position" ] - if "updated_at" in attributes and attributes[ "updated_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ] + 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 = attributes[ "updated_at" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "url" in attributes: # pragma no branch + assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] self._url = attributes[ "url" ] - if "user" in attributes and attributes[ "user" ] is not None: # pragma no branch - assert isinstance( attributes[ "user" ], dict ), attributes[ "user" ] - self._user = NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) + if "user" in attributes: # pragma no branch + assert attributes[ "user" ] is None or isinstance( attributes[ "user" ], dict ), attributes[ "user" ] + self._user = None if attributes[ "user" ] is None else NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) diff --git a/src/github/CommitFile.py b/src/github/CommitFile.py index 59b3901d..150b08db 100644 --- a/src/github/CommitFile.py +++ b/src/github/CommitFile.py @@ -6,76 +6,76 @@ import GithubObject class CommitFile( GithubObject.BasicGithubObject ): @property def additions( self ): - return self._additions + return self._NoneIfNotSet( self._additions ) @property def blob_url( self ): - return self._blob_url + return self._NoneIfNotSet( self._blob_url ) @property def changes( self ): - return self._changes + return self._NoneIfNotSet( self._changes ) @property def deletions( self ): - return self._deletions + return self._NoneIfNotSet( self._deletions ) @property def filename( self ): - return self._filename + return self._NoneIfNotSet( self._filename ) @property def patch( self ): - return self._patch + return self._NoneIfNotSet( self._patch ) @property def raw_url( self ): - return self._raw_url + return self._NoneIfNotSet( self._raw_url ) @property def sha( self ): - return self._sha + return self._NoneIfNotSet( self._sha ) @property def status( self ): - return self._status + return self._NoneIfNotSet( self._status ) def _initAttributes( self ): - self._additions = None - self._blob_url = None - self._changes = None - self._deletions = None - self._filename = None - self._patch = None - self._raw_url = None - self._sha = None - self._status = None + self._additions = GithubObject.NotSet + self._blob_url = GithubObject.NotSet + self._changes = GithubObject.NotSet + self._deletions = GithubObject.NotSet + self._filename = GithubObject.NotSet + self._patch = GithubObject.NotSet + self._raw_url = GithubObject.NotSet + self._sha = GithubObject.NotSet + self._status = GithubObject.NotSet def _useAttributes( self, attributes ): - if "additions" in attributes and attributes[ "additions" ] is not None: # pragma no branch - assert isinstance( attributes[ "additions" ], int ), attributes[ "additions" ] + if "additions" in attributes: # pragma no branch + assert attributes[ "additions" ] is None or isinstance( attributes[ "additions" ], int ), attributes[ "additions" ] self._additions = attributes[ "additions" ] - if "blob_url" in attributes and attributes[ "blob_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "blob_url" ], ( str, unicode ) ), attributes[ "blob_url" ] + if "blob_url" in attributes: # pragma no branch + assert attributes[ "blob_url" ] is None or isinstance( attributes[ "blob_url" ], ( str, unicode ) ), attributes[ "blob_url" ] self._blob_url = attributes[ "blob_url" ] - if "changes" in attributes and attributes[ "changes" ] is not None: # pragma no branch - assert isinstance( attributes[ "changes" ], int ), attributes[ "changes" ] + if "changes" in attributes: # pragma no branch + assert attributes[ "changes" ] is None or isinstance( attributes[ "changes" ], int ), attributes[ "changes" ] self._changes = attributes[ "changes" ] - if "deletions" in attributes and attributes[ "deletions" ] is not None: # pragma no branch - assert isinstance( attributes[ "deletions" ], int ), attributes[ "deletions" ] + if "deletions" in attributes: # pragma no branch + assert attributes[ "deletions" ] is None or isinstance( attributes[ "deletions" ], int ), attributes[ "deletions" ] self._deletions = attributes[ "deletions" ] - if "filename" in attributes and attributes[ "filename" ] is not None: # pragma no branch - assert isinstance( attributes[ "filename" ], ( str, unicode ) ), attributes[ "filename" ] + if "filename" in attributes: # pragma no branch + assert attributes[ "filename" ] is None or isinstance( attributes[ "filename" ], ( str, unicode ) ), attributes[ "filename" ] self._filename = attributes[ "filename" ] - if "patch" in attributes and attributes[ "patch" ] is not None: # pragma no branch - assert isinstance( attributes[ "patch" ], ( str, unicode ) ), attributes[ "patch" ] + if "patch" in attributes: # pragma no branch + assert attributes[ "patch" ] is None or isinstance( attributes[ "patch" ], ( str, unicode ) ), attributes[ "patch" ] self._patch = attributes[ "patch" ] - if "raw_url" in attributes and attributes[ "raw_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "raw_url" ], ( str, unicode ) ), attributes[ "raw_url" ] + if "raw_url" in attributes: # pragma no branch + assert attributes[ "raw_url" ] is None or isinstance( attributes[ "raw_url" ], ( str, unicode ) ), attributes[ "raw_url" ] self._raw_url = attributes[ "raw_url" ] - if "sha" in attributes and attributes[ "sha" ] is not None: # pragma no branch - assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] + if "sha" in attributes: # pragma no branch + assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] self._sha = attributes[ "sha" ] - if "status" in attributes and attributes[ "status" ] is not None: # pragma no branch - assert isinstance( attributes[ "status" ], ( str, unicode ) ), attributes[ "status" ] + if "status" in attributes: # pragma no branch + assert attributes[ "status" ] is None or isinstance( attributes[ "status" ], ( str, unicode ) ), attributes[ "status" ] self._status = attributes[ "status" ] diff --git a/src/github/CommitStats.py b/src/github/CommitStats.py index f27e6e5a..847fca14 100644 --- a/src/github/CommitStats.py +++ b/src/github/CommitStats.py @@ -6,28 +6,28 @@ import GithubObject class CommitStats( GithubObject.BasicGithubObject ): @property def additions( self ): - return self._additions + return self._NoneIfNotSet( self._additions ) @property def deletions( self ): - return self._deletions + return self._NoneIfNotSet( self._deletions ) @property def total( self ): - return self._total + return self._NoneIfNotSet( self._total ) def _initAttributes( self ): - self._additions = None - self._deletions = None - self._total = None + self._additions = GithubObject.NotSet + self._deletions = GithubObject.NotSet + self._total = GithubObject.NotSet def _useAttributes( self, attributes ): - if "additions" in attributes and attributes[ "additions" ] is not None: # pragma no branch - assert isinstance( attributes[ "additions" ], int ), attributes[ "additions" ] + if "additions" in attributes: # pragma no branch + assert attributes[ "additions" ] is None or isinstance( attributes[ "additions" ], int ), attributes[ "additions" ] self._additions = attributes[ "additions" ] - if "deletions" in attributes and attributes[ "deletions" ] is not None: # pragma no branch - assert isinstance( attributes[ "deletions" ], int ), attributes[ "deletions" ] + if "deletions" in attributes: # pragma no branch + assert attributes[ "deletions" ] is None or isinstance( attributes[ "deletions" ], int ), attributes[ "deletions" ] self._deletions = attributes[ "deletions" ] - if "total" in attributes and attributes[ "total" ] is not None: # pragma no branch - assert isinstance( attributes[ "total" ], int ), attributes[ "total" ] + if "total" in attributes: # pragma no branch + assert attributes[ "total" ] is None or isinstance( attributes[ "total" ], int ), attributes[ "total" ] self._total = attributes[ "total" ] diff --git a/src/github/DefaultValueForOptionalParameters.py b/src/github/DefaultValueForOptionalParameters.py deleted file mode 100644 index d3552f06..00000000 --- a/src/github/DefaultValueForOptionalParameters.py +++ /dev/null @@ -1,4 +0,0 @@ -# This allows None as a valid value for an optional parameter -class DefaultValueForOptionalParametersType: - pass -DefaultValueForOptionalParameters = DefaultValueForOptionalParametersType() diff --git a/src/github/Download.py b/src/github/Download.py index 2cc37df2..4c25620e 100644 --- a/src/github/Download.py +++ b/src/github/Download.py @@ -6,103 +6,103 @@ import GithubObject class Download( GithubObject.GithubObject ): @property def accesskeyid( self ): - self._completeIfNeeded( self._accesskeyid ) - return self._accesskeyid + self._completeIfNotSet( self._accesskeyid ) + return self._NoneIfNotSet( self._accesskeyid ) @property def acl( self ): - self._completeIfNeeded( self._acl ) - return self._acl + self._completeIfNotSet( self._acl ) + return self._NoneIfNotSet( self._acl ) @property def bucket( self ): - self._completeIfNeeded( self._bucket ) - return self._bucket + self._completeIfNotSet( self._bucket ) + return self._NoneIfNotSet( self._bucket ) @property def content_type( self ): - self._completeIfNeeded( self._content_type ) - return self._content_type + self._completeIfNotSet( self._content_type ) + return self._NoneIfNotSet( self._content_type ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def description( self ): - self._completeIfNeeded( self._description ) - return self._description + self._completeIfNotSet( self._description ) + return self._NoneIfNotSet( self._description ) @property def download_count( self ): - self._completeIfNeeded( self._download_count ) - return self._download_count + self._completeIfNotSet( self._download_count ) + return self._NoneIfNotSet( self._download_count ) @property def expirationdate( self ): - self._completeIfNeeded( self._expirationdate ) - return self._expirationdate + self._completeIfNotSet( self._expirationdate ) + return self._NoneIfNotSet( self._expirationdate ) @property def html_url( self ): - self._completeIfNeeded( self._html_url ) - return self._html_url + self._completeIfNotSet( self._html_url ) + return self._NoneIfNotSet( self._html_url ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def mime_type( self ): - self._completeIfNeeded( self._mime_type ) - return self._mime_type + self._completeIfNotSet( self._mime_type ) + return self._NoneIfNotSet( self._mime_type ) @property def name( self ): - self._completeIfNeeded( self._name ) - return self._name + self._completeIfNotSet( self._name ) + return self._NoneIfNotSet( self._name ) @property def path( self ): - self._completeIfNeeded( self._path ) - return self._path + self._completeIfNotSet( self._path ) + return self._NoneIfNotSet( self._path ) @property def policy( self ): - self._completeIfNeeded( self._policy ) - return self._policy + self._completeIfNotSet( self._policy ) + return self._NoneIfNotSet( self._policy ) @property def prefix( self ): - self._completeIfNeeded( self._prefix ) - return self._prefix + self._completeIfNotSet( self._prefix ) + return self._NoneIfNotSet( self._prefix ) @property def redirect( self ): - self._completeIfNeeded( self._redirect ) - return self._redirect + self._completeIfNotSet( self._redirect ) + return self._NoneIfNotSet( self._redirect ) @property def s3_url( self ): - self._completeIfNeeded( self._s3_url ) - return self._s3_url + self._completeIfNotSet( self._s3_url ) + return self._NoneIfNotSet( self._s3_url ) @property def signature( self ): - self._completeIfNeeded( self._signature ) - return self._signature + self._completeIfNotSet( self._signature ) + return self._NoneIfNotSet( self._signature ) @property def size( self ): - self._completeIfNeeded( self._size ) - return self._size + self._completeIfNotSet( self._size ) + return self._NoneIfNotSet( self._size ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def delete( self ): status, headers, data = self._request( @@ -114,85 +114,85 @@ class Download( GithubObject.GithubObject ): self._checkStatus( status, data ) def _initAttributes( self ): - self._accesskeyid = None - self._acl = None - self._bucket = None - self._content_type = None - self._created_at = None - self._description = None - self._download_count = None - self._expirationdate = None - self._html_url = None - self._id = None - self._mime_type = None - self._name = None - self._path = None - self._policy = None - self._prefix = None - self._redirect = None - self._s3_url = None - self._signature = None - self._size = None - self._url = None + self._accesskeyid = GithubObject.NotSet + self._acl = GithubObject.NotSet + self._bucket = GithubObject.NotSet + self._content_type = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._description = GithubObject.NotSet + self._download_count = GithubObject.NotSet + self._expirationdate = GithubObject.NotSet + self._html_url = GithubObject.NotSet + self._id = GithubObject.NotSet + self._mime_type = GithubObject.NotSet + self._name = GithubObject.NotSet + self._path = GithubObject.NotSet + self._policy = GithubObject.NotSet + self._prefix = GithubObject.NotSet + self._redirect = GithubObject.NotSet + self._s3_url = GithubObject.NotSet + self._signature = GithubObject.NotSet + self._size = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "accesskeyid" in attributes and attributes[ "accesskeyid" ] is not None: # pragma no branch - assert isinstance( attributes[ "accesskeyid" ], ( str, unicode ) ), attributes[ "accesskeyid" ] + if "accesskeyid" in attributes: # pragma no branch + assert attributes[ "accesskeyid" ] is None or isinstance( attributes[ "accesskeyid" ], ( str, unicode ) ), attributes[ "accesskeyid" ] self._accesskeyid = attributes[ "accesskeyid" ] - if "acl" in attributes and attributes[ "acl" ] is not None: # pragma no branch - assert isinstance( attributes[ "acl" ], ( str, unicode ) ), attributes[ "acl" ] + if "acl" in attributes: # pragma no branch + assert attributes[ "acl" ] is None or isinstance( attributes[ "acl" ], ( str, unicode ) ), attributes[ "acl" ] self._acl = attributes[ "acl" ] - if "bucket" in attributes and attributes[ "bucket" ] is not None: # pragma no branch - assert isinstance( attributes[ "bucket" ], ( str, unicode ) ), attributes[ "bucket" ] + if "bucket" in attributes: # pragma no branch + assert attributes[ "bucket" ] is None or isinstance( attributes[ "bucket" ], ( str, unicode ) ), attributes[ "bucket" ] self._bucket = attributes[ "bucket" ] - if "content_type" in attributes and attributes[ "content_type" ] is not None: # pragma no branch - assert isinstance( attributes[ "content_type" ], ( str, unicode ) ), attributes[ "content_type" ] + if "content_type" in attributes: # pragma no branch + assert attributes[ "content_type" ] is None or isinstance( attributes[ "content_type" ], ( str, unicode ) ), attributes[ "content_type" ] self._content_type = attributes[ "content_type" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "description" in attributes and attributes[ "description" ] is not None: # pragma no branch - assert isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ] + if "description" in attributes: # pragma no branch + assert attributes[ "description" ] is None or isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ] self._description = attributes[ "description" ] - if "download_count" in attributes and attributes[ "download_count" ] is not None: # pragma no branch - assert isinstance( attributes[ "download_count" ], int ), attributes[ "download_count" ] + if "download_count" in attributes: # pragma no branch + assert attributes[ "download_count" ] is None or isinstance( attributes[ "download_count" ], int ), attributes[ "download_count" ] self._download_count = attributes[ "download_count" ] - if "expirationdate" in attributes and attributes[ "expirationdate" ] is not None: # pragma no branch - assert isinstance( attributes[ "expirationdate" ], ( str, unicode ) ), attributes[ "expirationdate" ] + if "expirationdate" in attributes: # pragma no branch + assert attributes[ "expirationdate" ] is None or isinstance( attributes[ "expirationdate" ], ( str, unicode ) ), attributes[ "expirationdate" ] self._expirationdate = attributes[ "expirationdate" ] - if "html_url" in attributes and attributes[ "html_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ] + 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" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "mime_type" in attributes and attributes[ "mime_type" ] is not None: # pragma no branch - assert isinstance( attributes[ "mime_type" ], ( str, unicode ) ), attributes[ "mime_type" ] + if "mime_type" in attributes: # pragma no branch + assert attributes[ "mime_type" ] is None or isinstance( attributes[ "mime_type" ], ( str, unicode ) ), attributes[ "mime_type" ] self._mime_type = attributes[ "mime_type" ] - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] - if "path" in attributes and attributes[ "path" ] is not None: # pragma no branch - assert isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ] + if "path" in attributes: # pragma no branch + assert attributes[ "path" ] is None or isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ] self._path = attributes[ "path" ] - if "policy" in attributes and attributes[ "policy" ] is not None: # pragma no branch - assert isinstance( attributes[ "policy" ], ( str, unicode ) ), attributes[ "policy" ] + if "policy" in attributes: # pragma no branch + assert attributes[ "policy" ] is None or isinstance( attributes[ "policy" ], ( str, unicode ) ), attributes[ "policy" ] self._policy = attributes[ "policy" ] - if "prefix" in attributes and attributes[ "prefix" ] is not None: # pragma no branch - assert isinstance( attributes[ "prefix" ], ( str, unicode ) ), attributes[ "prefix" ] + if "prefix" in attributes: # pragma no branch + assert attributes[ "prefix" ] is None or isinstance( attributes[ "prefix" ], ( str, unicode ) ), attributes[ "prefix" ] self._prefix = attributes[ "prefix" ] - if "redirect" in attributes and attributes[ "redirect" ] is not None: # pragma no branch - assert isinstance( attributes[ "redirect" ], bool ), attributes[ "redirect" ] + if "redirect" in attributes: # pragma no branch + assert attributes[ "redirect" ] is None or isinstance( attributes[ "redirect" ], bool ), attributes[ "redirect" ] self._redirect = attributes[ "redirect" ] - if "s3_url" in attributes and attributes[ "s3_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "s3_url" ], ( str, unicode ) ), attributes[ "s3_url" ] + if "s3_url" in attributes: # pragma no branch + assert attributes[ "s3_url" ] is None or isinstance( attributes[ "s3_url" ], ( str, unicode ) ), attributes[ "s3_url" ] self._s3_url = attributes[ "s3_url" ] - if "signature" in attributes and attributes[ "signature" ] is not None: # pragma no branch - assert isinstance( attributes[ "signature" ], ( str, unicode ) ), attributes[ "signature" ] + if "signature" in attributes: # pragma no branch + assert attributes[ "signature" ] is None or isinstance( attributes[ "signature" ], ( str, unicode ) ), attributes[ "signature" ] self._signature = attributes[ "signature" ] - if "size" in attributes and attributes[ "size" ] is not None: # pragma no branch - assert isinstance( attributes[ "size" ], int ), attributes[ "size" ] + if "size" in attributes: # pragma no branch + assert attributes[ "size" ] is None or isinstance( attributes[ "size" ], int ), attributes[ "size" ] self._size = attributes[ "size" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/Event.py b/src/github/Event.py index 64a3f02c..a2d908fd 100644 --- a/src/github/Event.py +++ b/src/github/Event.py @@ -10,67 +10,67 @@ import NamedUser class Event( GithubObject.BasicGithubObject ): @property def actor( self ): - return self._actor + return self._NoneIfNotSet( self._actor ) @property def created_at( self ): - return self._created_at + return self._NoneIfNotSet( self._created_at ) @property def id( self ): - return self._id + return self._NoneIfNotSet( self._id ) @property def org( self ): - return self._org + return self._NoneIfNotSet( self._org ) @property def payload( self ): - return self._payload + return self._NoneIfNotSet( self._payload ) @property def public( self ): - return self._public + return self._NoneIfNotSet( self._public ) @property def repo( self ): - return self._repo + return self._NoneIfNotSet( self._repo ) @property def type( self ): - return self._type + return self._NoneIfNotSet( self._type ) def _initAttributes( self ): - self._actor = None - self._created_at = None - self._id = None - self._org = None - self._payload = None - self._public = None - self._repo = None - self._type = None + self._actor = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._id = GithubObject.NotSet + self._org = GithubObject.NotSet + self._payload = GithubObject.NotSet + self._public = GithubObject.NotSet + self._repo = GithubObject.NotSet + self._type = GithubObject.NotSet def _useAttributes( self, attributes ): - if "actor" in attributes and attributes[ "actor" ] is not None: # pragma no branch - assert isinstance( attributes[ "actor" ], dict ), attributes[ "actor" ] - self._actor = NamedUser.NamedUser( self._requester, attributes[ "actor" ], completed = False ) - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + if "actor" in attributes: # pragma no branch + assert attributes[ "actor" ] is None or isinstance( attributes[ "actor" ], dict ), attributes[ "actor" ] + 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 = attributes[ "created_at" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], ( str, unicode ) ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], ( str, unicode ) ), attributes[ "id" ] self._id = attributes[ "id" ] - if "org" in attributes and attributes[ "org" ] is not None: # pragma no branch - assert isinstance( attributes[ "org" ], dict ), attributes[ "org" ] - self._org = Organization.Organization( self._requester, attributes[ "org" ], completed = False ) - if "payload" in attributes and attributes[ "payload" ] is not None: # pragma no branch + if "org" in attributes: # pragma no branch + assert attributes[ "org" ] is None or isinstance( attributes[ "org" ], dict ), attributes[ "org" ] + self._org = None if attributes[ "org" ] is None else Organization.Organization( self._requester, attributes[ "org" ], completed = False ) + if "payload" in attributes: # pragma no branch self._payload = attributes[ "payload" ] - if "public" in attributes and attributes[ "public" ] is not None: # pragma no branch - assert isinstance( attributes[ "public" ], bool ), attributes[ "public" ] + if "public" in attributes: # pragma no branch + assert attributes[ "public" ] is None or isinstance( attributes[ "public" ], bool ), attributes[ "public" ] self._public = attributes[ "public" ] - if "repo" in attributes and attributes[ "repo" ] is not None: # pragma no branch - assert isinstance( attributes[ "repo" ], dict ), attributes[ "repo" ] - self._repo = Repository.Repository( self._requester, attributes[ "repo" ], completed = False ) - if "type" in attributes and attributes[ "type" ] is not None: # pragma no branch - assert isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ] + if "repo" in attributes: # pragma no branch + assert attributes[ "repo" ] is None or isinstance( attributes[ "repo" ], dict ), attributes[ "repo" ] + self._repo = None if attributes[ "repo" ] is None else Repository.Repository( self._requester, attributes[ "repo" ], completed = False ) + if "type" in attributes: # pragma no branch + assert attributes[ "type" ] is None or isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ] self._type = attributes[ "type" ] diff --git a/src/github/Gist.py b/src/github/Gist.py index f11eaab7..07fe4e9f 100644 --- a/src/github/Gist.py +++ b/src/github/Gist.py @@ -3,7 +3,6 @@ import GithubObject import PaginatedList -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import GistHistoryState import NamedUser @@ -13,78 +12,78 @@ import GistComment class Gist( GithubObject.GithubObject ): @property def comments( self ): - self._completeIfNeeded( self._comments ) - return self._comments + self._completeIfNotSet( self._comments ) + return self._NoneIfNotSet( self._comments ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def description( self ): - self._completeIfNeeded( self._description ) - return self._description + self._completeIfNotSet( self._description ) + return self._NoneIfNotSet( self._description ) @property def files( self ): - self._completeIfNeeded( self._files ) - return self._files + self._completeIfNotSet( self._files ) + return self._NoneIfNotSet( self._files ) @property def fork_of( self ): - self._completeIfNeeded( self._fork_of ) - return self._fork_of + self._completeIfNotSet( self._fork_of ) + return self._NoneIfNotSet( self._fork_of ) @property def forks( self ): - self._completeIfNeeded( self._forks ) - return self._forks + self._completeIfNotSet( self._forks ) + return self._NoneIfNotSet( self._forks ) @property def git_pull_url( self ): - self._completeIfNeeded( self._git_pull_url ) - return self._git_pull_url + self._completeIfNotSet( self._git_pull_url ) + return self._NoneIfNotSet( self._git_pull_url ) @property def git_push_url( self ): - self._completeIfNeeded( self._git_push_url ) - return self._git_push_url + self._completeIfNotSet( self._git_push_url ) + return self._NoneIfNotSet( self._git_push_url ) @property def history( self ): - self._completeIfNeeded( self._history ) - return self._history + self._completeIfNotSet( self._history ) + return self._NoneIfNotSet( self._history ) @property def html_url( self ): - self._completeIfNeeded( self._html_url ) - return self._html_url + self._completeIfNotSet( self._html_url ) + return self._NoneIfNotSet( self._html_url ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def public( self ): - self._completeIfNeeded( self._public ) - return self._public + self._completeIfNotSet( self._public ) + return self._NoneIfNotSet( self._public ) @property def updated_at( self ): - self._completeIfNeeded( self._updated_at ) - return self._updated_at + self._completeIfNotSet( self._updated_at ) + return self._NoneIfNotSet( self._updated_at ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) @property def user( self ): - self._completeIfNeeded( self._user ) - return self._user + self._completeIfNotSet( self._user ) + return self._NoneIfNotSet( self._user ) def create_comment( self, body ): assert isinstance( body, ( str, unicode ) ), body @@ -119,13 +118,13 @@ class Gist( GithubObject.GithubObject ): ) self._checkStatus( status, data ) - def edit( self, description = DefaultValueForOptionalParameters, files = DefaultValueForOptionalParameters ): - if description is not DefaultValueForOptionalParameters: + def edit( self, description = GithubObject.NotSet, files = GithubObject.NotSet ): + if description is not GithubObject.NotSet: assert isinstance( description, ( str, unicode ) ), description post_parameters = dict() - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: post_parameters[ "description" ] = description - if files is not DefaultValueForOptionalParameters: + if files is not GithubObject.NotSet: post_parameters[ "files" ] = files status, headers, data = self._request( "PATCH", @@ -190,70 +189,70 @@ class Gist( GithubObject.GithubObject ): self._checkStatus( status, data ) def _initAttributes( self ): - self._comments = None - self._created_at = None - self._description = None - self._files = None - self._fork_of = None - self._forks = None - self._git_pull_url = None - self._git_push_url = None - self._history = None - self._html_url = None - self._id = None - self._public = None - self._updated_at = None - self._url = None - self._user = None + self._comments = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._description = GithubObject.NotSet + self._files = GithubObject.NotSet + self._fork_of = GithubObject.NotSet + self._forks = GithubObject.NotSet + self._git_pull_url = GithubObject.NotSet + self._git_push_url = GithubObject.NotSet + self._history = GithubObject.NotSet + self._html_url = GithubObject.NotSet + self._id = GithubObject.NotSet + self._public = GithubObject.NotSet + self._updated_at = GithubObject.NotSet + self._url = GithubObject.NotSet + self._user = GithubObject.NotSet def _useAttributes( self, attributes ): - if "comments" in attributes and attributes[ "comments" ] is not None: # pragma no branch - assert isinstance( attributes[ "comments" ], int ), attributes[ "comments" ] + if "comments" in attributes: # pragma no branch + assert attributes[ "comments" ] is None or isinstance( attributes[ "comments" ], int ), attributes[ "comments" ] self._comments = attributes[ "comments" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "description" in attributes and attributes[ "description" ] is not None: # pragma no branch - assert isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ] + if "description" in attributes: # pragma no branch + assert attributes[ "description" ] is None or isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ] self._description = attributes[ "description" ] - if "files" in attributes and attributes[ "files" ] is not None: # pragma no branch + if "files" in attributes: # pragma no branch self._files = attributes[ "files" ] - if "fork_of" in attributes and attributes[ "fork_of" ] is not None: # pragma no branch - assert isinstance( attributes[ "fork_of" ], dict ), attributes[ "fork_of" ] - self._fork_of = Gist( self._requester, attributes[ "fork_of" ], completed = False ) - if "forks" in attributes and attributes[ "forks" ] is not None: # pragma no branch + if "fork_of" in attributes: # pragma no branch + 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 = [ Gist( self._requester, element, completed = False ) for element in attributes[ "forks" ] ] - if "git_pull_url" in attributes and attributes[ "git_pull_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "git_pull_url" ], ( str, unicode ) ), attributes[ "git_pull_url" ] + if "git_pull_url" in attributes: # pragma no branch + assert attributes[ "git_pull_url" ] is None or isinstance( attributes[ "git_pull_url" ], ( str, unicode ) ), attributes[ "git_pull_url" ] self._git_pull_url = attributes[ "git_pull_url" ] - if "git_push_url" in attributes and attributes[ "git_push_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "git_push_url" ], ( str, unicode ) ), attributes[ "git_push_url" ] + if "git_push_url" in attributes: # pragma no branch + 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 and attributes[ "history" ] is not None: # pragma no branch + if "history" in attributes: # pragma no branch assert all( isinstance( element, dict ) for element in attributes[ "history" ] ), attributes[ "history" ] self._history = [ GistHistoryState.GistHistoryState( self._requester, element, completed = False ) for element in attributes[ "history" ] ] - if "html_url" in attributes and attributes[ "html_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ] + 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" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], ( str, unicode ) ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], ( str, unicode ) ), attributes[ "id" ] self._id = attributes[ "id" ] - if "public" in attributes and attributes[ "public" ] is not None: # pragma no branch - assert isinstance( attributes[ "public" ], bool ), attributes[ "public" ] + if "public" in attributes: # pragma no branch + assert attributes[ "public" ] is None or isinstance( attributes[ "public" ], bool ), attributes[ "public" ] self._public = attributes[ "public" ] - if "updated_at" in attributes and attributes[ "updated_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ] + 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 = attributes[ "updated_at" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "url" in attributes: # pragma no branch + assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] self._url = attributes[ "url" ] - if "user" in attributes and attributes[ "user" ] is not None: # pragma no branch - assert isinstance( attributes[ "user" ], dict ), attributes[ "user" ] - self._user = NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) + if "user" in attributes: # pragma no branch + assert attributes[ "user" ] is None or isinstance( attributes[ "user" ], dict ), attributes[ "user" ] + self._user = None if attributes[ "user" ] is None else NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) diff --git a/src/github/GistComment.py b/src/github/GistComment.py index 411481c5..a44aea23 100644 --- a/src/github/GistComment.py +++ b/src/github/GistComment.py @@ -8,33 +8,33 @@ import NamedUser class GistComment( GithubObject.GithubObject ): @property def body( self ): - self._completeIfNeeded( self._body ) - return self._body + self._completeIfNotSet( self._body ) + return self._NoneIfNotSet( self._body ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def updated_at( self ): - self._completeIfNeeded( self._updated_at ) - return self._updated_at + self._completeIfNotSet( self._updated_at ) + return self._NoneIfNotSet( self._updated_at ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) @property def user( self ): - self._completeIfNeeded( self._user ) - return self._user + self._completeIfNotSet( self._user ) + return self._NoneIfNotSet( self._user ) def delete( self ): status, headers, data = self._request( @@ -60,29 +60,29 @@ class GistComment( GithubObject.GithubObject ): self._useAttributes( data ) def _initAttributes( self ): - self._body = None - self._created_at = None - self._id = None - self._updated_at = None - self._url = None - self._user = None + self._body = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._id = GithubObject.NotSet + self._updated_at = GithubObject.NotSet + self._url = GithubObject.NotSet + self._user = GithubObject.NotSet def _useAttributes( self, attributes ): - if "body" in attributes and attributes[ "body" ] is not None: # pragma no branch - assert isinstance( attributes[ "body" ], ( str, unicode ) ), attributes[ "body" ] + if "body" in attributes: # pragma no branch + assert attributes[ "body" ] is None or isinstance( attributes[ "body" ], ( str, unicode ) ), attributes[ "body" ] self._body = attributes[ "body" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + 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 and attributes[ "updated_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ] + 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 = attributes[ "updated_at" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "url" in attributes: # pragma no branch + assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] self._url = attributes[ "url" ] - if "user" in attributes and attributes[ "user" ] is not None: # pragma no branch - assert isinstance( attributes[ "user" ], dict ), attributes[ "user" ] - self._user = NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) + if "user" in attributes: # pragma no branch + assert attributes[ "user" ] is None or isinstance( attributes[ "user" ], dict ), attributes[ "user" ] + self._user = None if attributes[ "user" ] is None else NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) diff --git a/src/github/GistHistoryState.py b/src/github/GistHistoryState.py index 30d2660b..95b8a9fb 100644 --- a/src/github/GistHistoryState.py +++ b/src/github/GistHistoryState.py @@ -9,49 +9,49 @@ import CommitStats class GistHistoryState( GithubObject.GithubObject ): @property def change_status( self ): - self._completeIfNeeded( self._change_status ) - return self._change_status + self._completeIfNotSet( self._change_status ) + return self._NoneIfNotSet( self._change_status ) @property def committed_at( self ): - self._completeIfNeeded( self._committed_at ) - return self._committed_at + self._completeIfNotSet( self._committed_at ) + return self._NoneIfNotSet( self._committed_at ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) @property def user( self ): - self._completeIfNeeded( self._user ) - return self._user + self._completeIfNotSet( self._user ) + return self._NoneIfNotSet( self._user ) @property def version( self ): - self._completeIfNeeded( self._version ) - return self._version + self._completeIfNotSet( self._version ) + return self._NoneIfNotSet( self._version ) def _initAttributes( self ): - self._change_status = None - self._committed_at = None - self._url = None - self._user = None - self._version = None + self._change_status = GithubObject.NotSet + self._committed_at = GithubObject.NotSet + self._url = GithubObject.NotSet + self._user = GithubObject.NotSet + self._version = GithubObject.NotSet def _useAttributes( self, attributes ): - if "change_status" in attributes and attributes[ "change_status" ] is not None: # pragma no branch - assert isinstance( attributes[ "change_status" ], dict ), attributes[ "change_status" ] - self._change_status = CommitStats.CommitStats( self._requester, attributes[ "change_status" ], completed = False ) - if "committed_at" in attributes and attributes[ "committed_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "committed_at" ], ( str, unicode ) ), attributes[ "committed_at" ] + if "change_status" in attributes: # pragma no branch + assert attributes[ "change_status" ] is None or isinstance( attributes[ "change_status" ], dict ), attributes[ "change_status" ] + 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 = attributes[ "committed_at" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "url" in attributes: # pragma no branch + assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] self._url = attributes[ "url" ] - if "user" in attributes and attributes[ "user" ] is not None: # pragma no branch - assert isinstance( attributes[ "user" ], dict ), attributes[ "user" ] - self._user = NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) - if "version" in attributes and attributes[ "version" ] is not None: # pragma no branch - assert isinstance( attributes[ "version" ], ( str, unicode ) ), attributes[ "version" ] + if "user" in attributes: # pragma no branch + assert attributes[ "user" ] is None or isinstance( attributes[ "user" ], dict ), attributes[ "user" ] + self._user = None if attributes[ "user" ] is None else NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) + if "version" in attributes: # pragma no branch + assert attributes[ "version" ] is None or isinstance( attributes[ "version" ], ( str, unicode ) ), attributes[ "version" ] self._version = attributes[ "version" ] diff --git a/src/github/GitAuthor.py b/src/github/GitAuthor.py index 36c71542..74e94903 100644 --- a/src/github/GitAuthor.py +++ b/src/github/GitAuthor.py @@ -6,28 +6,28 @@ import GithubObject class GitAuthor( GithubObject.BasicGithubObject ): @property def date( self ): - return self._date + return self._NoneIfNotSet( self._date ) @property def email( self ): - return self._email + return self._NoneIfNotSet( self._email ) @property def name( self ): - return self._name + return self._NoneIfNotSet( self._name ) def _initAttributes( self ): - self._date = None - self._email = None - self._name = None + self._date = GithubObject.NotSet + self._email = GithubObject.NotSet + self._name = GithubObject.NotSet def _useAttributes( self, attributes ): - if "date" in attributes and attributes[ "date" ] is not None: # pragma no branch - assert isinstance( attributes[ "date" ], ( str, unicode ) ), attributes[ "date" ] + if "date" in attributes: # pragma no branch + assert attributes[ "date" ] is None or isinstance( attributes[ "date" ], ( str, unicode ) ), attributes[ "date" ] self._date = attributes[ "date" ] - if "email" in attributes and attributes[ "email" ] is not None: # pragma no branch - assert isinstance( attributes[ "email" ], ( str, unicode ) ), attributes[ "email" ] + if "email" in attributes: # pragma no branch + assert attributes[ "email" ] is None or isinstance( attributes[ "email" ], ( str, unicode ) ), attributes[ "email" ] self._email = attributes[ "email" ] - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] diff --git a/src/github/GitBlob.py b/src/github/GitBlob.py index e451326d..c463b2e6 100644 --- a/src/github/GitBlob.py +++ b/src/github/GitBlob.py @@ -6,49 +6,49 @@ import GithubObject class GitBlob( GithubObject.GithubObject ): @property def content( self ): - self._completeIfNeeded( self._content ) - return self._content + self._completeIfNotSet( self._content ) + return self._NoneIfNotSet( self._content ) @property def encoding( self ): - self._completeIfNeeded( self._encoding ) - return self._encoding + self._completeIfNotSet( self._encoding ) + return self._NoneIfNotSet( self._encoding ) @property def sha( self ): - self._completeIfNeeded( self._sha ) - return self._sha + self._completeIfNotSet( self._sha ) + return self._NoneIfNotSet( self._sha ) @property def size( self ): - self._completeIfNeeded( self._size ) - return self._size + self._completeIfNotSet( self._size ) + return self._NoneIfNotSet( self._size ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def _initAttributes( self ): - self._content = None - self._encoding = None - self._sha = None - self._size = None - self._url = None + self._content = GithubObject.NotSet + self._encoding = GithubObject.NotSet + self._sha = GithubObject.NotSet + self._size = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "content" in attributes and attributes[ "content" ] is not None: # pragma no branch - assert isinstance( attributes[ "content" ], ( str, unicode ) ), attributes[ "content" ] + if "content" in attributes: # pragma no branch + assert attributes[ "content" ] is None or isinstance( attributes[ "content" ], ( str, unicode ) ), attributes[ "content" ] self._content = attributes[ "content" ] - if "encoding" in attributes and attributes[ "encoding" ] is not None: # pragma no branch - assert isinstance( attributes[ "encoding" ], ( str, unicode ) ), attributes[ "encoding" ] + if "encoding" in attributes: # pragma no branch + assert attributes[ "encoding" ] is None or isinstance( attributes[ "encoding" ], ( str, unicode ) ), attributes[ "encoding" ] self._encoding = attributes[ "encoding" ] - if "sha" in attributes and attributes[ "sha" ] is not None: # pragma no branch - assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] + if "sha" in attributes: # pragma no branch + assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] self._sha = attributes[ "sha" ] - if "size" in attributes and attributes[ "size" ] is not None: # pragma no branch - assert isinstance( attributes[ "size" ], int ), attributes[ "size" ] + if "size" in attributes: # pragma no branch + assert attributes[ "size" ] is None or isinstance( attributes[ "size" ], int ), attributes[ "size" ] self._size = attributes[ "size" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/GitCommit.py b/src/github/GitCommit.py index 6cd65f0d..5470d22a 100644 --- a/src/github/GitCommit.py +++ b/src/github/GitCommit.py @@ -10,70 +10,70 @@ import GitTree class GitCommit( GithubObject.GithubObject ): @property def author( self ): - self._completeIfNeeded( self._author ) - return self._author + self._completeIfNotSet( self._author ) + return self._NoneIfNotSet( self._author ) @property def committer( self ): - self._completeIfNeeded( self._committer ) - return self._committer + self._completeIfNotSet( self._committer ) + return self._NoneIfNotSet( self._committer ) @property def message( self ): - self._completeIfNeeded( self._message ) - return self._message + self._completeIfNotSet( self._message ) + return self._NoneIfNotSet( self._message ) @property def parents( self ): - self._completeIfNeeded( self._parents ) - return self._parents + self._completeIfNotSet( self._parents ) + return self._NoneIfNotSet( self._parents ) @property def sha( self ): - self._completeIfNeeded( self._sha ) - return self._sha + self._completeIfNotSet( self._sha ) + return self._NoneIfNotSet( self._sha ) @property def tree( self ): - self._completeIfNeeded( self._tree ) - return self._tree + self._completeIfNotSet( self._tree ) + return self._NoneIfNotSet( self._tree ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def _initAttributes( self ): - self._author = None - self._committer = None - self._message = None - self._parents = None - self._sha = None - self._tree = None - self._url = None + self._author = GithubObject.NotSet + self._committer = GithubObject.NotSet + self._message = GithubObject.NotSet + self._parents = GithubObject.NotSet + self._sha = GithubObject.NotSet + self._tree = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "author" in attributes and attributes[ "author" ] is not None: # pragma no branch - assert isinstance( attributes[ "author" ], dict ), attributes[ "author" ] - self._author = GitAuthor.GitAuthor( self._requester, attributes[ "author" ], completed = False ) - if "committer" in attributes and attributes[ "committer" ] is not None: # pragma no branch - assert isinstance( attributes[ "committer" ], dict ), attributes[ "committer" ] - self._committer = GitAuthor.GitAuthor( self._requester, attributes[ "committer" ], completed = False ) - if "message" in attributes and attributes[ "message" ] is not None: # pragma no branch - assert isinstance( attributes[ "message" ], ( str, unicode ) ), attributes[ "message" ] + if "author" in attributes: # pragma no branch + assert attributes[ "author" ] is None or isinstance( attributes[ "author" ], dict ), attributes[ "author" ] + self._author = None if attributes[ "author" ] is None else GitAuthor.GitAuthor( self._requester, attributes[ "author" ], completed = False ) + if "committer" in attributes: # pragma no branch + assert attributes[ "committer" ] is None or isinstance( attributes[ "committer" ], dict ), attributes[ "committer" ] + self._committer = None if attributes[ "committer" ] is None else GitAuthor.GitAuthor( self._requester, attributes[ "committer" ], completed = False ) + if "message" in attributes: # pragma no branch + assert attributes[ "message" ] is None or isinstance( attributes[ "message" ], ( str, unicode ) ), attributes[ "message" ] self._message = attributes[ "message" ] - if "parents" in attributes and attributes[ "parents" ] is not None: # pragma no branch + if "parents" in attributes: # pragma no branch assert all( isinstance( element, dict ) for element in attributes[ "parents" ] ), attributes[ "parents" ] self._parents = [ GitCommit( self._requester, element, completed = False ) for element in attributes[ "parents" ] ] - if "sha" in attributes and attributes[ "sha" ] is not None: # pragma no branch - assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] + if "sha" in attributes: # pragma no branch + assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] self._sha = attributes[ "sha" ] - if "tree" in attributes and attributes[ "tree" ] is not None: # pragma no branch - assert isinstance( attributes[ "tree" ], dict ), attributes[ "tree" ] - self._tree = GitTree.GitTree( self._requester, attributes[ "tree" ], completed = False ) - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "tree" in attributes: # pragma no branch + assert attributes[ "tree" ] is None or isinstance( attributes[ "tree" ], dict ), attributes[ "tree" ] + self._tree = None if attributes[ "tree" ] is None else GitTree.GitTree( self._requester, attributes[ "tree" ], completed = False ) + 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/src/github/GitObject.py b/src/github/GitObject.py index b30aa05e..a1d31cd2 100644 --- a/src/github/GitObject.py +++ b/src/github/GitObject.py @@ -6,28 +6,28 @@ import GithubObject class GitObject( GithubObject.BasicGithubObject ): @property def sha( self ): - return self._sha + return self._NoneIfNotSet( self._sha ) @property def type( self ): - return self._type + return self._NoneIfNotSet( self._type ) @property def url( self ): - return self._url + return self._NoneIfNotSet( self._url ) def _initAttributes( self ): - self._sha = None - self._type = None - self._url = None + self._sha = GithubObject.NotSet + self._type = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "sha" in attributes and attributes[ "sha" ] is not None: # pragma no branch - assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] + if "sha" in attributes: # pragma no branch + assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] self._sha = attributes[ "sha" ] - if "type" in attributes and attributes[ "type" ] is not None: # pragma no branch - assert isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ] + if "type" in attributes: # pragma no branch + assert attributes[ "type" ] is None or isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ] self._type = attributes[ "type" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/GitRef.py b/src/github/GitRef.py index e6e329ff..f12d6dab 100644 --- a/src/github/GitRef.py +++ b/src/github/GitRef.py @@ -2,25 +2,24 @@ # Do not modify it manually, your work would be lost. import GithubObject -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import GitObject class GitRef( GithubObject.GithubObject ): @property def object( self ): - self._completeIfNeeded( self._object ) - return self._object + self._completeIfNotSet( self._object ) + return self._NoneIfNotSet( self._object ) @property def ref( self ): - self._completeIfNeeded( self._ref ) - return self._ref + self._completeIfNotSet( self._ref ) + return self._NoneIfNotSet( self._ref ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def delete( self ): status, headers, data = self._request( @@ -31,14 +30,14 @@ class GitRef( GithubObject.GithubObject ): ) self._checkStatus( status, data ) - def edit( self, sha, force = DefaultValueForOptionalParameters ): + def edit( self, sha, force = GithubObject.NotSet ): assert isinstance( sha, ( str, unicode ) ), sha - if force is not DefaultValueForOptionalParameters: + if force is not GithubObject.NotSet: assert isinstance( force, bool ), force post_parameters = { "sha": sha, } - if force is not DefaultValueForOptionalParameters: + if force is not GithubObject.NotSet: post_parameters[ "force" ] = force status, headers, data = self._request( "PATCH", @@ -50,17 +49,17 @@ class GitRef( GithubObject.GithubObject ): self._useAttributes( data ) def _initAttributes( self ): - self._object = None - self._ref = None - self._url = None + self._object = GithubObject.NotSet + self._ref = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "object" in attributes and attributes[ "object" ] is not None: # pragma no branch - assert isinstance( attributes[ "object" ], dict ), attributes[ "object" ] - self._object = GitObject.GitObject( self._requester, attributes[ "object" ], completed = False ) - if "ref" in attributes and attributes[ "ref" ] is not None: # pragma no branch - assert isinstance( attributes[ "ref" ], ( str, unicode ) ), attributes[ "ref" ] + if "object" in attributes: # pragma no branch + assert attributes[ "object" ] is None or isinstance( attributes[ "object" ], dict ), attributes[ "object" ] + self._object = None if attributes[ "object" ] is None else GitObject.GitObject( self._requester, attributes[ "object" ], completed = False ) + if "ref" in attributes: # pragma no branch + assert attributes[ "ref" ] is None or isinstance( attributes[ "ref" ], ( str, unicode ) ), attributes[ "ref" ] self._ref = attributes[ "ref" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/GitTag.py b/src/github/GitTag.py index 5abd4fb7..b4756999 100644 --- a/src/github/GitTag.py +++ b/src/github/GitTag.py @@ -9,58 +9,58 @@ import GitObject class GitTag( GithubObject.GithubObject ): @property def message( self ): - self._completeIfNeeded( self._message ) - return self._message + self._completeIfNotSet( self._message ) + return self._NoneIfNotSet( self._message ) @property def object( self ): - self._completeIfNeeded( self._object ) - return self._object + self._completeIfNotSet( self._object ) + return self._NoneIfNotSet( self._object ) @property def sha( self ): - self._completeIfNeeded( self._sha ) - return self._sha + self._completeIfNotSet( self._sha ) + return self._NoneIfNotSet( self._sha ) @property def tag( self ): - self._completeIfNeeded( self._tag ) - return self._tag + self._completeIfNotSet( self._tag ) + return self._NoneIfNotSet( self._tag ) @property def tagger( self ): - self._completeIfNeeded( self._tagger ) - return self._tagger + self._completeIfNotSet( self._tagger ) + return self._NoneIfNotSet( self._tagger ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def _initAttributes( self ): - self._message = None - self._object = None - self._sha = None - self._tag = None - self._tagger = None - self._url = None + self._message = GithubObject.NotSet + self._object = GithubObject.NotSet + self._sha = GithubObject.NotSet + self._tag = GithubObject.NotSet + self._tagger = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "message" in attributes and attributes[ "message" ] is not None: # pragma no branch - assert isinstance( attributes[ "message" ], ( str, unicode ) ), attributes[ "message" ] + if "message" in attributes: # pragma no branch + assert attributes[ "message" ] is None or isinstance( attributes[ "message" ], ( str, unicode ) ), attributes[ "message" ] self._message = attributes[ "message" ] - if "object" in attributes and attributes[ "object" ] is not None: # pragma no branch - assert isinstance( attributes[ "object" ], dict ), attributes[ "object" ] - self._object = GitObject.GitObject( self._requester, attributes[ "object" ], completed = False ) - if "sha" in attributes and attributes[ "sha" ] is not None: # pragma no branch - assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] + if "object" in attributes: # pragma no branch + assert attributes[ "object" ] is None or isinstance( attributes[ "object" ], dict ), attributes[ "object" ] + self._object = None if attributes[ "object" ] is None else GitObject.GitObject( self._requester, attributes[ "object" ], completed = False ) + if "sha" in attributes: # pragma no branch + assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] self._sha = attributes[ "sha" ] - if "tag" in attributes and attributes[ "tag" ] is not None: # pragma no branch - assert isinstance( attributes[ "tag" ], ( str, unicode ) ), attributes[ "tag" ] + if "tag" in attributes: # pragma no branch + assert attributes[ "tag" ] is None or isinstance( attributes[ "tag" ], ( str, unicode ) ), attributes[ "tag" ] self._tag = attributes[ "tag" ] - if "tagger" in attributes and attributes[ "tagger" ] is not None: # pragma no branch - assert isinstance( attributes[ "tagger" ], dict ), attributes[ "tagger" ] - self._tagger = GitAuthor.GitAuthor( self._requester, attributes[ "tagger" ], completed = False ) - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "tagger" in attributes: # pragma no branch + assert attributes[ "tagger" ] is None or isinstance( attributes[ "tagger" ], dict ), attributes[ "tagger" ] + self._tagger = None if attributes[ "tagger" ] is None else GitAuthor.GitAuthor( self._requester, attributes[ "tagger" ], completed = False ) + 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/src/github/GitTree.py b/src/github/GitTree.py index 7439bf24..1435b745 100644 --- a/src/github/GitTree.py +++ b/src/github/GitTree.py @@ -8,34 +8,34 @@ import GitTreeElement class GitTree( GithubObject.GithubObject ): @property def sha( self ): - self._completeIfNeeded( self._sha ) - return self._sha + self._completeIfNotSet( self._sha ) + return self._NoneIfNotSet( self._sha ) @property def tree( self ): - self._completeIfNeeded( self._tree ) - return self._tree + self._completeIfNotSet( self._tree ) + return self._NoneIfNotSet( self._tree ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def _initAttributes( self ): - self._sha = None - self._tree = None - self._url = None + self._sha = GithubObject.NotSet + self._tree = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "sha" in attributes and attributes[ "sha" ] is not None: # pragma no branch - assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] + if "sha" in attributes: # pragma no branch + assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] self._sha = attributes[ "sha" ] - if "tree" in attributes and attributes[ "tree" ] is not None: # pragma no branch + if "tree" in attributes: # pragma no branch assert all( isinstance( element, dict ) for element in attributes[ "tree" ] ), attributes[ "tree" ] self._tree = [ GitTreeElement.GitTreeElement( self._requester, element, completed = False ) for element in attributes[ "tree" ] ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/GitTreeElement.py b/src/github/GitTreeElement.py index e966ac95..7cb5c3c3 100644 --- a/src/github/GitTreeElement.py +++ b/src/github/GitTreeElement.py @@ -6,52 +6,52 @@ import GithubObject class GitTreeElement( GithubObject.BasicGithubObject ): @property def mode( self ): - return self._mode + return self._NoneIfNotSet( self._mode ) @property def path( self ): - return self._path + return self._NoneIfNotSet( self._path ) @property def sha( self ): - return self._sha + return self._NoneIfNotSet( self._sha ) @property def size( self ): - return self._size + return self._NoneIfNotSet( self._size ) @property def type( self ): - return self._type + return self._NoneIfNotSet( self._type ) @property def url( self ): - return self._url + return self._NoneIfNotSet( self._url ) def _initAttributes( self ): - self._mode = None - self._path = None - self._sha = None - self._size = None - self._type = None - self._url = None + self._mode = GithubObject.NotSet + self._path = GithubObject.NotSet + self._sha = GithubObject.NotSet + self._size = GithubObject.NotSet + self._type = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "mode" in attributes and attributes[ "mode" ] is not None: # pragma no branch - assert isinstance( attributes[ "mode" ], ( str, unicode ) ), attributes[ "mode" ] + if "mode" in attributes: # pragma no branch + assert attributes[ "mode" ] is None or isinstance( attributes[ "mode" ], ( str, unicode ) ), attributes[ "mode" ] self._mode = attributes[ "mode" ] - if "path" in attributes and attributes[ "path" ] is not None: # pragma no branch - assert isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ] + if "path" in attributes: # pragma no branch + assert attributes[ "path" ] is None or isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ] self._path = attributes[ "path" ] - if "sha" in attributes and attributes[ "sha" ] is not None: # pragma no branch - assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] + if "sha" in attributes: # pragma no branch + assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] self._sha = attributes[ "sha" ] - if "size" in attributes and attributes[ "size" ] is not None: # pragma no branch - assert isinstance( attributes[ "size" ], int ), attributes[ "size" ] + if "size" in attributes: # pragma no branch + assert attributes[ "size" ] is None or isinstance( attributes[ "size" ], int ), attributes[ "size" ] self._size = attributes[ "size" ] - if "type" in attributes and attributes[ "type" ] is not None: # pragma no branch - assert isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ] + if "type" in attributes: # pragma no branch + assert attributes[ "type" ] is None or isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ] self._type = attributes[ "type" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/GithubObject.py b/src/github/GithubObject.py index 3939b2c2..485d345a 100644 --- a/src/github/GithubObject.py +++ b/src/github/GithubObject.py @@ -1,5 +1,9 @@ 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 @@ -13,19 +17,25 @@ class BasicGithubObject( object ): return "/".join( url.split( "/" )[ : -1 ] ) def _checkStatus( self, status, data ): - if status >= 400: # pragma no branch - raise GithubException.GithubException( status, data ) # pragma no cover + if status >= 400: + raise GithubException.GithubException( status, data ) + + def _NoneIfNotSet( self, value ): + if value is NotSet: + return None + else: + return value class GithubObject( BasicGithubObject ): def __init__( self, requester, attributes, completed ): BasicGithubObject.__init__( self, requester, attributes, completed ) self.__completed = completed - def _completeIfNeeded( self, testedAttribute ): - if not self.__completed and testedAttribute is None: - self.__complete() # pragma: no cover + def _completeIfNotSet( self, value ): + if not self.__completed and value is NotSet: + self.__complete() - def __complete( self ): # pragma: no cover + def __complete( self ): status, headers, data = self._request( "GET", self._url, diff --git a/src/github/Hook.py b/src/github/Hook.py index 03ae6dac..f8e971b3 100644 --- a/src/github/Hook.py +++ b/src/github/Hook.py @@ -2,55 +2,54 @@ # Do not modify it manually, your work would be lost. import GithubObject -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import HookResponse class Hook( GithubObject.GithubObject ): @property def active( self ): - self._completeIfNeeded( self._active ) - return self._active + self._completeIfNotSet( self._active ) + return self._NoneIfNotSet( self._active ) @property def config( self ): - self._completeIfNeeded( self._config ) - return self._config + self._completeIfNotSet( self._config ) + return self._NoneIfNotSet( self._config ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def events( self ): - self._completeIfNeeded( self._events ) - return self._events + self._completeIfNotSet( self._events ) + return self._NoneIfNotSet( self._events ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def last_response( self ): - self._completeIfNeeded( self._last_response ) - return self._last_response + self._completeIfNotSet( self._last_response ) + return self._NoneIfNotSet( self._last_response ) @property def name( self ): - self._completeIfNeeded( self._name ) - return self._name + self._completeIfNotSet( self._name ) + return self._NoneIfNotSet( self._name ) @property def updated_at( self ): - self._completeIfNeeded( self._updated_at ) - return self._updated_at + self._completeIfNotSet( self._updated_at ) + return self._NoneIfNotSet( self._updated_at ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def delete( self ): status, headers, data = self._request( @@ -61,27 +60,27 @@ class Hook( GithubObject.GithubObject ): ) self._checkStatus( status, data ) - def edit( self, name, config, events = DefaultValueForOptionalParameters, add_events = DefaultValueForOptionalParameters, remove_events = DefaultValueForOptionalParameters, active = DefaultValueForOptionalParameters ): + def edit( self, name, config, events = GithubObject.NotSet, add_events = GithubObject.NotSet, remove_events = GithubObject.NotSet, active = GithubObject.NotSet ): assert isinstance( name, ( str, unicode ) ), name - if events is not DefaultValueForOptionalParameters: + if events is not GithubObject.NotSet: assert all( isinstance( element, ( str, unicode ) ) for element in events ), events - if add_events is not DefaultValueForOptionalParameters: + if add_events is not GithubObject.NotSet: assert all( isinstance( element, ( str, unicode ) ) for element in add_events ), add_events - if remove_events is not DefaultValueForOptionalParameters: + if remove_events is not GithubObject.NotSet: assert all( isinstance( element, ( str, unicode ) ) for element in remove_events ), remove_events - if active is not DefaultValueForOptionalParameters: + if active is not GithubObject.NotSet: assert isinstance( active, bool ), active post_parameters = { "name": name, "config": config, } - if events is not DefaultValueForOptionalParameters: + if events is not GithubObject.NotSet: post_parameters[ "events" ] = events - if add_events is not DefaultValueForOptionalParameters: + if add_events is not GithubObject.NotSet: post_parameters[ "add_events" ] = add_events - if remove_events is not DefaultValueForOptionalParameters: + if remove_events is not GithubObject.NotSet: post_parameters[ "remove_events" ] = remove_events - if active is not DefaultValueForOptionalParameters: + if active is not GithubObject.NotSet: post_parameters[ "active" ] = active status, headers, data = self._request( "PATCH", @@ -102,40 +101,40 @@ class Hook( GithubObject.GithubObject ): self._checkStatus( status, data ) def _initAttributes( self ): - self._active = None - self._config = None - self._created_at = None - self._events = None - self._id = None - self._last_response = None - self._name = None - self._updated_at = None - self._url = None + self._active = GithubObject.NotSet + self._config = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._events = GithubObject.NotSet + self._id = GithubObject.NotSet + self._last_response = GithubObject.NotSet + self._name = GithubObject.NotSet + self._updated_at = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "active" in attributes and attributes[ "active" ] is not None: # pragma no branch - assert isinstance( attributes[ "active" ], bool ), attributes[ "active" ] + if "active" in attributes: # pragma no branch + assert attributes[ "active" ] is None or isinstance( attributes[ "active" ], bool ), attributes[ "active" ] self._active = attributes[ "active" ] - if "config" in attributes and attributes[ "config" ] is not None: # pragma no branch + if "config" in attributes: # pragma no branch self._config = attributes[ "config" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "events" in attributes and attributes[ "events" ] is not None: # pragma no branch + if "events" in attributes: # pragma no branch assert all( isinstance( element, ( str, unicode ) ) for element in attributes[ "events" ] ), attributes[ "events" ] self._events = attributes[ "events" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "last_response" in attributes and attributes[ "last_response" ] is not None: # pragma no branch - assert isinstance( attributes[ "last_response" ], dict ), attributes[ "last_response" ] - self._last_response = HookResponse.HookResponse( self._requester, attributes[ "last_response" ], completed = False ) - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "last_response" in attributes: # pragma no branch + assert attributes[ "last_response" ] is None or isinstance( attributes[ "last_response" ], dict ), attributes[ "last_response" ] + self._last_response = None if attributes[ "last_response" ] is None else HookResponse.HookResponse( self._requester, attributes[ "last_response" ], completed = False ) + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] - if "updated_at" in attributes and attributes[ "updated_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ] + 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 = attributes[ "updated_at" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/HookResponse.py b/src/github/HookResponse.py index c9c0d29a..acd82749 100644 --- a/src/github/HookResponse.py +++ b/src/github/HookResponse.py @@ -6,28 +6,28 @@ import GithubObject class HookResponse( GithubObject.BasicGithubObject ): @property def code( self ): - return self._code + return self._NoneIfNotSet( self._code ) @property def message( self ): - return self._message + return self._NoneIfNotSet( self._message ) @property def status( self ): - return self._status + return self._NoneIfNotSet( self._status ) def _initAttributes( self ): - self._code = None - self._message = None - self._status = None + self._code = GithubObject.NotSet + self._message = GithubObject.NotSet + self._status = GithubObject.NotSet def _useAttributes( self, attributes ): - if "code" in attributes and attributes[ "code" ] is not None: # pragma no branch - assert isinstance( attributes[ "code" ], int ), attributes[ "code" ] + if "code" in attributes: # pragma no branch + assert attributes[ "code" ] is None or isinstance( attributes[ "code" ], int ), attributes[ "code" ] self._code = attributes[ "code" ] - if "message" in attributes and attributes[ "message" ] is not None: # pragma no branch - assert isinstance( attributes[ "message" ], ( str, unicode ) ), attributes[ "message" ] + if "message" in attributes: # pragma no branch + assert attributes[ "message" ] is None or isinstance( attributes[ "message" ], ( str, unicode ) ), attributes[ "message" ] self._message = attributes[ "message" ] - if "status" in attributes and attributes[ "status" ] is not None: # pragma no branch - assert isinstance( attributes[ "status" ], ( str, unicode ) ), attributes[ "status" ] + if "status" in attributes: # pragma no branch + assert attributes[ "status" ] is None or isinstance( attributes[ "status" ], ( str, unicode ) ), attributes[ "status" ] self._status = attributes[ "status" ] diff --git a/src/github/Issue.py b/src/github/Issue.py index 00bed3ee..82ba3885 100644 --- a/src/github/Issue.py +++ b/src/github/Issue.py @@ -3,7 +3,6 @@ import GithubObject import PaginatedList -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import Repository import IssueEvent @@ -16,93 +15,93 @@ import IssuePullRequest class Issue( GithubObject.GithubObject ): @property def assignee( self ): - self._completeIfNeeded( self._assignee ) - return self._assignee + self._completeIfNotSet( self._assignee ) + return self._NoneIfNotSet( self._assignee ) @property def body( self ): - self._completeIfNeeded( self._body ) - return self._body + self._completeIfNotSet( self._body ) + return self._NoneIfNotSet( self._body ) @property def closed_at( self ): - self._completeIfNeeded( self._closed_at ) - return self._closed_at + self._completeIfNotSet( self._closed_at ) + return self._NoneIfNotSet( self._closed_at ) @property def closed_by( self ): - self._completeIfNeeded( self._closed_by ) - return self._closed_by + self._completeIfNotSet( self._closed_by ) + return self._NoneIfNotSet( self._closed_by ) @property def comments( self ): - self._completeIfNeeded( self._comments ) - return self._comments + self._completeIfNotSet( self._comments ) + return self._NoneIfNotSet( self._comments ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def html_url( self ): - self._completeIfNeeded( self._html_url ) - return self._html_url + self._completeIfNotSet( self._html_url ) + return self._NoneIfNotSet( self._html_url ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def labels( self ): - self._completeIfNeeded( self._labels ) - return self._labels + self._completeIfNotSet( self._labels ) + return self._NoneIfNotSet( self._labels ) @property def milestone( self ): - self._completeIfNeeded( self._milestone ) - return self._milestone + self._completeIfNotSet( self._milestone ) + return self._NoneIfNotSet( self._milestone ) @property def number( self ): - self._completeIfNeeded( self._number ) - return self._number + self._completeIfNotSet( self._number ) + return self._NoneIfNotSet( self._number ) @property def pull_request( self ): - self._completeIfNeeded( self._pull_request ) - return self._pull_request + self._completeIfNotSet( self._pull_request ) + return self._NoneIfNotSet( self._pull_request ) @property def repository( self ): - self._completeIfNeeded( self._repository ) - return self._repository + self._completeIfNotSet( self._repository ) + return self._NoneIfNotSet( self._repository ) @property def state( self ): - self._completeIfNeeded( self._state ) - return self._state + self._completeIfNotSet( self._state ) + return self._NoneIfNotSet( self._state ) @property def title( self ): - self._completeIfNeeded( self._title ) - return self._title + self._completeIfNotSet( self._title ) + return self._NoneIfNotSet( self._title ) @property def updated_at( self ): - self._completeIfNeeded( self._updated_at ) - return self._updated_at + self._completeIfNotSet( self._updated_at ) + return self._NoneIfNotSet( self._updated_at ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) @property def user( self ): - self._completeIfNeeded( self._user ) - return self._user + self._completeIfNotSet( self._user ) + return self._NoneIfNotSet( self._user ) def add_to_labels( self, *labels ): assert all( isinstance( label, Label.Label ) for label in labels ), labels @@ -138,31 +137,31 @@ class Issue( GithubObject.GithubObject ): ) self._checkStatus( status, data ) - def edit( self, title = DefaultValueForOptionalParameters, body = DefaultValueForOptionalParameters, assignee = DefaultValueForOptionalParameters, state = DefaultValueForOptionalParameters, milestone = DefaultValueForOptionalParameters, labels = DefaultValueForOptionalParameters ): - if title is not DefaultValueForOptionalParameters: + def edit( self, title = GithubObject.NotSet, body = GithubObject.NotSet, assignee = GithubObject.NotSet, state = GithubObject.NotSet, milestone = GithubObject.NotSet, labels = GithubObject.NotSet ): + if title is not GithubObject.NotSet: assert isinstance( title, ( str, unicode ) ), title - if body is not DefaultValueForOptionalParameters: + if body is not GithubObject.NotSet: assert isinstance( body, ( str, unicode ) ), body - if assignee is not DefaultValueForOptionalParameters: + if assignee is not GithubObject.NotSet: assert isinstance( assignee, ( str, unicode ) ), assignee - if state is not DefaultValueForOptionalParameters: + if state is not GithubObject.NotSet: assert isinstance( state, ( str, unicode ) ), state - if milestone is not DefaultValueForOptionalParameters: + if milestone is not GithubObject.NotSet: assert isinstance( milestone, int ), milestone - if labels is not DefaultValueForOptionalParameters: + if labels is not GithubObject.NotSet: assert all( isinstance( element, ( str, unicode ) ) for element in labels ), labels post_parameters = dict() - if title is not DefaultValueForOptionalParameters: + if title is not GithubObject.NotSet: post_parameters[ "title" ] = title - if body is not DefaultValueForOptionalParameters: + if body is not GithubObject.NotSet: post_parameters[ "body" ] = body - if assignee is not DefaultValueForOptionalParameters: + if assignee is not GithubObject.NotSet: post_parameters[ "assignee" ] = assignee - if state is not DefaultValueForOptionalParameters: + if state is not GithubObject.NotSet: post_parameters[ "state" ] = state - if milestone is not DefaultValueForOptionalParameters: + if milestone is not GithubObject.NotSet: post_parameters[ "milestone" ] = milestone - if labels is not DefaultValueForOptionalParameters: + if labels is not GithubObject.NotSet: post_parameters[ "labels" ] = labels status, headers, data = self._request( "PATCH", @@ -251,80 +250,80 @@ class Issue( GithubObject.GithubObject ): self._checkStatus( status, data ) def _initAttributes( self ): - self._assignee = None - self._body = None - self._closed_at = None - self._closed_by = None - self._comments = None - self._created_at = None - self._html_url = None - self._id = None - self._labels = None - self._milestone = None - self._number = None - self._pull_request = None - self._repository = None - self._state = None - self._title = None - self._updated_at = None - self._url = None - self._user = None + self._assignee = GithubObject.NotSet + self._body = GithubObject.NotSet + self._closed_at = GithubObject.NotSet + self._closed_by = GithubObject.NotSet + self._comments = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._html_url = GithubObject.NotSet + self._id = GithubObject.NotSet + self._labels = GithubObject.NotSet + self._milestone = GithubObject.NotSet + self._number = GithubObject.NotSet + self._pull_request = GithubObject.NotSet + self._repository = GithubObject.NotSet + self._state = GithubObject.NotSet + self._title = GithubObject.NotSet + self._updated_at = GithubObject.NotSet + self._url = GithubObject.NotSet + self._user = GithubObject.NotSet def _useAttributes( self, attributes ): - if "assignee" in attributes and attributes[ "assignee" ] is not None: # pragma no branch - assert isinstance( attributes[ "assignee" ], dict ), attributes[ "assignee" ] - self._assignee = NamedUser.NamedUser( self._requester, attributes[ "assignee" ], completed = False ) - if "body" in attributes and attributes[ "body" ] is not None: # pragma no branch - assert isinstance( attributes[ "body" ], ( str, unicode ) ), attributes[ "body" ] + if "assignee" in attributes: # pragma no branch + assert attributes[ "assignee" ] is None or isinstance( attributes[ "assignee" ], dict ), attributes[ "assignee" ] + self._assignee = None if attributes[ "assignee" ] is None else NamedUser.NamedUser( self._requester, attributes[ "assignee" ], completed = False ) + if "body" in attributes: # pragma no branch + assert attributes[ "body" ] is None or isinstance( attributes[ "body" ], ( str, unicode ) ), attributes[ "body" ] self._body = attributes[ "body" ] - if "closed_at" in attributes and attributes[ "closed_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "closed_at" ], ( str, unicode ) ), attributes[ "closed_at" ] + 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 = attributes[ "closed_at" ] - if "closed_by" in attributes and attributes[ "closed_by" ] is not None: # pragma no branch - assert isinstance( attributes[ "closed_by" ], dict ), attributes[ "closed_by" ] - self._closed_by = NamedUser.NamedUser( self._requester, attributes[ "closed_by" ], completed = False ) - if "comments" in attributes and attributes[ "comments" ] is not None: # pragma no branch - assert isinstance( attributes[ "comments" ], int ), attributes[ "comments" ] + 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 ) + if "comments" in attributes: # pragma no branch + assert attributes[ "comments" ] is None or isinstance( attributes[ "comments" ], int ), attributes[ "comments" ] self._comments = attributes[ "comments" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "html_url" in attributes and attributes[ "html_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ] + 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" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "labels" in attributes and attributes[ "labels" ] is not None: # pragma no branch + if "labels" in attributes: # pragma no branch assert all( isinstance( element, dict ) for element in attributes[ "labels" ] ), attributes[ "labels" ] self._labels = [ Label.Label( self._requester, element, completed = False ) for element in attributes[ "labels" ] ] - if "milestone" in attributes and attributes[ "milestone" ] is not None: # pragma no branch - assert isinstance( attributes[ "milestone" ], dict ), attributes[ "milestone" ] - self._milestone = Milestone.Milestone( self._requester, attributes[ "milestone" ], completed = False ) - if "number" in attributes and attributes[ "number" ] is not None: # pragma no branch - assert isinstance( attributes[ "number" ], int ), attributes[ "number" ] + if "milestone" in attributes: # pragma no branch + assert attributes[ "milestone" ] is None or isinstance( attributes[ "milestone" ], dict ), attributes[ "milestone" ] + self._milestone = None if attributes[ "milestone" ] is None else Milestone.Milestone( self._requester, attributes[ "milestone" ], completed = False ) + if "number" in attributes: # pragma no branch + assert attributes[ "number" ] is None or isinstance( attributes[ "number" ], int ), attributes[ "number" ] self._number = attributes[ "number" ] - if "pull_request" in attributes and attributes[ "pull_request" ] is not None: # pragma no branch - assert isinstance( attributes[ "pull_request" ], dict ), attributes[ "pull_request" ] - self._pull_request = IssuePullRequest.IssuePullRequest( self._requester, attributes[ "pull_request" ], completed = False ) - if "repository" in attributes and attributes[ "repository" ] is not None: # pragma no branch - assert isinstance( attributes[ "repository" ], dict ), attributes[ "repository" ] - self._repository = Repository.Repository( self._requester, attributes[ "repository" ], completed = False ) - if "state" in attributes and attributes[ "state" ] is not None: # pragma no branch - assert isinstance( attributes[ "state" ], ( str, unicode ) ), attributes[ "state" ] + if "pull_request" in attributes: # pragma no branch + assert attributes[ "pull_request" ] is None or isinstance( attributes[ "pull_request" ], dict ), attributes[ "pull_request" ] + self._pull_request = None if attributes[ "pull_request" ] is None else IssuePullRequest.IssuePullRequest( self._requester, attributes[ "pull_request" ], completed = False ) + if "repository" in attributes: # pragma no branch + assert attributes[ "repository" ] is None or isinstance( attributes[ "repository" ], dict ), attributes[ "repository" ] + self._repository = None if attributes[ "repository" ] is None else Repository.Repository( self._requester, attributes[ "repository" ], completed = False ) + if "state" in attributes: # pragma no branch + assert attributes[ "state" ] is None or isinstance( attributes[ "state" ], ( str, unicode ) ), attributes[ "state" ] self._state = attributes[ "state" ] - if "title" in attributes and attributes[ "title" ] is not None: # pragma no branch - assert isinstance( attributes[ "title" ], ( str, unicode ) ), attributes[ "title" ] + if "title" in attributes: # pragma no branch + assert attributes[ "title" ] is None or isinstance( attributes[ "title" ], ( str, unicode ) ), attributes[ "title" ] self._title = attributes[ "title" ] - if "updated_at" in attributes and attributes[ "updated_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ] + 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 = attributes[ "updated_at" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "url" in attributes: # pragma no branch + assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] self._url = attributes[ "url" ] - if "user" in attributes and attributes[ "user" ] is not None: # pragma no branch - assert isinstance( attributes[ "user" ], dict ), attributes[ "user" ] - self._user = NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) + if "user" in attributes: # pragma no branch + assert attributes[ "user" ] is None or isinstance( attributes[ "user" ], dict ), attributes[ "user" ] + self._user = None if attributes[ "user" ] is None else NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) diff --git a/src/github/IssueComment.py b/src/github/IssueComment.py index f18e04fe..f29fbd2f 100644 --- a/src/github/IssueComment.py +++ b/src/github/IssueComment.py @@ -8,33 +8,33 @@ import NamedUser class IssueComment( GithubObject.GithubObject ): @property def body( self ): - self._completeIfNeeded( self._body ) - return self._body + self._completeIfNotSet( self._body ) + return self._NoneIfNotSet( self._body ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def updated_at( self ): - self._completeIfNeeded( self._updated_at ) - return self._updated_at + self._completeIfNotSet( self._updated_at ) + return self._NoneIfNotSet( self._updated_at ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) @property def user( self ): - self._completeIfNeeded( self._user ) - return self._user + self._completeIfNotSet( self._user ) + return self._NoneIfNotSet( self._user ) def delete( self ): status, headers, data = self._request( @@ -60,29 +60,29 @@ class IssueComment( GithubObject.GithubObject ): self._useAttributes( data ) def _initAttributes( self ): - self._body = None - self._created_at = None - self._id = None - self._updated_at = None - self._url = None - self._user = None + self._body = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._id = GithubObject.NotSet + self._updated_at = GithubObject.NotSet + self._url = GithubObject.NotSet + self._user = GithubObject.NotSet def _useAttributes( self, attributes ): - if "body" in attributes and attributes[ "body" ] is not None: # pragma no branch - assert isinstance( attributes[ "body" ], ( str, unicode ) ), attributes[ "body" ] + if "body" in attributes: # pragma no branch + assert attributes[ "body" ] is None or isinstance( attributes[ "body" ], ( str, unicode ) ), attributes[ "body" ] self._body = attributes[ "body" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + 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 and attributes[ "updated_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ] + 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 = attributes[ "updated_at" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "url" in attributes: # pragma no branch + assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] self._url = attributes[ "url" ] - if "user" in attributes and attributes[ "user" ] is not None: # pragma no branch - assert isinstance( attributes[ "user" ], dict ), attributes[ "user" ] - self._user = NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) + if "user" in attributes: # pragma no branch + assert attributes[ "user" ] is None or isinstance( attributes[ "user" ], dict ), attributes[ "user" ] + self._user = None if attributes[ "user" ] is None else NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) diff --git a/src/github/IssueEvent.py b/src/github/IssueEvent.py index adec035f..09f395fc 100644 --- a/src/github/IssueEvent.py +++ b/src/github/IssueEvent.py @@ -9,67 +9,67 @@ import NamedUser class IssueEvent( GithubObject.GithubObject ): @property def actor( self ): - self._completeIfNeeded( self._actor ) - return self._actor + self._completeIfNotSet( self._actor ) + return self._NoneIfNotSet( self._actor ) @property def commit_id( self ): - self._completeIfNeeded( self._commit_id ) - return self._commit_id + self._completeIfNotSet( self._commit_id ) + return self._NoneIfNotSet( self._commit_id ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def event( self ): - self._completeIfNeeded( self._event ) - return self._event + self._completeIfNotSet( self._event ) + return self._NoneIfNotSet( self._event ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def issue( self ): - self._completeIfNeeded( self._issue ) - return self._issue + self._completeIfNotSet( self._issue ) + return self._NoneIfNotSet( self._issue ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def _initAttributes( self ): - self._actor = None - self._commit_id = None - self._created_at = None - self._event = None - self._id = None - self._issue = None - self._url = None + self._actor = GithubObject.NotSet + self._commit_id = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._event = GithubObject.NotSet + self._id = GithubObject.NotSet + self._issue = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "actor" in attributes and attributes[ "actor" ] is not None: # pragma no branch - assert isinstance( attributes[ "actor" ], dict ), attributes[ "actor" ] - self._actor = NamedUser.NamedUser( self._requester, attributes[ "actor" ], completed = False ) - if "commit_id" in attributes and attributes[ "commit_id" ] is not None: # pragma no branch - assert isinstance( attributes[ "commit_id" ], ( str, unicode ) ), attributes[ "commit_id" ] + if "actor" in attributes: # pragma no branch + assert attributes[ "actor" ] is None or isinstance( attributes[ "actor" ], dict ), attributes[ "actor" ] + self._actor = None if attributes[ "actor" ] is None else NamedUser.NamedUser( self._requester, attributes[ "actor" ], completed = False ) + if "commit_id" in attributes: # pragma no branch + assert attributes[ "commit_id" ] is None or isinstance( attributes[ "commit_id" ], ( str, unicode ) ), attributes[ "commit_id" ] self._commit_id = attributes[ "commit_id" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "event" in attributes and attributes[ "event" ] is not None: # pragma no branch - assert isinstance( attributes[ "event" ], ( str, unicode ) ), attributes[ "event" ] + if "event" in attributes: # pragma no branch + assert attributes[ "event" ] is None or isinstance( attributes[ "event" ], ( str, unicode ) ), attributes[ "event" ] self._event = attributes[ "event" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "issue" in attributes and attributes[ "issue" ] is not None: # pragma no branch - assert isinstance( attributes[ "issue" ], dict ), attributes[ "issue" ] - self._issue = Issue.Issue( self._requester, attributes[ "issue" ], completed = False ) - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "issue" in attributes: # pragma no branch + assert attributes[ "issue" ] is None or isinstance( attributes[ "issue" ], dict ), attributes[ "issue" ] + self._issue = None if attributes[ "issue" ] is None else Issue.Issue( self._requester, attributes[ "issue" ], completed = False ) + 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/src/github/IssuePullRequest.py b/src/github/IssuePullRequest.py index 56903591..1ed469bf 100644 --- a/src/github/IssuePullRequest.py +++ b/src/github/IssuePullRequest.py @@ -6,28 +6,28 @@ import GithubObject class IssuePullRequest( GithubObject.BasicGithubObject ): @property def diff_url( self ): - return self._diff_url + return self._NoneIfNotSet( self._diff_url ) @property def html_url( self ): - return self._html_url + return self._NoneIfNotSet( self._html_url ) @property def patch_url( self ): - return self._patch_url + return self._NoneIfNotSet( self._patch_url ) def _initAttributes( self ): - self._diff_url = None - self._html_url = None - self._patch_url = None + self._diff_url = GithubObject.NotSet + self._html_url = GithubObject.NotSet + self._patch_url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "diff_url" in attributes and attributes[ "diff_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "diff_url" ], ( str, unicode ) ), attributes[ "diff_url" ] + if "diff_url" in attributes: # pragma no branch + assert attributes[ "diff_url" ] is None or isinstance( attributes[ "diff_url" ], ( str, unicode ) ), attributes[ "diff_url" ] self._diff_url = attributes[ "diff_url" ] - if "html_url" in attributes and attributes[ "html_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ] + 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" ] - if "patch_url" in attributes and attributes[ "patch_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "patch_url" ], ( str, unicode ) ), attributes[ "patch_url" ] + if "patch_url" in attributes: # pragma no branch + assert attributes[ "patch_url" ] is None or isinstance( attributes[ "patch_url" ], ( str, unicode ) ), attributes[ "patch_url" ] self._patch_url = attributes[ "patch_url" ] diff --git a/src/github/Label.py b/src/github/Label.py index dd7c49fc..b23feb88 100644 --- a/src/github/Label.py +++ b/src/github/Label.py @@ -8,18 +8,18 @@ import GithubObject class Label( GithubObject.GithubObject ): @property def color( self ): - self._completeIfNeeded( self._color ) - return self._color + self._completeIfNotSet( self._color ) + return self._NoneIfNotSet( self._color ) @property def name( self ): - self._completeIfNeeded( self._name ) - return self._name + self._completeIfNotSet( self._name ) + return self._NoneIfNotSet( self._name ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def delete( self ): status, headers, data = self._request( @@ -51,17 +51,17 @@ class Label( GithubObject.GithubObject ): return urllib.quote( str( self.name ) ) def _initAttributes( self ): - self._color = None - self._name = None - self._url = None + self._color = GithubObject.NotSet + self._name = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "color" in attributes and attributes[ "color" ] is not None: # pragma no branch - assert isinstance( attributes[ "color" ], ( str, unicode ) ), attributes[ "color" ] + if "color" in attributes: # pragma no branch + assert attributes[ "color" ] is None or isinstance( attributes[ "color" ], ( str, unicode ) ), attributes[ "color" ] self._color = attributes[ "color" ] - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/Milestone.py b/src/github/Milestone.py index 963ddf60..0504baa1 100644 --- a/src/github/Milestone.py +++ b/src/github/Milestone.py @@ -3,7 +3,6 @@ import GithubObject import PaginatedList -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import NamedUser import Label @@ -11,58 +10,58 @@ import Label class Milestone( GithubObject.GithubObject ): @property def closed_issues( self ): - self._completeIfNeeded( self._closed_issues ) - return self._closed_issues + self._completeIfNotSet( self._closed_issues ) + return self._NoneIfNotSet( self._closed_issues ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def creator( self ): - self._completeIfNeeded( self._creator ) - return self._creator + self._completeIfNotSet( self._creator ) + return self._NoneIfNotSet( self._creator ) @property def description( self ): - self._completeIfNeeded( self._description ) - return self._description + self._completeIfNotSet( self._description ) + return self._NoneIfNotSet( self._description ) @property def due_on( self ): - self._completeIfNeeded( self._due_on ) - return self._due_on + self._completeIfNotSet( self._due_on ) + return self._NoneIfNotSet( self._due_on ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def number( self ): - self._completeIfNeeded( self._number ) - return self._number + self._completeIfNotSet( self._number ) + return self._NoneIfNotSet( self._number ) @property def open_issues( self ): - self._completeIfNeeded( self._open_issues ) - return self._open_issues + self._completeIfNotSet( self._open_issues ) + return self._NoneIfNotSet( self._open_issues ) @property def state( self ): - self._completeIfNeeded( self._state ) - return self._state + self._completeIfNotSet( self._state ) + return self._NoneIfNotSet( self._state ) @property def title( self ): - self._completeIfNeeded( self._title ) - return self._title + self._completeIfNotSet( self._title ) + return self._NoneIfNotSet( self._title ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def delete( self ): status, headers, data = self._request( @@ -73,22 +72,22 @@ class Milestone( GithubObject.GithubObject ): ) self._checkStatus( status, data ) - def edit( self, title, state = DefaultValueForOptionalParameters, description = DefaultValueForOptionalParameters, due_on = DefaultValueForOptionalParameters ): + def edit( self, title, state = GithubObject.NotSet, description = GithubObject.NotSet, due_on = GithubObject.NotSet ): assert isinstance( title, ( str, unicode ) ), title - if state is not DefaultValueForOptionalParameters: + if state is not GithubObject.NotSet: assert isinstance( state, ( str, unicode ) ), state - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: assert isinstance( description, ( str, unicode ) ), description - if due_on is not DefaultValueForOptionalParameters: + if due_on is not GithubObject.NotSet: assert isinstance( due_on, ( str, unicode ) ), due_on post_parameters = { "title": title, } - if state is not DefaultValueForOptionalParameters: + if state is not GithubObject.NotSet: post_parameters[ "state" ] = state - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: post_parameters[ "description" ] = description - if due_on is not DefaultValueForOptionalParameters: + if due_on is not GithubObject.NotSet: post_parameters[ "due_on" ] = due_on status, headers, data = self._request( "PATCH", @@ -115,49 +114,49 @@ class Milestone( GithubObject.GithubObject ): ) def _initAttributes( self ): - self._closed_issues = None - self._created_at = None - self._creator = None - self._description = None - self._due_on = None - self._id = None - self._number = None - self._open_issues = None - self._state = None - self._title = None - self._url = None + self._closed_issues = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._creator = GithubObject.NotSet + self._description = GithubObject.NotSet + self._due_on = GithubObject.NotSet + self._id = GithubObject.NotSet + self._number = GithubObject.NotSet + self._open_issues = GithubObject.NotSet + self._state = GithubObject.NotSet + self._title = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "closed_issues" in attributes and attributes[ "closed_issues" ] is not None: # pragma no branch - assert isinstance( attributes[ "closed_issues" ], int ), attributes[ "closed_issues" ] + if "closed_issues" in attributes: # pragma no branch + assert attributes[ "closed_issues" ] is None or isinstance( attributes[ "closed_issues" ], int ), attributes[ "closed_issues" ] self._closed_issues = attributes[ "closed_issues" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "creator" in attributes and attributes[ "creator" ] is not None: # pragma no branch - assert isinstance( attributes[ "creator" ], dict ), attributes[ "creator" ] - self._creator = NamedUser.NamedUser( self._requester, attributes[ "creator" ], completed = False ) - if "description" in attributes and attributes[ "description" ] is not None: # pragma no branch - assert isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ] + 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 ) + if "description" in attributes: # pragma no branch + assert attributes[ "description" ] is None or isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ] self._description = attributes[ "description" ] - if "due_on" in attributes and attributes[ "due_on" ] is not None: # pragma no branch - assert isinstance( attributes[ "due_on" ], ( str, unicode ) ), attributes[ "due_on" ] + 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 = attributes[ "due_on" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "number" in attributes and attributes[ "number" ] is not None: # pragma no branch - assert isinstance( attributes[ "number" ], int ), attributes[ "number" ] + if "number" in attributes: # pragma no branch + assert attributes[ "number" ] is None or isinstance( attributes[ "number" ], int ), attributes[ "number" ] self._number = attributes[ "number" ] - if "open_issues" in attributes and attributes[ "open_issues" ] is not None: # pragma no branch - assert isinstance( attributes[ "open_issues" ], int ), attributes[ "open_issues" ] + if "open_issues" in attributes: # pragma no branch + assert attributes[ "open_issues" ] is None or isinstance( attributes[ "open_issues" ], int ), attributes[ "open_issues" ] self._open_issues = attributes[ "open_issues" ] - if "state" in attributes and attributes[ "state" ] is not None: # pragma no branch - assert isinstance( attributes[ "state" ], ( str, unicode ) ), attributes[ "state" ] + if "state" in attributes: # pragma no branch + assert attributes[ "state" ] is None or isinstance( attributes[ "state" ], ( str, unicode ) ), attributes[ "state" ] self._state = attributes[ "state" ] - if "title" in attributes and attributes[ "title" ] is not None: # pragma no branch - assert isinstance( attributes[ "title" ], ( str, unicode ) ), attributes[ "title" ] + if "title" in attributes: # pragma no branch + assert attributes[ "title" ] is None or isinstance( attributes[ "title" ], ( str, unicode ) ), attributes[ "title" ] self._title = attributes[ "title" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/NamedUser.py b/src/github/NamedUser.py index 1165b139..266e98c5 100644 --- a/src/github/NamedUser.py +++ b/src/github/NamedUser.py @@ -3,7 +3,6 @@ import GithubObject import PaginatedList -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import Gist import Repository @@ -15,143 +14,143 @@ import Event class NamedUser( GithubObject.GithubObject ): @property def avatar_url( self ): - self._completeIfNeeded( self._avatar_url ) - return self._avatar_url + self._completeIfNotSet( self._avatar_url ) + return self._NoneIfNotSet( self._avatar_url ) @property def bio( self ): - self._completeIfNeeded( self._bio ) - return self._bio + self._completeIfNotSet( self._bio ) + return self._NoneIfNotSet( self._bio ) @property def blog( self ): - self._completeIfNeeded( self._blog ) - return self._blog + self._completeIfNotSet( self._blog ) + return self._NoneIfNotSet( self._blog ) @property def collaborators( self ): - self._completeIfNeeded( self._collaborators ) - return self._collaborators + self._completeIfNotSet( self._collaborators ) + return self._NoneIfNotSet( self._collaborators ) @property def company( self ): - self._completeIfNeeded( self._company ) - return self._company + self._completeIfNotSet( self._company ) + return self._NoneIfNotSet( self._company ) @property def contributions( self ): - self._completeIfNeeded( self._contributions ) - return self._contributions + self._completeIfNotSet( self._contributions ) + return self._NoneIfNotSet( self._contributions ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def disk_usage( self ): - self._completeIfNeeded( self._disk_usage ) - return self._disk_usage + self._completeIfNotSet( self._disk_usage ) + return self._NoneIfNotSet( self._disk_usage ) @property def email( self ): - self._completeIfNeeded( self._email ) - return self._email + self._completeIfNotSet( self._email ) + return self._NoneIfNotSet( self._email ) @property def followers( self ): - self._completeIfNeeded( self._followers ) - return self._followers + self._completeIfNotSet( self._followers ) + return self._NoneIfNotSet( self._followers ) @property def following( self ): - self._completeIfNeeded( self._following ) - return self._following + self._completeIfNotSet( self._following ) + return self._NoneIfNotSet( self._following ) @property def gravatar_id( self ): - self._completeIfNeeded( self._gravatar_id ) - return self._gravatar_id + self._completeIfNotSet( self._gravatar_id ) + return self._NoneIfNotSet( self._gravatar_id ) @property def hireable( self ): - self._completeIfNeeded( self._hireable ) - return self._hireable + self._completeIfNotSet( self._hireable ) + return self._NoneIfNotSet( self._hireable ) @property def html_url( self ): - self._completeIfNeeded( self._html_url ) - return self._html_url + self._completeIfNotSet( self._html_url ) + return self._NoneIfNotSet( self._html_url ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def location( self ): - self._completeIfNeeded( self._location ) - return self._location + self._completeIfNotSet( self._location ) + return self._NoneIfNotSet( self._location ) @property def login( self ): - self._completeIfNeeded( self._login ) - return self._login + self._completeIfNotSet( self._login ) + return self._NoneIfNotSet( self._login ) @property def name( self ): - self._completeIfNeeded( self._name ) - return self._name + self._completeIfNotSet( self._name ) + return self._NoneIfNotSet( self._name ) @property def owned_private_repos( self ): - self._completeIfNeeded( self._owned_private_repos ) - return self._owned_private_repos + self._completeIfNotSet( self._owned_private_repos ) + return self._NoneIfNotSet( self._owned_private_repos ) @property def plan( self ): - self._completeIfNeeded( self._plan ) - return self._plan + self._completeIfNotSet( self._plan ) + return self._NoneIfNotSet( self._plan ) @property def private_gists( self ): - self._completeIfNeeded( self._private_gists ) - return self._private_gists + self._completeIfNotSet( self._private_gists ) + return self._NoneIfNotSet( self._private_gists ) @property def public_gists( self ): - self._completeIfNeeded( self._public_gists ) - return self._public_gists + self._completeIfNotSet( self._public_gists ) + return self._NoneIfNotSet( self._public_gists ) @property def public_repos( self ): - self._completeIfNeeded( self._public_repos ) - return self._public_repos + self._completeIfNotSet( self._public_repos ) + return self._NoneIfNotSet( self._public_repos ) @property def total_private_repos( self ): - self._completeIfNeeded( self._total_private_repos ) - return self._total_private_repos + self._completeIfNotSet( self._total_private_repos ) + return self._NoneIfNotSet( self._total_private_repos ) @property def type( self ): - self._completeIfNeeded( self._type ) - return self._type + self._completeIfNotSet( self._type ) + return self._NoneIfNotSet( self._type ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) - def create_gist( self, public, files, description = DefaultValueForOptionalParameters ): + def create_gist( self, public, files, description = GithubObject.NotSet ): assert isinstance( public, bool ), public - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: assert isinstance( description, ( str, unicode ) ), description post_parameters = { "public": public, "files": files, } - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: post_parameters[ "description" ] = description status, headers, data = self._request( "POST", @@ -293,11 +292,11 @@ class NamedUser( GithubObject.GithubObject ): self._checkStatus( status, data ) return Repository.Repository( self._requester, data, completed = True ) - def get_repos( self, type = DefaultValueForOptionalParameters ): - if type is not DefaultValueForOptionalParameters: + def get_repos( self, type = GithubObject.NotSet ): + if type is not GithubObject.NotSet: assert isinstance( type, ( str, unicode ) ), type url_parameters = dict() - if type is not DefaultValueForOptionalParameters: + if type is not GithubObject.NotSet: url_parameters[ "type" ] = type status, headers, data = self._request( "GET", @@ -333,109 +332,109 @@ class NamedUser( GithubObject.GithubObject ): return str( self.login ) def _initAttributes( self ): - self._avatar_url = None - self._bio = None - self._blog = None - self._collaborators = None - self._company = None - self._contributions = None - self._created_at = None - self._disk_usage = None - self._email = None - self._followers = None - self._following = None - self._gravatar_id = None - self._hireable = None - self._html_url = None - self._id = None - self._location = None - self._login = None - self._name = None - self._owned_private_repos = None - self._plan = None - self._private_gists = None - self._public_gists = None - self._public_repos = None - self._total_private_repos = None - self._type = None - self._url = None + self._avatar_url = GithubObject.NotSet + self._bio = GithubObject.NotSet + self._blog = GithubObject.NotSet + self._collaborators = GithubObject.NotSet + self._company = GithubObject.NotSet + self._contributions = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._disk_usage = GithubObject.NotSet + self._email = GithubObject.NotSet + self._followers = GithubObject.NotSet + self._following = GithubObject.NotSet + self._gravatar_id = GithubObject.NotSet + self._hireable = GithubObject.NotSet + self._html_url = GithubObject.NotSet + self._id = GithubObject.NotSet + self._location = GithubObject.NotSet + self._login = GithubObject.NotSet + self._name = GithubObject.NotSet + self._owned_private_repos = GithubObject.NotSet + self._plan = GithubObject.NotSet + self._private_gists = GithubObject.NotSet + self._public_gists = GithubObject.NotSet + self._public_repos = GithubObject.NotSet + self._total_private_repos = GithubObject.NotSet + self._type = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "avatar_url" in attributes and attributes[ "avatar_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "avatar_url" ], ( str, unicode ) ), attributes[ "avatar_url" ] + if "avatar_url" in attributes: # pragma no branch + assert attributes[ "avatar_url" ] is None or isinstance( attributes[ "avatar_url" ], ( str, unicode ) ), attributes[ "avatar_url" ] self._avatar_url = attributes[ "avatar_url" ] - if "bio" in attributes and attributes[ "bio" ] is not None: # pragma no branch - assert isinstance( attributes[ "bio" ], ( str, unicode ) ), attributes[ "bio" ] + if "bio" in attributes: # pragma no branch + assert attributes[ "bio" ] is None or isinstance( attributes[ "bio" ], ( str, unicode ) ), attributes[ "bio" ] self._bio = attributes[ "bio" ] - if "blog" in attributes and attributes[ "blog" ] is not None: # pragma no branch - assert isinstance( attributes[ "blog" ], ( str, unicode ) ), attributes[ "blog" ] + if "blog" in attributes: # pragma no branch + assert attributes[ "blog" ] is None or isinstance( attributes[ "blog" ], ( str, unicode ) ), attributes[ "blog" ] self._blog = attributes[ "blog" ] - if "collaborators" in attributes and attributes[ "collaborators" ] is not None: # pragma no branch - assert isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ] + if "collaborators" in attributes: # pragma no branch + assert attributes[ "collaborators" ] is None or isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ] self._collaborators = attributes[ "collaborators" ] - if "company" in attributes and attributes[ "company" ] is not None: # pragma no branch - assert isinstance( attributes[ "company" ], ( str, unicode ) ), attributes[ "company" ] + if "company" in attributes: # pragma no branch + assert attributes[ "company" ] is None or isinstance( attributes[ "company" ], ( str, unicode ) ), attributes[ "company" ] self._company = attributes[ "company" ] - if "contributions" in attributes and attributes[ "contributions" ] is not None: # pragma no branch - assert isinstance( attributes[ "contributions" ], int ), attributes[ "contributions" ] + if "contributions" in attributes: # pragma no branch + assert attributes[ "contributions" ] is None or isinstance( attributes[ "contributions" ], int ), attributes[ "contributions" ] self._contributions = attributes[ "contributions" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "disk_usage" in attributes and attributes[ "disk_usage" ] is not None: # pragma no branch - assert isinstance( attributes[ "disk_usage" ], int ), attributes[ "disk_usage" ] + 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" ] - if "email" in attributes and attributes[ "email" ] is not None: # pragma no branch - assert isinstance( attributes[ "email" ], ( str, unicode ) ), attributes[ "email" ] + if "email" in attributes: # pragma no branch + assert attributes[ "email" ] is None or isinstance( attributes[ "email" ], ( str, unicode ) ), attributes[ "email" ] self._email = attributes[ "email" ] - if "followers" in attributes and attributes[ "followers" ] is not None: # pragma no branch - assert isinstance( attributes[ "followers" ], int ), attributes[ "followers" ] + if "followers" in attributes: # pragma no branch + assert attributes[ "followers" ] is None or isinstance( attributes[ "followers" ], int ), attributes[ "followers" ] self._followers = attributes[ "followers" ] - if "following" in attributes and attributes[ "following" ] is not None: # pragma no branch - assert isinstance( attributes[ "following" ], int ), attributes[ "following" ] + if "following" in attributes: # pragma no branch + assert attributes[ "following" ] is None or isinstance( attributes[ "following" ], int ), attributes[ "following" ] self._following = attributes[ "following" ] - if "gravatar_id" in attributes and attributes[ "gravatar_id" ] is not None: # pragma no branch - assert isinstance( attributes[ "gravatar_id" ], ( str, unicode ) ), attributes[ "gravatar_id" ] + if "gravatar_id" in attributes: # pragma no branch + assert attributes[ "gravatar_id" ] is None or isinstance( attributes[ "gravatar_id" ], ( str, unicode ) ), attributes[ "gravatar_id" ] self._gravatar_id = attributes[ "gravatar_id" ] - if "hireable" in attributes and attributes[ "hireable" ] is not None: # pragma no branch - assert isinstance( attributes[ "hireable" ], bool ), attributes[ "hireable" ] + if "hireable" in attributes: # pragma no branch + assert attributes[ "hireable" ] is None or isinstance( attributes[ "hireable" ], bool ), attributes[ "hireable" ] self._hireable = attributes[ "hireable" ] - if "html_url" in attributes and attributes[ "html_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ] + 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" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "location" in attributes and attributes[ "location" ] is not None: # pragma no branch - assert isinstance( attributes[ "location" ], ( str, unicode ) ), attributes[ "location" ] + if "location" in attributes: # pragma no branch + assert attributes[ "location" ] is None or isinstance( attributes[ "location" ], ( str, unicode ) ), attributes[ "location" ] self._location = attributes[ "location" ] - if "login" in attributes and attributes[ "login" ] is not None: # pragma no branch - assert isinstance( attributes[ "login" ], ( str, unicode ) ), attributes[ "login" ] + if "login" in attributes: # pragma no branch + assert attributes[ "login" ] is None or isinstance( attributes[ "login" ], ( str, unicode ) ), attributes[ "login" ] self._login = attributes[ "login" ] - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] - if "owned_private_repos" in attributes and attributes[ "owned_private_repos" ] is not None: # pragma no branch - assert isinstance( attributes[ "owned_private_repos" ], int ), attributes[ "owned_private_repos" ] + if "owned_private_repos" in attributes: # pragma no branch + assert attributes[ "owned_private_repos" ] is None or isinstance( attributes[ "owned_private_repos" ], int ), attributes[ "owned_private_repos" ] self._owned_private_repos = attributes[ "owned_private_repos" ] - if "plan" in attributes and attributes[ "plan" ] is not None: # pragma no branch - assert isinstance( attributes[ "plan" ], dict ), attributes[ "plan" ] - self._plan = Plan.Plan( self._requester, attributes[ "plan" ], completed = False ) - if "private_gists" in attributes and attributes[ "private_gists" ] is not None: # pragma no branch - assert isinstance( attributes[ "private_gists" ], int ), attributes[ "private_gists" ] + if "plan" in attributes: # pragma no branch + assert attributes[ "plan" ] is None or isinstance( attributes[ "plan" ], dict ), attributes[ "plan" ] + self._plan = None if attributes[ "plan" ] is None else Plan.Plan( self._requester, attributes[ "plan" ], completed = False ) + if "private_gists" in attributes: # pragma no branch + assert attributes[ "private_gists" ] is None or isinstance( attributes[ "private_gists" ], int ), attributes[ "private_gists" ] self._private_gists = attributes[ "private_gists" ] - if "public_gists" in attributes and attributes[ "public_gists" ] is not None: # pragma no branch - assert isinstance( attributes[ "public_gists" ], int ), attributes[ "public_gists" ] + if "public_gists" in attributes: # pragma no branch + assert attributes[ "public_gists" ] is None or isinstance( attributes[ "public_gists" ], int ), attributes[ "public_gists" ] self._public_gists = attributes[ "public_gists" ] - if "public_repos" in attributes and attributes[ "public_repos" ] is not None: # pragma no branch - assert isinstance( attributes[ "public_repos" ], int ), attributes[ "public_repos" ] + if "public_repos" in attributes: # pragma no branch + assert attributes[ "public_repos" ] is None or isinstance( attributes[ "public_repos" ], int ), attributes[ "public_repos" ] self._public_repos = attributes[ "public_repos" ] - if "total_private_repos" in attributes and attributes[ "total_private_repos" ] is not None: # pragma no branch - assert isinstance( attributes[ "total_private_repos" ], int ), attributes[ "total_private_repos" ] + if "total_private_repos" in attributes: # pragma no branch + assert attributes[ "total_private_repos" ] is None or isinstance( attributes[ "total_private_repos" ], int ), attributes[ "total_private_repos" ] self._total_private_repos = attributes[ "total_private_repos" ] - if "type" in attributes and attributes[ "type" ] is not None: # pragma no branch - assert isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ] + if "type" in attributes: # pragma no branch + assert attributes[ "type" ] is None or isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ] self._type = attributes[ "type" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/Organization.py b/src/github/Organization.py index 874a6310..8d177674 100644 --- a/src/github/Organization.py +++ b/src/github/Organization.py @@ -3,7 +3,6 @@ import GithubObject import PaginatedList -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import Team import Plan @@ -14,123 +13,123 @@ import NamedUser class Organization( GithubObject.GithubObject ): @property def avatar_url( self ): - self._completeIfNeeded( self._avatar_url ) - return self._avatar_url + self._completeIfNotSet( self._avatar_url ) + return self._NoneIfNotSet( self._avatar_url ) @property def billing_email( self ): - self._completeIfNeeded( self._billing_email ) - return self._billing_email + self._completeIfNotSet( self._billing_email ) + return self._NoneIfNotSet( self._billing_email ) @property def blog( self ): - self._completeIfNeeded( self._blog ) - return self._blog + self._completeIfNotSet( self._blog ) + return self._NoneIfNotSet( self._blog ) @property def collaborators( self ): - self._completeIfNeeded( self._collaborators ) - return self._collaborators + self._completeIfNotSet( self._collaborators ) + return self._NoneIfNotSet( self._collaborators ) @property def company( self ): - self._completeIfNeeded( self._company ) - return self._company + self._completeIfNotSet( self._company ) + return self._NoneIfNotSet( self._company ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def disk_usage( self ): - self._completeIfNeeded( self._disk_usage ) - return self._disk_usage + self._completeIfNotSet( self._disk_usage ) + return self._NoneIfNotSet( self._disk_usage ) @property def email( self ): - self._completeIfNeeded( self._email ) - return self._email + self._completeIfNotSet( self._email ) + return self._NoneIfNotSet( self._email ) @property def followers( self ): - self._completeIfNeeded( self._followers ) - return self._followers + self._completeIfNotSet( self._followers ) + return self._NoneIfNotSet( self._followers ) @property def following( self ): - self._completeIfNeeded( self._following ) - return self._following + self._completeIfNotSet( self._following ) + return self._NoneIfNotSet( self._following ) @property def gravatar_id( self ): - self._completeIfNeeded( self._gravatar_id ) - return self._gravatar_id + self._completeIfNotSet( self._gravatar_id ) + return self._NoneIfNotSet( self._gravatar_id ) @property def html_url( self ): - self._completeIfNeeded( self._html_url ) - return self._html_url + self._completeIfNotSet( self._html_url ) + return self._NoneIfNotSet( self._html_url ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def location( self ): - self._completeIfNeeded( self._location ) - return self._location + self._completeIfNotSet( self._location ) + return self._NoneIfNotSet( self._location ) @property def login( self ): - self._completeIfNeeded( self._login ) - return self._login + self._completeIfNotSet( self._login ) + return self._NoneIfNotSet( self._login ) @property def name( self ): - self._completeIfNeeded( self._name ) - return self._name + self._completeIfNotSet( self._name ) + return self._NoneIfNotSet( self._name ) @property def owned_private_repos( self ): - self._completeIfNeeded( self._owned_private_repos ) - return self._owned_private_repos + self._completeIfNotSet( self._owned_private_repos ) + return self._NoneIfNotSet( self._owned_private_repos ) @property def plan( self ): - self._completeIfNeeded( self._plan ) - return self._plan + self._completeIfNotSet( self._plan ) + return self._NoneIfNotSet( self._plan ) @property def private_gists( self ): - self._completeIfNeeded( self._private_gists ) - return self._private_gists + self._completeIfNotSet( self._private_gists ) + return self._NoneIfNotSet( self._private_gists ) @property def public_gists( self ): - self._completeIfNeeded( self._public_gists ) - return self._public_gists + self._completeIfNotSet( self._public_gists ) + return self._NoneIfNotSet( self._public_gists ) @property def public_repos( self ): - self._completeIfNeeded( self._public_repos ) - return self._public_repos + self._completeIfNotSet( self._public_repos ) + return self._NoneIfNotSet( self._public_repos ) @property def total_private_repos( self ): - self._completeIfNeeded( self._total_private_repos ) - return self._total_private_repos + self._completeIfNotSet( self._total_private_repos ) + return self._NoneIfNotSet( self._total_private_repos ) @property def type( self ): - self._completeIfNeeded( self._type ) - return self._type + self._completeIfNotSet( self._type ) + return self._NoneIfNotSet( self._type ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def add_to_public_members( self, public_member ): assert isinstance( public_member, NamedUser.NamedUser ), public_member @@ -156,38 +155,38 @@ class Organization( GithubObject.GithubObject ): self._checkStatus( status, data ) return Repository.Repository( self._requester, data, completed = True ) - def create_repo( self, name, description = DefaultValueForOptionalParameters, homepage = DefaultValueForOptionalParameters, private = DefaultValueForOptionalParameters, has_issues = DefaultValueForOptionalParameters, has_wiki = DefaultValueForOptionalParameters, has_downloads = DefaultValueForOptionalParameters, team_id = DefaultValueForOptionalParameters ): + def create_repo( self, name, description = GithubObject.NotSet, homepage = GithubObject.NotSet, private = GithubObject.NotSet, has_issues = GithubObject.NotSet, has_wiki = GithubObject.NotSet, has_downloads = GithubObject.NotSet, team_id = GithubObject.NotSet ): assert isinstance( name, ( str, unicode ) ), name - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: assert isinstance( description, ( str, unicode ) ), description - if homepage is not DefaultValueForOptionalParameters: + if homepage is not GithubObject.NotSet: assert isinstance( homepage, ( str, unicode ) ), homepage - if private is not DefaultValueForOptionalParameters: + if private is not GithubObject.NotSet: assert isinstance( private, bool ), private - if has_issues is not DefaultValueForOptionalParameters: + if has_issues is not GithubObject.NotSet: assert isinstance( has_issues, bool ), has_issues - if has_wiki is not DefaultValueForOptionalParameters: + if has_wiki is not GithubObject.NotSet: assert isinstance( has_wiki, bool ), has_wiki - if has_downloads is not DefaultValueForOptionalParameters: + if has_downloads is not GithubObject.NotSet: assert isinstance( has_downloads, bool ), has_downloads - if team_id is not DefaultValueForOptionalParameters: + if team_id is not GithubObject.NotSet: assert isinstance( team_id, int ), team_id post_parameters = { "name": name, } - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: post_parameters[ "description" ] = description - if homepage is not DefaultValueForOptionalParameters: + if homepage is not GithubObject.NotSet: post_parameters[ "homepage" ] = homepage - if private is not DefaultValueForOptionalParameters: + if private is not GithubObject.NotSet: post_parameters[ "private" ] = private - if has_issues is not DefaultValueForOptionalParameters: + if has_issues is not GithubObject.NotSet: post_parameters[ "has_issues" ] = has_issues - if has_wiki is not DefaultValueForOptionalParameters: + if has_wiki is not GithubObject.NotSet: post_parameters[ "has_wiki" ] = has_wiki - if has_downloads is not DefaultValueForOptionalParameters: + if has_downloads is not GithubObject.NotSet: post_parameters[ "has_downloads" ] = has_downloads - if team_id is not DefaultValueForOptionalParameters: + if team_id is not GithubObject.NotSet: post_parameters[ "team_id" ] = team_id status, headers, data = self._request( "POST", @@ -198,18 +197,18 @@ class Organization( GithubObject.GithubObject ): self._checkStatus( status, data ) return Repository.Repository( self._requester, data, completed = True ) - def create_team( self, name, repo_names = DefaultValueForOptionalParameters, permission = DefaultValueForOptionalParameters ): + def create_team( self, name, repo_names = GithubObject.NotSet, permission = GithubObject.NotSet ): assert isinstance( name, ( str, unicode ) ), name - if repo_names is not DefaultValueForOptionalParameters: + if repo_names is not GithubObject.NotSet: assert all( isinstance( element, ( str, unicode ) ) for element in repo_names ), repo_names - if permission is not DefaultValueForOptionalParameters: + if permission is not GithubObject.NotSet: assert isinstance( permission, ( str, unicode ) ), permission post_parameters = { "name": name, } - if repo_names is not DefaultValueForOptionalParameters: + if repo_names is not GithubObject.NotSet: post_parameters[ "repo_names" ] = repo_names - if permission is not DefaultValueForOptionalParameters: + if permission is not GithubObject.NotSet: post_parameters[ "permission" ] = permission status, headers, data = self._request( "POST", @@ -220,31 +219,31 @@ class Organization( GithubObject.GithubObject ): self._checkStatus( status, data ) return Team.Team( self._requester, data, completed = True ) - def edit( self, billing_email = DefaultValueForOptionalParameters, blog = DefaultValueForOptionalParameters, company = DefaultValueForOptionalParameters, email = DefaultValueForOptionalParameters, location = DefaultValueForOptionalParameters, name = DefaultValueForOptionalParameters ): - if billing_email is not DefaultValueForOptionalParameters: + def edit( self, billing_email = GithubObject.NotSet, blog = GithubObject.NotSet, company = GithubObject.NotSet, email = GithubObject.NotSet, location = GithubObject.NotSet, name = GithubObject.NotSet ): + if billing_email is not GithubObject.NotSet: assert isinstance( billing_email, ( str, unicode ) ), billing_email - if blog is not DefaultValueForOptionalParameters: + if blog is not GithubObject.NotSet: assert isinstance( blog, ( str, unicode ) ), blog - if company is not DefaultValueForOptionalParameters: + if company is not GithubObject.NotSet: assert isinstance( company, ( str, unicode ) ), company - if email is not DefaultValueForOptionalParameters: + if email is not GithubObject.NotSet: assert isinstance( email, ( str, unicode ) ), email - if location is not DefaultValueForOptionalParameters: + if location is not GithubObject.NotSet: assert isinstance( location, ( str, unicode ) ), location - if name is not DefaultValueForOptionalParameters: + if name is not GithubObject.NotSet: assert isinstance( name, ( str, unicode ) ), name post_parameters = dict() - if billing_email is not DefaultValueForOptionalParameters: + if billing_email is not GithubObject.NotSet: post_parameters[ "billing_email" ] = billing_email - if blog is not DefaultValueForOptionalParameters: + if blog is not GithubObject.NotSet: post_parameters[ "blog" ] = blog - if company is not DefaultValueForOptionalParameters: + if company is not GithubObject.NotSet: post_parameters[ "company" ] = company - if email is not DefaultValueForOptionalParameters: + if email is not GithubObject.NotSet: post_parameters[ "email" ] = email - if location is not DefaultValueForOptionalParameters: + if location is not GithubObject.NotSet: post_parameters[ "location" ] = location - if name is not DefaultValueForOptionalParameters: + if name is not GithubObject.NotSet: post_parameters[ "name" ] = name status, headers, data = self._request( "PATCH", @@ -311,11 +310,11 @@ class Organization( GithubObject.GithubObject ): self._checkStatus( status, data ) return Repository.Repository( self._requester, data, completed = True ) - def get_repos( self, type = DefaultValueForOptionalParameters ): - if type is not DefaultValueForOptionalParameters: + def get_repos( self, type = GithubObject.NotSet ): + if type is not GithubObject.NotSet: assert isinstance( type, ( str, unicode ) ), type url_parameters = dict() - if type is not DefaultValueForOptionalParameters: + if type is not GithubObject.NotSet: url_parameters[ "type" ] = type status, headers, data = self._request( "GET", @@ -398,101 +397,101 @@ class Organization( GithubObject.GithubObject ): self._checkStatus( status, data ) def _initAttributes( self ): - self._avatar_url = None - self._billing_email = None - self._blog = None - self._collaborators = None - self._company = None - self._created_at = None - self._disk_usage = None - self._email = None - self._followers = None - self._following = None - self._gravatar_id = None - self._html_url = None - self._id = None - self._location = None - self._login = None - self._name = None - self._owned_private_repos = None - self._plan = None - self._private_gists = None - self._public_gists = None - self._public_repos = None - self._total_private_repos = None - self._type = None - self._url = None + self._avatar_url = GithubObject.NotSet + self._billing_email = GithubObject.NotSet + self._blog = GithubObject.NotSet + self._collaborators = GithubObject.NotSet + self._company = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._disk_usage = GithubObject.NotSet + self._email = GithubObject.NotSet + self._followers = GithubObject.NotSet + self._following = GithubObject.NotSet + self._gravatar_id = GithubObject.NotSet + self._html_url = GithubObject.NotSet + self._id = GithubObject.NotSet + self._location = GithubObject.NotSet + self._login = GithubObject.NotSet + self._name = GithubObject.NotSet + self._owned_private_repos = GithubObject.NotSet + self._plan = GithubObject.NotSet + self._private_gists = GithubObject.NotSet + self._public_gists = GithubObject.NotSet + self._public_repos = GithubObject.NotSet + self._total_private_repos = GithubObject.NotSet + self._type = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "avatar_url" in attributes and attributes[ "avatar_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "avatar_url" ], ( str, unicode ) ), attributes[ "avatar_url" ] + if "avatar_url" in attributes: # pragma no branch + assert attributes[ "avatar_url" ] is None or isinstance( attributes[ "avatar_url" ], ( str, unicode ) ), attributes[ "avatar_url" ] self._avatar_url = attributes[ "avatar_url" ] - if "billing_email" in attributes and attributes[ "billing_email" ] is not None: # pragma no branch - assert isinstance( attributes[ "billing_email" ], ( str, unicode ) ), attributes[ "billing_email" ] + if "billing_email" in attributes: # pragma no branch + assert attributes[ "billing_email" ] is None or isinstance( attributes[ "billing_email" ], ( str, unicode ) ), attributes[ "billing_email" ] self._billing_email = attributes[ "billing_email" ] - if "blog" in attributes and attributes[ "blog" ] is not None: # pragma no branch - assert isinstance( attributes[ "blog" ], ( str, unicode ) ), attributes[ "blog" ] + if "blog" in attributes: # pragma no branch + assert attributes[ "blog" ] is None or isinstance( attributes[ "blog" ], ( str, unicode ) ), attributes[ "blog" ] self._blog = attributes[ "blog" ] - if "collaborators" in attributes and attributes[ "collaborators" ] is not None: # pragma no branch - assert isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ] + if "collaborators" in attributes: # pragma no branch + assert attributes[ "collaborators" ] is None or isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ] self._collaborators = attributes[ "collaborators" ] - if "company" in attributes and attributes[ "company" ] is not None: # pragma no branch - assert isinstance( attributes[ "company" ], ( str, unicode ) ), attributes[ "company" ] + if "company" in attributes: # pragma no branch + assert attributes[ "company" ] is None or isinstance( attributes[ "company" ], ( str, unicode ) ), attributes[ "company" ] self._company = attributes[ "company" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "disk_usage" in attributes and attributes[ "disk_usage" ] is not None: # pragma no branch - assert isinstance( attributes[ "disk_usage" ], int ), attributes[ "disk_usage" ] + 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" ] - if "email" in attributes and attributes[ "email" ] is not None: # pragma no branch - assert isinstance( attributes[ "email" ], ( str, unicode ) ), attributes[ "email" ] + if "email" in attributes: # pragma no branch + assert attributes[ "email" ] is None or isinstance( attributes[ "email" ], ( str, unicode ) ), attributes[ "email" ] self._email = attributes[ "email" ] - if "followers" in attributes and attributes[ "followers" ] is not None: # pragma no branch - assert isinstance( attributes[ "followers" ], int ), attributes[ "followers" ] + if "followers" in attributes: # pragma no branch + assert attributes[ "followers" ] is None or isinstance( attributes[ "followers" ], int ), attributes[ "followers" ] self._followers = attributes[ "followers" ] - if "following" in attributes and attributes[ "following" ] is not None: # pragma no branch - assert isinstance( attributes[ "following" ], int ), attributes[ "following" ] + if "following" in attributes: # pragma no branch + assert attributes[ "following" ] is None or isinstance( attributes[ "following" ], int ), attributes[ "following" ] self._following = attributes[ "following" ] - if "gravatar_id" in attributes and attributes[ "gravatar_id" ] is not None: # pragma no branch - assert isinstance( attributes[ "gravatar_id" ], ( str, unicode ) ), attributes[ "gravatar_id" ] + if "gravatar_id" in attributes: # pragma no branch + assert attributes[ "gravatar_id" ] is None or isinstance( attributes[ "gravatar_id" ], ( str, unicode ) ), attributes[ "gravatar_id" ] self._gravatar_id = attributes[ "gravatar_id" ] - if "html_url" in attributes and attributes[ "html_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ] + 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" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "location" in attributes and attributes[ "location" ] is not None: # pragma no branch - assert isinstance( attributes[ "location" ], ( str, unicode ) ), attributes[ "location" ] + if "location" in attributes: # pragma no branch + assert attributes[ "location" ] is None or isinstance( attributes[ "location" ], ( str, unicode ) ), attributes[ "location" ] self._location = attributes[ "location" ] - if "login" in attributes and attributes[ "login" ] is not None: # pragma no branch - assert isinstance( attributes[ "login" ], ( str, unicode ) ), attributes[ "login" ] + if "login" in attributes: # pragma no branch + assert attributes[ "login" ] is None or isinstance( attributes[ "login" ], ( str, unicode ) ), attributes[ "login" ] self._login = attributes[ "login" ] - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] - if "owned_private_repos" in attributes and attributes[ "owned_private_repos" ] is not None: # pragma no branch - assert isinstance( attributes[ "owned_private_repos" ], int ), attributes[ "owned_private_repos" ] + if "owned_private_repos" in attributes: # pragma no branch + assert attributes[ "owned_private_repos" ] is None or isinstance( attributes[ "owned_private_repos" ], int ), attributes[ "owned_private_repos" ] self._owned_private_repos = attributes[ "owned_private_repos" ] - if "plan" in attributes and attributes[ "plan" ] is not None: # pragma no branch - assert isinstance( attributes[ "plan" ], dict ), attributes[ "plan" ] - self._plan = Plan.Plan( self._requester, attributes[ "plan" ], completed = False ) - if "private_gists" in attributes and attributes[ "private_gists" ] is not None: # pragma no branch - assert isinstance( attributes[ "private_gists" ], int ), attributes[ "private_gists" ] + if "plan" in attributes: # pragma no branch + assert attributes[ "plan" ] is None or isinstance( attributes[ "plan" ], dict ), attributes[ "plan" ] + self._plan = None if attributes[ "plan" ] is None else Plan.Plan( self._requester, attributes[ "plan" ], completed = False ) + if "private_gists" in attributes: # pragma no branch + assert attributes[ "private_gists" ] is None or isinstance( attributes[ "private_gists" ], int ), attributes[ "private_gists" ] self._private_gists = attributes[ "private_gists" ] - if "public_gists" in attributes and attributes[ "public_gists" ] is not None: # pragma no branch - assert isinstance( attributes[ "public_gists" ], int ), attributes[ "public_gists" ] + if "public_gists" in attributes: # pragma no branch + assert attributes[ "public_gists" ] is None or isinstance( attributes[ "public_gists" ], int ), attributes[ "public_gists" ] self._public_gists = attributes[ "public_gists" ] - if "public_repos" in attributes and attributes[ "public_repos" ] is not None: # pragma no branch - assert isinstance( attributes[ "public_repos" ], int ), attributes[ "public_repos" ] + if "public_repos" in attributes: # pragma no branch + assert attributes[ "public_repos" ] is None or isinstance( attributes[ "public_repos" ], int ), attributes[ "public_repos" ] self._public_repos = attributes[ "public_repos" ] - if "total_private_repos" in attributes and attributes[ "total_private_repos" ] is not None: # pragma no branch - assert isinstance( attributes[ "total_private_repos" ], int ), attributes[ "total_private_repos" ] + if "total_private_repos" in attributes: # pragma no branch + assert attributes[ "total_private_repos" ] is None or isinstance( attributes[ "total_private_repos" ], int ), attributes[ "total_private_repos" ] self._total_private_repos = attributes[ "total_private_repos" ] - if "type" in attributes and attributes[ "type" ] is not None: # pragma no branch - assert isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ] + if "type" in attributes: # pragma no branch + assert attributes[ "type" ] is None or isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ] self._type = attributes[ "type" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/Permissions.py b/src/github/Permissions.py index 91b2c4c1..b7a28eca 100644 --- a/src/github/Permissions.py +++ b/src/github/Permissions.py @@ -6,28 +6,28 @@ import GithubObject class Permissions( GithubObject.BasicGithubObject ): @property def admin( self ): - return self._admin + return self._NoneIfNotSet( self._admin ) @property def pull( self ): - return self._pull + return self._NoneIfNotSet( self._pull ) @property def push( self ): - return self._push + return self._NoneIfNotSet( self._push ) def _initAttributes( self ): - self._admin = None - self._pull = None - self._push = None + self._admin = GithubObject.NotSet + self._pull = GithubObject.NotSet + self._push = GithubObject.NotSet def _useAttributes( self, attributes ): - if "admin" in attributes and attributes[ "admin" ] is not None: # pragma no branch - assert isinstance( attributes[ "admin" ], bool ), attributes[ "admin" ] + if "admin" in attributes: # pragma no branch + assert attributes[ "admin" ] is None or isinstance( attributes[ "admin" ], bool ), attributes[ "admin" ] self._admin = attributes[ "admin" ] - if "pull" in attributes and attributes[ "pull" ] is not None: # pragma no branch - assert isinstance( attributes[ "pull" ], bool ), attributes[ "pull" ] + if "pull" in attributes: # pragma no branch + assert attributes[ "pull" ] is None or isinstance( attributes[ "pull" ], bool ), attributes[ "pull" ] self._pull = attributes[ "pull" ] - if "push" in attributes and attributes[ "push" ] is not None: # pragma no branch - assert isinstance( attributes[ "push" ], bool ), attributes[ "push" ] + if "push" in attributes: # pragma no branch + assert attributes[ "push" ] is None or isinstance( attributes[ "push" ], bool ), attributes[ "push" ] self._push = attributes[ "push" ] diff --git a/src/github/Plan.py b/src/github/Plan.py index b344fae7..b574225c 100644 --- a/src/github/Plan.py +++ b/src/github/Plan.py @@ -6,36 +6,36 @@ import GithubObject class Plan( GithubObject.BasicGithubObject ): @property def collaborators( self ): - return self._collaborators + return self._NoneIfNotSet( self._collaborators ) @property def name( self ): - return self._name + return self._NoneIfNotSet( self._name ) @property def private_repos( self ): - return self._private_repos + return self._NoneIfNotSet( self._private_repos ) @property def space( self ): - return self._space + return self._NoneIfNotSet( self._space ) def _initAttributes( self ): - self._collaborators = None - self._name = None - self._private_repos = None - self._space = None + self._collaborators = GithubObject.NotSet + self._name = GithubObject.NotSet + self._private_repos = GithubObject.NotSet + self._space = GithubObject.NotSet def _useAttributes( self, attributes ): - if "collaborators" in attributes and attributes[ "collaborators" ] is not None: # pragma no branch - assert isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ] + if "collaborators" in attributes: # pragma no branch + assert attributes[ "collaborators" ] is None or isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ] self._collaborators = attributes[ "collaborators" ] - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] - if "private_repos" in attributes and attributes[ "private_repos" ] is not None: # pragma no branch - assert isinstance( attributes[ "private_repos" ], int ), attributes[ "private_repos" ] + if "private_repos" in attributes: # pragma no branch + assert attributes[ "private_repos" ] is None or isinstance( attributes[ "private_repos" ], int ), attributes[ "private_repos" ] self._private_repos = attributes[ "private_repos" ] - if "space" in attributes and attributes[ "space" ] is not None: # pragma no branch - assert isinstance( attributes[ "space" ], int ), attributes[ "space" ] + if "space" in attributes: # pragma no branch + assert attributes[ "space" ] is None or isinstance( attributes[ "space" ], int ), attributes[ "space" ] self._space = attributes[ "space" ] diff --git a/src/github/PullRequest.py b/src/github/PullRequest.py index 0911c32f..9e132c00 100644 --- a/src/github/PullRequest.py +++ b/src/github/PullRequest.py @@ -3,7 +3,6 @@ import GithubObject import PaginatedList -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import Commit import NamedUser @@ -14,133 +13,133 @@ import PullRequestFile class PullRequest( GithubObject.GithubObject ): @property def additions( self ): - self._completeIfNeeded( self._additions ) - return self._additions + self._completeIfNotSet( self._additions ) + return self._NoneIfNotSet( self._additions ) @property def base( self ): - self._completeIfNeeded( self._base ) - return self._base + self._completeIfNotSet( self._base ) + return self._NoneIfNotSet( self._base ) @property def body( self ): - self._completeIfNeeded( self._body ) - return self._body + self._completeIfNotSet( self._body ) + return self._NoneIfNotSet( self._body ) @property def changed_files( self ): - self._completeIfNeeded( self._changed_files ) - return self._changed_files + self._completeIfNotSet( self._changed_files ) + return self._NoneIfNotSet( self._changed_files ) @property def closed_at( self ): - self._completeIfNeeded( self._closed_at ) - return self._closed_at + self._completeIfNotSet( self._closed_at ) + return self._NoneIfNotSet( self._closed_at ) @property def comments( self ): - self._completeIfNeeded( self._comments ) - return self._comments + self._completeIfNotSet( self._comments ) + return self._NoneIfNotSet( self._comments ) @property def commits( self ): - self._completeIfNeeded( self._commits ) - return self._commits + self._completeIfNotSet( self._commits ) + return self._NoneIfNotSet( self._commits ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def deletions( self ): - self._completeIfNeeded( self._deletions ) - return self._deletions + self._completeIfNotSet( self._deletions ) + return self._NoneIfNotSet( self._deletions ) @property def diff_url( self ): - self._completeIfNeeded( self._diff_url ) - return self._diff_url + self._completeIfNotSet( self._diff_url ) + return self._NoneIfNotSet( self._diff_url ) @property def head( self ): - self._completeIfNeeded( self._head ) - return self._head + self._completeIfNotSet( self._head ) + return self._NoneIfNotSet( self._head ) @property def html_url( self ): - self._completeIfNeeded( self._html_url ) - return self._html_url + self._completeIfNotSet( self._html_url ) + return self._NoneIfNotSet( self._html_url ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def issue_url( self ): - self._completeIfNeeded( self._issue_url ) - return self._issue_url + self._completeIfNotSet( self._issue_url ) + return self._NoneIfNotSet( self._issue_url ) @property def mergeable( self ): - self._completeIfNeeded( self._mergeable ) - return self._mergeable + self._completeIfNotSet( self._mergeable ) + return self._NoneIfNotSet( self._mergeable ) @property def merged( self ): - self._completeIfNeeded( self._merged ) - return self._merged + self._completeIfNotSet( self._merged ) + return self._NoneIfNotSet( self._merged ) @property def merged_at( self ): - self._completeIfNeeded( self._merged_at ) - return self._merged_at + self._completeIfNotSet( self._merged_at ) + return self._NoneIfNotSet( self._merged_at ) @property def merged_by( self ): - self._completeIfNeeded( self._merged_by ) - return self._merged_by + self._completeIfNotSet( self._merged_by ) + return self._NoneIfNotSet( self._merged_by ) @property def number( self ): - self._completeIfNeeded( self._number ) - return self._number + self._completeIfNotSet( self._number ) + return self._NoneIfNotSet( self._number ) @property def patch_url( self ): - self._completeIfNeeded( self._patch_url ) - return self._patch_url + self._completeIfNotSet( self._patch_url ) + return self._NoneIfNotSet( self._patch_url ) @property def review_comments( self ): - self._completeIfNeeded( self._review_comments ) - return self._review_comments + self._completeIfNotSet( self._review_comments ) + return self._NoneIfNotSet( self._review_comments ) @property def state( self ): - self._completeIfNeeded( self._state ) - return self._state + self._completeIfNotSet( self._state ) + return self._NoneIfNotSet( self._state ) @property def title( self ): - self._completeIfNeeded( self._title ) - return self._title + self._completeIfNotSet( self._title ) + return self._NoneIfNotSet( self._title ) @property def updated_at( self ): - self._completeIfNeeded( self._updated_at ) - return self._updated_at + self._completeIfNotSet( self._updated_at ) + return self._NoneIfNotSet( self._updated_at ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) @property def user( self ): - self._completeIfNeeded( self._user ) - return self._user + self._completeIfNotSet( self._user ) + return self._NoneIfNotSet( self._user ) def create_comment( self, body, commit_id, path, position ): assert isinstance( body, ( str, unicode ) ), body @@ -162,19 +161,19 @@ class PullRequest( GithubObject.GithubObject ): self._checkStatus( status, data ) return PullRequestComment.PullRequestComment( self._requester, data, completed = True ) - def edit( self, title = DefaultValueForOptionalParameters, body = DefaultValueForOptionalParameters, state = DefaultValueForOptionalParameters ): - if title is not DefaultValueForOptionalParameters: + def edit( self, title = GithubObject.NotSet, body = GithubObject.NotSet, state = GithubObject.NotSet ): + if title is not GithubObject.NotSet: assert isinstance( title, ( str, unicode ) ), title - if body is not DefaultValueForOptionalParameters: + if body is not GithubObject.NotSet: assert isinstance( body, ( str, unicode ) ), body - if state is not DefaultValueForOptionalParameters: + if state is not GithubObject.NotSet: assert isinstance( state, ( str, unicode ) ), state post_parameters = dict() - if title is not DefaultValueForOptionalParameters: + if title is not GithubObject.NotSet: post_parameters[ "title" ] = title - if body is not DefaultValueForOptionalParameters: + if body is not GithubObject.NotSet: post_parameters[ "body" ] = body - if state is not DefaultValueForOptionalParameters: + if state is not GithubObject.NotSet: post_parameters[ "state" ] = state status, headers, data = self._request( "PATCH", @@ -250,11 +249,11 @@ class PullRequest( GithubObject.GithubObject ): ) return status == 204 - def merge( self, commit_message = DefaultValueForOptionalParameters ): - if commit_message is not DefaultValueForOptionalParameters: + def merge( self, commit_message = GithubObject.NotSet ): + if commit_message is not GithubObject.NotSet: assert isinstance( commit_message, ( str, unicode ) ), commit_message post_parameters = dict() - if commit_message is not DefaultValueForOptionalParameters: + if commit_message is not GithubObject.NotSet: post_parameters[ "commit_message" ] = commit_message status, headers, data = self._request( "PUT", @@ -266,107 +265,107 @@ class PullRequest( GithubObject.GithubObject ): return PullRequestMergeStatus.PullRequestMergeStatus( self._requester, data, completed = True ) def _initAttributes( self ): - self._additions = None - self._base = None - self._body = None - self._changed_files = None - self._closed_at = None - self._comments = None - self._commits = None - self._created_at = None - self._deletions = None - self._diff_url = None - self._head = None - self._html_url = None - self._id = None - self._issue_url = None - self._mergeable = None - self._merged = None - self._merged_at = None - self._merged_by = None - self._number = None - self._patch_url = None - self._review_comments = None - self._state = None - self._title = None - self._updated_at = None - self._url = None - self._user = None + self._additions = GithubObject.NotSet + self._base = GithubObject.NotSet + self._body = GithubObject.NotSet + self._changed_files = GithubObject.NotSet + self._closed_at = GithubObject.NotSet + self._comments = GithubObject.NotSet + self._commits = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._deletions = GithubObject.NotSet + self._diff_url = GithubObject.NotSet + self._head = GithubObject.NotSet + self._html_url = GithubObject.NotSet + self._id = GithubObject.NotSet + self._issue_url = GithubObject.NotSet + self._mergeable = GithubObject.NotSet + self._merged = GithubObject.NotSet + self._merged_at = GithubObject.NotSet + self._merged_by = GithubObject.NotSet + self._number = GithubObject.NotSet + self._patch_url = GithubObject.NotSet + self._review_comments = GithubObject.NotSet + self._state = GithubObject.NotSet + self._title = GithubObject.NotSet + self._updated_at = GithubObject.NotSet + self._url = GithubObject.NotSet + self._user = GithubObject.NotSet def _useAttributes( self, attributes ): - if "additions" in attributes and attributes[ "additions" ] is not None: # pragma no branch - assert isinstance( attributes[ "additions" ], int ), attributes[ "additions" ] + if "additions" in attributes: # pragma no branch + assert attributes[ "additions" ] is None or isinstance( attributes[ "additions" ], int ), attributes[ "additions" ] self._additions = attributes[ "additions" ] - if "base" in attributes and attributes[ "base" ] is not None: # pragma no branch + if "base" in attributes: # pragma no branch self._base = attributes[ "base" ] - if "body" in attributes and attributes[ "body" ] is not None: # pragma no branch - assert isinstance( attributes[ "body" ], ( str, unicode ) ), attributes[ "body" ] + if "body" in attributes: # pragma no branch + assert attributes[ "body" ] is None or isinstance( attributes[ "body" ], ( str, unicode ) ), attributes[ "body" ] self._body = attributes[ "body" ] - if "changed_files" in attributes and attributes[ "changed_files" ] is not None: # pragma no branch - assert isinstance( attributes[ "changed_files" ], int ), attributes[ "changed_files" ] + if "changed_files" in attributes: # pragma no branch + assert attributes[ "changed_files" ] is None or isinstance( attributes[ "changed_files" ], int ), attributes[ "changed_files" ] self._changed_files = attributes[ "changed_files" ] - if "closed_at" in attributes and attributes[ "closed_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "closed_at" ], ( str, unicode ) ), attributes[ "closed_at" ] + 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 = attributes[ "closed_at" ] - if "comments" in attributes and attributes[ "comments" ] is not None: # pragma no branch - assert isinstance( attributes[ "comments" ], int ), attributes[ "comments" ] + if "comments" in attributes: # pragma no branch + assert attributes[ "comments" ] is None or isinstance( attributes[ "comments" ], int ), attributes[ "comments" ] self._comments = attributes[ "comments" ] - if "commits" in attributes and attributes[ "commits" ] is not None: # pragma no branch - assert isinstance( attributes[ "commits" ], int ), attributes[ "commits" ] + if "commits" in attributes: # pragma no branch + assert attributes[ "commits" ] is None or isinstance( attributes[ "commits" ], int ), attributes[ "commits" ] self._commits = attributes[ "commits" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "deletions" in attributes and attributes[ "deletions" ] is not None: # pragma no branch - assert isinstance( attributes[ "deletions" ], int ), attributes[ "deletions" ] + if "deletions" in attributes: # pragma no branch + assert attributes[ "deletions" ] is None or isinstance( attributes[ "deletions" ], int ), attributes[ "deletions" ] self._deletions = attributes[ "deletions" ] - if "diff_url" in attributes and attributes[ "diff_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "diff_url" ], ( str, unicode ) ), attributes[ "diff_url" ] + if "diff_url" in attributes: # pragma no branch + assert attributes[ "diff_url" ] is None or isinstance( attributes[ "diff_url" ], ( str, unicode ) ), attributes[ "diff_url" ] self._diff_url = attributes[ "diff_url" ] - if "head" in attributes and attributes[ "head" ] is not None: # pragma no branch + if "head" in attributes: # pragma no branch self._head = attributes[ "head" ] - if "html_url" in attributes and attributes[ "html_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ] + 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" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "issue_url" in attributes and attributes[ "issue_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "issue_url" ], ( str, unicode ) ), attributes[ "issue_url" ] + if "issue_url" in attributes: # pragma no branch + assert attributes[ "issue_url" ] is None or isinstance( attributes[ "issue_url" ], ( str, unicode ) ), attributes[ "issue_url" ] self._issue_url = attributes[ "issue_url" ] - if "mergeable" in attributes and attributes[ "mergeable" ] is not None: # pragma no branch - assert isinstance( attributes[ "mergeable" ], bool ), attributes[ "mergeable" ] + if "mergeable" in attributes: # pragma no branch + assert attributes[ "mergeable" ] is None or isinstance( attributes[ "mergeable" ], bool ), attributes[ "mergeable" ] self._mergeable = attributes[ "mergeable" ] - if "merged" in attributes and attributes[ "merged" ] is not None: # pragma no branch - assert isinstance( attributes[ "merged" ], bool ), attributes[ "merged" ] + if "merged" in attributes: # pragma no branch + assert attributes[ "merged" ] is None or isinstance( attributes[ "merged" ], bool ), attributes[ "merged" ] self._merged = attributes[ "merged" ] - if "merged_at" in attributes and attributes[ "merged_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "merged_at" ], ( str, unicode ) ), attributes[ "merged_at" ] + 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 = attributes[ "merged_at" ] - if "merged_by" in attributes and attributes[ "merged_by" ] is not None: # pragma no branch - assert isinstance( attributes[ "merged_by" ], dict ), attributes[ "merged_by" ] - self._merged_by = NamedUser.NamedUser( self._requester, attributes[ "merged_by" ], completed = False ) - if "number" in attributes and attributes[ "number" ] is not None: # pragma no branch - assert isinstance( attributes[ "number" ], int ), attributes[ "number" ] + 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 ) + if "number" in attributes: # pragma no branch + assert attributes[ "number" ] is None or isinstance( attributes[ "number" ], int ), attributes[ "number" ] self._number = attributes[ "number" ] - if "patch_url" in attributes and attributes[ "patch_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "patch_url" ], ( str, unicode ) ), attributes[ "patch_url" ] + if "patch_url" in attributes: # pragma no branch + assert attributes[ "patch_url" ] is None or isinstance( attributes[ "patch_url" ], ( str, unicode ) ), attributes[ "patch_url" ] self._patch_url = attributes[ "patch_url" ] - if "review_comments" in attributes and attributes[ "review_comments" ] is not None: # pragma no branch - assert isinstance( attributes[ "review_comments" ], int ), attributes[ "review_comments" ] + if "review_comments" in attributes: # pragma no branch + assert attributes[ "review_comments" ] is None or isinstance( attributes[ "review_comments" ], int ), attributes[ "review_comments" ] self._review_comments = attributes[ "review_comments" ] - if "state" in attributes and attributes[ "state" ] is not None: # pragma no branch - assert isinstance( attributes[ "state" ], ( str, unicode ) ), attributes[ "state" ] + if "state" in attributes: # pragma no branch + assert attributes[ "state" ] is None or isinstance( attributes[ "state" ], ( str, unicode ) ), attributes[ "state" ] self._state = attributes[ "state" ] - if "title" in attributes and attributes[ "title" ] is not None: # pragma no branch - assert isinstance( attributes[ "title" ], ( str, unicode ) ), attributes[ "title" ] + if "title" in attributes: # pragma no branch + assert attributes[ "title" ] is None or isinstance( attributes[ "title" ], ( str, unicode ) ), attributes[ "title" ] self._title = attributes[ "title" ] - if "updated_at" in attributes and attributes[ "updated_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ] + 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 = attributes[ "updated_at" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "url" in attributes: # pragma no branch + assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] self._url = attributes[ "url" ] - if "user" in attributes and attributes[ "user" ] is not None: # pragma no branch - assert isinstance( attributes[ "user" ], dict ), attributes[ "user" ] - self._user = NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) + if "user" in attributes: # pragma no branch + assert attributes[ "user" ] is None or isinstance( attributes[ "user" ], dict ), attributes[ "user" ] + self._user = None if attributes[ "user" ] is None else NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) diff --git a/src/github/PullRequestComment.py b/src/github/PullRequestComment.py index d7224496..ad272ae2 100644 --- a/src/github/PullRequestComment.py +++ b/src/github/PullRequestComment.py @@ -8,58 +8,58 @@ import NamedUser class PullRequestComment( GithubObject.GithubObject ): @property def body( self ): - self._completeIfNeeded( self._body ) - return self._body + self._completeIfNotSet( self._body ) + return self._NoneIfNotSet( self._body ) @property def commit_id( self ): - self._completeIfNeeded( self._commit_id ) - return self._commit_id + self._completeIfNotSet( self._commit_id ) + return self._NoneIfNotSet( self._commit_id ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def original_commit_id( self ): - self._completeIfNeeded( self._original_commit_id ) - return self._original_commit_id + self._completeIfNotSet( self._original_commit_id ) + return self._NoneIfNotSet( self._original_commit_id ) @property def original_position( self ): - self._completeIfNeeded( self._original_position ) - return self._original_position + self._completeIfNotSet( self._original_position ) + return self._NoneIfNotSet( self._original_position ) @property def path( self ): - self._completeIfNeeded( self._path ) - return self._path + self._completeIfNotSet( self._path ) + return self._NoneIfNotSet( self._path ) @property def position( self ): - self._completeIfNeeded( self._position ) - return self._position + self._completeIfNotSet( self._position ) + return self._NoneIfNotSet( self._position ) @property def updated_at( self ): - self._completeIfNeeded( self._updated_at ) - return self._updated_at + self._completeIfNotSet( self._updated_at ) + return self._NoneIfNotSet( self._updated_at ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) @property def user( self ): - self._completeIfNeeded( self._user ) - return self._user + self._completeIfNotSet( self._user ) + return self._NoneIfNotSet( self._user ) def delete( self ): status, headers, data = self._request( @@ -85,49 +85,49 @@ class PullRequestComment( GithubObject.GithubObject ): self._useAttributes( data ) def _initAttributes( self ): - self._body = None - self._commit_id = None - self._created_at = None - self._id = None - self._original_commit_id = None - self._original_position = None - self._path = None - self._position = None - self._updated_at = None - self._url = None - self._user = None + self._body = GithubObject.NotSet + self._commit_id = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._id = GithubObject.NotSet + self._original_commit_id = GithubObject.NotSet + self._original_position = GithubObject.NotSet + self._path = GithubObject.NotSet + self._position = GithubObject.NotSet + self._updated_at = GithubObject.NotSet + self._url = GithubObject.NotSet + self._user = GithubObject.NotSet def _useAttributes( self, attributes ): - if "body" in attributes and attributes[ "body" ] is not None: # pragma no branch - assert isinstance( attributes[ "body" ], ( str, unicode ) ), attributes[ "body" ] + if "body" in attributes: # pragma no branch + assert attributes[ "body" ] is None or isinstance( attributes[ "body" ], ( str, unicode ) ), attributes[ "body" ] self._body = attributes[ "body" ] - if "commit_id" in attributes and attributes[ "commit_id" ] is not None: # pragma no branch - assert isinstance( attributes[ "commit_id" ], ( str, unicode ) ), attributes[ "commit_id" ] + if "commit_id" in attributes: # pragma no branch + assert attributes[ "commit_id" ] is None or isinstance( attributes[ "commit_id" ], ( str, unicode ) ), attributes[ "commit_id" ] self._commit_id = attributes[ "commit_id" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "original_commit_id" in attributes and attributes[ "original_commit_id" ] is not None: # pragma no branch - assert isinstance( attributes[ "original_commit_id" ], ( str, unicode ) ), attributes[ "original_commit_id" ] + if "original_commit_id" in attributes: # pragma no branch + assert attributes[ "original_commit_id" ] is None or isinstance( attributes[ "original_commit_id" ], ( str, unicode ) ), attributes[ "original_commit_id" ] self._original_commit_id = attributes[ "original_commit_id" ] - if "original_position" in attributes and attributes[ "original_position" ] is not None: # pragma no branch - assert isinstance( attributes[ "original_position" ], int ), attributes[ "original_position" ] + if "original_position" in attributes: # pragma no branch + assert attributes[ "original_position" ] is None or isinstance( attributes[ "original_position" ], int ), attributes[ "original_position" ] self._original_position = attributes[ "original_position" ] - if "path" in attributes and attributes[ "path" ] is not None: # pragma no branch - assert isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ] + if "path" in attributes: # pragma no branch + assert attributes[ "path" ] is None or isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ] self._path = attributes[ "path" ] - if "position" in attributes and attributes[ "position" ] is not None: # pragma no branch - assert isinstance( attributes[ "position" ], int ), attributes[ "position" ] + if "position" in attributes: # pragma no branch + assert attributes[ "position" ] is None or isinstance( attributes[ "position" ], int ), attributes[ "position" ] self._position = attributes[ "position" ] - if "updated_at" in attributes and attributes[ "updated_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ] + 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 = attributes[ "updated_at" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "url" in attributes: # pragma no branch + assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] self._url = attributes[ "url" ] - if "user" in attributes and attributes[ "user" ] is not None: # pragma no branch - assert isinstance( attributes[ "user" ], dict ), attributes[ "user" ] - self._user = NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) + if "user" in attributes: # pragma no branch + assert attributes[ "user" ] is None or isinstance( attributes[ "user" ], dict ), attributes[ "user" ] + self._user = None if attributes[ "user" ] is None else NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False ) diff --git a/src/github/PullRequestFile.py b/src/github/PullRequestFile.py index 419332eb..2d1016a6 100644 --- a/src/github/PullRequestFile.py +++ b/src/github/PullRequestFile.py @@ -6,76 +6,76 @@ import GithubObject class PullRequestFile( GithubObject.BasicGithubObject ): @property def additions( self ): - return self._additions + return self._NoneIfNotSet( self._additions ) @property def blob_url( self ): - return self._blob_url + return self._NoneIfNotSet( self._blob_url ) @property def changes( self ): - return self._changes + return self._NoneIfNotSet( self._changes ) @property def deletions( self ): - return self._deletions + return self._NoneIfNotSet( self._deletions ) @property def filename( self ): - return self._filename + return self._NoneIfNotSet( self._filename ) @property def patch( self ): - return self._patch + return self._NoneIfNotSet( self._patch ) @property def raw_url( self ): - return self._raw_url + return self._NoneIfNotSet( self._raw_url ) @property def sha( self ): - return self._sha + return self._NoneIfNotSet( self._sha ) @property def status( self ): - return self._status + return self._NoneIfNotSet( self._status ) def _initAttributes( self ): - self._additions = None - self._blob_url = None - self._changes = None - self._deletions = None - self._filename = None - self._patch = None - self._raw_url = None - self._sha = None - self._status = None + self._additions = GithubObject.NotSet + self._blob_url = GithubObject.NotSet + self._changes = GithubObject.NotSet + self._deletions = GithubObject.NotSet + self._filename = GithubObject.NotSet + self._patch = GithubObject.NotSet + self._raw_url = GithubObject.NotSet + self._sha = GithubObject.NotSet + self._status = GithubObject.NotSet def _useAttributes( self, attributes ): - if "additions" in attributes and attributes[ "additions" ] is not None: # pragma no branch - assert isinstance( attributes[ "additions" ], int ), attributes[ "additions" ] + if "additions" in attributes: # pragma no branch + assert attributes[ "additions" ] is None or isinstance( attributes[ "additions" ], int ), attributes[ "additions" ] self._additions = attributes[ "additions" ] - if "blob_url" in attributes and attributes[ "blob_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "blob_url" ], ( str, unicode ) ), attributes[ "blob_url" ] + if "blob_url" in attributes: # pragma no branch + assert attributes[ "blob_url" ] is None or isinstance( attributes[ "blob_url" ], ( str, unicode ) ), attributes[ "blob_url" ] self._blob_url = attributes[ "blob_url" ] - if "changes" in attributes and attributes[ "changes" ] is not None: # pragma no branch - assert isinstance( attributes[ "changes" ], int ), attributes[ "changes" ] + if "changes" in attributes: # pragma no branch + assert attributes[ "changes" ] is None or isinstance( attributes[ "changes" ], int ), attributes[ "changes" ] self._changes = attributes[ "changes" ] - if "deletions" in attributes and attributes[ "deletions" ] is not None: # pragma no branch - assert isinstance( attributes[ "deletions" ], int ), attributes[ "deletions" ] + if "deletions" in attributes: # pragma no branch + assert attributes[ "deletions" ] is None or isinstance( attributes[ "deletions" ], int ), attributes[ "deletions" ] self._deletions = attributes[ "deletions" ] - if "filename" in attributes and attributes[ "filename" ] is not None: # pragma no branch - assert isinstance( attributes[ "filename" ], ( str, unicode ) ), attributes[ "filename" ] + if "filename" in attributes: # pragma no branch + assert attributes[ "filename" ] is None or isinstance( attributes[ "filename" ], ( str, unicode ) ), attributes[ "filename" ] self._filename = attributes[ "filename" ] - if "patch" in attributes and attributes[ "patch" ] is not None: # pragma no branch - assert isinstance( attributes[ "patch" ], ( str, unicode ) ), attributes[ "patch" ] + if "patch" in attributes: # pragma no branch + assert attributes[ "patch" ] is None or isinstance( attributes[ "patch" ], ( str, unicode ) ), attributes[ "patch" ] self._patch = attributes[ "patch" ] - if "raw_url" in attributes and attributes[ "raw_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "raw_url" ], ( str, unicode ) ), attributes[ "raw_url" ] + if "raw_url" in attributes: # pragma no branch + assert attributes[ "raw_url" ] is None or isinstance( attributes[ "raw_url" ], ( str, unicode ) ), attributes[ "raw_url" ] self._raw_url = attributes[ "raw_url" ] - if "sha" in attributes and attributes[ "sha" ] is not None: # pragma no branch - assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] + if "sha" in attributes: # pragma no branch + assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] self._sha = attributes[ "sha" ] - if "status" in attributes and attributes[ "status" ] is not None: # pragma no branch - assert isinstance( attributes[ "status" ], ( str, unicode ) ), attributes[ "status" ] + if "status" in attributes: # pragma no branch + assert attributes[ "status" ] is None or isinstance( attributes[ "status" ], ( str, unicode ) ), attributes[ "status" ] self._status = attributes[ "status" ] diff --git a/src/github/PullRequestMergeStatus.py b/src/github/PullRequestMergeStatus.py index 32f788da..d8f74935 100644 --- a/src/github/PullRequestMergeStatus.py +++ b/src/github/PullRequestMergeStatus.py @@ -6,28 +6,28 @@ import GithubObject class PullRequestMergeStatus( GithubObject.BasicGithubObject ): @property def merged( self ): - return self._merged + return self._NoneIfNotSet( self._merged ) @property def message( self ): - return self._message + return self._NoneIfNotSet( self._message ) @property def sha( self ): - return self._sha + return self._NoneIfNotSet( self._sha ) def _initAttributes( self ): - self._merged = None - self._message = None - self._sha = None + self._merged = GithubObject.NotSet + self._message = GithubObject.NotSet + self._sha = GithubObject.NotSet def _useAttributes( self, attributes ): - if "merged" in attributes and attributes[ "merged" ] is not None: # pragma no branch - assert isinstance( attributes[ "merged" ], bool ), attributes[ "merged" ] + if "merged" in attributes: # pragma no branch + assert attributes[ "merged" ] is None or isinstance( attributes[ "merged" ], bool ), attributes[ "merged" ] self._merged = attributes[ "merged" ] - if "message" in attributes and attributes[ "message" ] is not None: # pragma no branch - assert isinstance( attributes[ "message" ], ( str, unicode ) ), attributes[ "message" ] + if "message" in attributes: # pragma no branch + assert attributes[ "message" ] is None or isinstance( attributes[ "message" ], ( str, unicode ) ), attributes[ "message" ] self._message = attributes[ "message" ] - if "sha" in attributes and attributes[ "sha" ] is not None: # pragma no branch - assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] + if "sha" in attributes: # pragma no branch + assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] self._sha = attributes[ "sha" ] diff --git a/src/github/Repository.py b/src/github/Repository.py index 3da025bd..b3c442ec 100644 --- a/src/github/Repository.py +++ b/src/github/Repository.py @@ -5,7 +5,6 @@ import urllib ########## import GithubObject import PaginatedList -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import Branch import IssueEvent @@ -34,153 +33,153 @@ import Event class Repository( GithubObject.GithubObject ): @property def clone_url( self ): - self._completeIfNeeded( self._clone_url ) - return self._clone_url + self._completeIfNotSet( self._clone_url ) + return self._NoneIfNotSet( self._clone_url ) @property def created_at( self ): - self._completeIfNeeded( self._created_at ) - return self._created_at + self._completeIfNotSet( self._created_at ) + return self._NoneIfNotSet( self._created_at ) @property def description( self ): - self._completeIfNeeded( self._description ) - return self._description + self._completeIfNotSet( self._description ) + return self._NoneIfNotSet( self._description ) @property def fork( self ): - self._completeIfNeeded( self._fork ) - return self._fork + self._completeIfNotSet( self._fork ) + return self._NoneIfNotSet( self._fork ) @property def forks( self ): - self._completeIfNeeded( self._forks ) - return self._forks + self._completeIfNotSet( self._forks ) + return self._NoneIfNotSet( self._forks ) @property def full_name( self ): - self._completeIfNeeded( self._full_name ) - return self._full_name + self._completeIfNotSet( self._full_name ) + return self._NoneIfNotSet( self._full_name ) @property def git_url( self ): - self._completeIfNeeded( self._git_url ) - return self._git_url + self._completeIfNotSet( self._git_url ) + return self._NoneIfNotSet( self._git_url ) @property def has_downloads( self ): - self._completeIfNeeded( self._has_downloads ) - return self._has_downloads + self._completeIfNotSet( self._has_downloads ) + return self._NoneIfNotSet( self._has_downloads ) @property def has_issues( self ): - self._completeIfNeeded( self._has_issues ) - return self._has_issues + self._completeIfNotSet( self._has_issues ) + return self._NoneIfNotSet( self._has_issues ) @property def has_wiki( self ): - self._completeIfNeeded( self._has_wiki ) - return self._has_wiki + self._completeIfNotSet( self._has_wiki ) + return self._NoneIfNotSet( self._has_wiki ) @property def homepage( self ): - self._completeIfNeeded( self._homepage ) - return self._homepage + self._completeIfNotSet( self._homepage ) + return self._NoneIfNotSet( self._homepage ) @property def html_url( self ): - self._completeIfNeeded( self._html_url ) - return self._html_url + self._completeIfNotSet( self._html_url ) + return self._NoneIfNotSet( self._html_url ) @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def language( self ): - self._completeIfNeeded( self._language ) - return self._language + self._completeIfNotSet( self._language ) + return self._NoneIfNotSet( self._language ) @property def master_branch( self ): - self._completeIfNeeded( self._master_branch ) - return self._master_branch + self._completeIfNotSet( self._master_branch ) + return self._NoneIfNotSet( self._master_branch ) @property def name( self ): - self._completeIfNeeded( self._name ) - return self._name + self._completeIfNotSet( self._name ) + return self._NoneIfNotSet( self._name ) @property def open_issues( self ): - self._completeIfNeeded( self._open_issues ) - return self._open_issues + self._completeIfNotSet( self._open_issues ) + return self._NoneIfNotSet( self._open_issues ) @property def organization( self ): - self._completeIfNeeded( self._organization ) - return self._organization + self._completeIfNotSet( self._organization ) + return self._NoneIfNotSet( self._organization ) @property def owner( self ): - self._completeIfNeeded( self._owner ) - return self._owner + self._completeIfNotSet( self._owner ) + return self._NoneIfNotSet( self._owner ) @property def parent( self ): - self._completeIfNeeded( self._parent ) - return self._parent + self._completeIfNotSet( self._parent ) + return self._NoneIfNotSet( self._parent ) @property def permissions( self ): - self._completeIfNeeded( self._permissions ) - return self._permissions + self._completeIfNotSet( self._permissions ) + return self._NoneIfNotSet( self._permissions ) @property def private( self ): - self._completeIfNeeded( self._private ) - return self._private + self._completeIfNotSet( self._private ) + return self._NoneIfNotSet( self._private ) @property def pushed_at( self ): - self._completeIfNeeded( self._pushed_at ) - return self._pushed_at + self._completeIfNotSet( self._pushed_at ) + return self._NoneIfNotSet( self._pushed_at ) @property def size( self ): - self._completeIfNeeded( self._size ) - return self._size + self._completeIfNotSet( self._size ) + return self._NoneIfNotSet( self._size ) @property def source( self ): - self._completeIfNeeded( self._source ) - return self._source + self._completeIfNotSet( self._source ) + return self._NoneIfNotSet( self._source ) @property def ssh_url( self ): - self._completeIfNeeded( self._ssh_url ) - return self._ssh_url + self._completeIfNotSet( self._ssh_url ) + return self._NoneIfNotSet( self._ssh_url ) @property def svn_url( self ): - self._completeIfNeeded( self._svn_url ) - return self._svn_url + self._completeIfNotSet( self._svn_url ) + return self._NoneIfNotSet( self._svn_url ) @property def updated_at( self ): - self._completeIfNeeded( self._updated_at ) - return self._updated_at + self._completeIfNotSet( self._updated_at ) + return self._NoneIfNotSet( self._updated_at ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) @property def watchers( self ): - self._completeIfNeeded( self._watchers ) - return self._watchers + self._completeIfNotSet( self._watchers ) + return self._NoneIfNotSet( self._watchers ) def add_to_collaborators( self, collaborator ): assert isinstance( collaborator, NamedUser.NamedUser ), collaborator @@ -204,20 +203,20 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return data - def create_download( self, name, size, description = DefaultValueForOptionalParameters, content_type = DefaultValueForOptionalParameters ): + def create_download( self, name, size, description = GithubObject.NotSet, content_type = GithubObject.NotSet ): assert isinstance( name, ( str, unicode ) ), name assert isinstance( size, int ), size - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: assert isinstance( description, ( str, unicode ) ), description - if content_type is not DefaultValueForOptionalParameters: + if content_type is not GithubObject.NotSet: assert isinstance( content_type, ( str, unicode ) ), content_type post_parameters = { "name": name, "size": size, } - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: post_parameters[ "description" ] = description - if content_type is not DefaultValueForOptionalParameters: + if content_type is not GithubObject.NotSet: post_parameters[ "content_type" ] = content_type status, headers, data = self._request( "POST", @@ -244,7 +243,7 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return GitBlob.GitBlob( self._requester, data, completed = True ) - def create_git_commit( self, message, tree, parents, author = DefaultValueForOptionalParameters, committer = DefaultValueForOptionalParameters ): + def create_git_commit( self, message, tree, parents, author = GithubObject.NotSet, committer = GithubObject.NotSet ): assert isinstance( message, ( str, unicode ) ), message assert all( isinstance( element, GitCommit.GitCommit ) for element in parents ), parents post_parameters = { @@ -252,9 +251,9 @@ class Repository( GithubObject.GithubObject ): "tree": tree, "parents": parents, } - if author is not DefaultValueForOptionalParameters: + if author is not GithubObject.NotSet: post_parameters[ "author" ] = author - if committer is not DefaultValueForOptionalParameters: + if committer is not GithubObject.NotSet: post_parameters[ "committer" ] = committer status, headers, data = self._request( "POST", @@ -281,7 +280,7 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return GitRef.GitRef( self._requester, data, completed = True ) - def create_git_tag( self, tag, message, object, type, tagger = DefaultValueForOptionalParameters ): + def create_git_tag( self, tag, message, object, type, tagger = GithubObject.NotSet ): assert isinstance( tag, ( str, unicode ) ), tag assert isinstance( message, ( str, unicode ) ), message assert isinstance( object, ( str, unicode ) ), object @@ -292,7 +291,7 @@ class Repository( GithubObject.GithubObject ): "object": object, "type": type, } - if tagger is not DefaultValueForOptionalParameters: + if tagger is not GithubObject.NotSet: post_parameters[ "tagger" ] = tagger status, headers, data = self._request( "POST", @@ -303,11 +302,11 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return GitTag.GitTag( self._requester, data, completed = True ) - def create_git_tree( self, tree, base_tree = DefaultValueForOptionalParameters ): + def create_git_tree( self, tree, base_tree = GithubObject.NotSet ): post_parameters = { "tree": tree, } - if base_tree is not DefaultValueForOptionalParameters: + if base_tree is not GithubObject.NotSet: post_parameters[ "base_tree" ] = base_tree status, headers, data = self._request( "POST", @@ -318,19 +317,19 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return GitTree.GitTree( self._requester, data, completed = True ) - def create_hook( self, name, config, events = DefaultValueForOptionalParameters, active = DefaultValueForOptionalParameters ): + def create_hook( self, name, config, events = GithubObject.NotSet, active = GithubObject.NotSet ): assert isinstance( name, ( str, unicode ) ), name - if events is not DefaultValueForOptionalParameters: + if events is not GithubObject.NotSet: assert all( isinstance( element, ( str, unicode ) ) for element in events ), events - if active is not DefaultValueForOptionalParameters: + if active is not GithubObject.NotSet: assert isinstance( active, bool ), active post_parameters = { "name": name, "config": config, } - if events is not DefaultValueForOptionalParameters: + if events is not GithubObject.NotSet: post_parameters[ "events" ] = events - if active is not DefaultValueForOptionalParameters: + if active is not GithubObject.NotSet: post_parameters[ "active" ] = active status, headers, data = self._request( "POST", @@ -341,26 +340,26 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return Hook.Hook( self._requester, data, completed = True ) - def create_issue( self, title, body = DefaultValueForOptionalParameters, assignee = DefaultValueForOptionalParameters, milestone = DefaultValueForOptionalParameters, labels = DefaultValueForOptionalParameters ): + def create_issue( self, title, body = GithubObject.NotSet, assignee = GithubObject.NotSet, milestone = GithubObject.NotSet, labels = GithubObject.NotSet ): assert isinstance( title, ( str, unicode ) ), title - if body is not DefaultValueForOptionalParameters: + if body is not GithubObject.NotSet: assert isinstance( body, ( str, unicode ) ), body - if assignee is not DefaultValueForOptionalParameters: + if assignee is not GithubObject.NotSet: assert isinstance( assignee, ( str, unicode ) ), assignee - if milestone is not DefaultValueForOptionalParameters: + if milestone is not GithubObject.NotSet: assert isinstance( milestone, int ), milestone - if labels is not DefaultValueForOptionalParameters: + if labels is not GithubObject.NotSet: assert all( isinstance( element, ( str, unicode ) ) for element in labels ), labels post_parameters = { "title": title, } - if body is not DefaultValueForOptionalParameters: + if body is not GithubObject.NotSet: post_parameters[ "body" ] = body - if assignee is not DefaultValueForOptionalParameters: + if assignee is not GithubObject.NotSet: post_parameters[ "assignee" ] = assignee - if milestone is not DefaultValueForOptionalParameters: + if milestone is not GithubObject.NotSet: post_parameters[ "milestone" ] = milestone - if labels is not DefaultValueForOptionalParameters: + if labels is not GithubObject.NotSet: post_parameters[ "labels" ] = labels status, headers, data = self._request( "POST", @@ -403,22 +402,22 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return Label.Label( self._requester, data, completed = True ) - def create_milestone( self, title, state = DefaultValueForOptionalParameters, description = DefaultValueForOptionalParameters, due_on = DefaultValueForOptionalParameters ): + def create_milestone( self, title, state = GithubObject.NotSet, description = GithubObject.NotSet, due_on = GithubObject.NotSet ): assert isinstance( title, ( str, unicode ) ), title - if state is not DefaultValueForOptionalParameters: + if state is not GithubObject.NotSet: assert isinstance( state, ( str, unicode ) ), state - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: assert isinstance( description, ( str, unicode ) ), description - if due_on is not DefaultValueForOptionalParameters: + if due_on is not GithubObject.NotSet: assert isinstance( due_on, ( str, unicode ) ), due_on post_parameters = { "title": title, } - if state is not DefaultValueForOptionalParameters: + if state is not GithubObject.NotSet: post_parameters[ "state" ] = state - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: post_parameters[ "description" ] = description - if due_on is not DefaultValueForOptionalParameters: + if due_on is not GithubObject.NotSet: post_parameters[ "due_on" ] = due_on status, headers, data = self._request( "POST", @@ -455,34 +454,34 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return PullRequest.PullRequest( self._requester, data, completed = True ) - def edit( self, name, description = DefaultValueForOptionalParameters, homepage = DefaultValueForOptionalParameters, public = DefaultValueForOptionalParameters, has_issues = DefaultValueForOptionalParameters, has_wiki = DefaultValueForOptionalParameters, has_downloads = DefaultValueForOptionalParameters ): + def edit( self, name, description = GithubObject.NotSet, homepage = GithubObject.NotSet, public = GithubObject.NotSet, has_issues = GithubObject.NotSet, has_wiki = GithubObject.NotSet, has_downloads = GithubObject.NotSet ): assert isinstance( name, ( str, unicode ) ), name - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: assert isinstance( description, ( str, unicode ) ), description - if homepage is not DefaultValueForOptionalParameters: + if homepage is not GithubObject.NotSet: assert isinstance( homepage, ( str, unicode ) ), homepage - if public is not DefaultValueForOptionalParameters: + if public is not GithubObject.NotSet: assert isinstance( public, bool ), public - if has_issues is not DefaultValueForOptionalParameters: + if has_issues is not GithubObject.NotSet: assert isinstance( has_issues, bool ), has_issues - if has_wiki is not DefaultValueForOptionalParameters: + if has_wiki is not GithubObject.NotSet: assert isinstance( has_wiki, bool ), has_wiki - if has_downloads is not DefaultValueForOptionalParameters: + if has_downloads is not GithubObject.NotSet: assert isinstance( has_downloads, bool ), has_downloads post_parameters = { "name": name, } - if description is not DefaultValueForOptionalParameters: + if description is not GithubObject.NotSet: post_parameters[ "description" ] = description - if homepage is not DefaultValueForOptionalParameters: + if homepage is not GithubObject.NotSet: post_parameters[ "homepage" ] = homepage - if public is not DefaultValueForOptionalParameters: + if public is not GithubObject.NotSet: post_parameters[ "public" ] = public - if has_issues is not DefaultValueForOptionalParameters: + if has_issues is not GithubObject.NotSet: post_parameters[ "has_issues" ] = has_issues - if has_wiki is not DefaultValueForOptionalParameters: + if has_wiki is not GithubObject.NotSet: post_parameters[ "has_wiki" ] = has_wiki - if has_downloads is not DefaultValueForOptionalParameters: + if has_downloads is not GithubObject.NotSet: post_parameters[ "has_downloads" ] = has_downloads status, headers, data = self._request( "PATCH", @@ -560,15 +559,15 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return Commit.Commit( self._requester, data, completed = True ) - def get_commits( self, sha = DefaultValueForOptionalParameters, path = DefaultValueForOptionalParameters ): - if sha is not DefaultValueForOptionalParameters: + def get_commits( self, sha = GithubObject.NotSet, path = GithubObject.NotSet ): + if sha is not GithubObject.NotSet: assert isinstance( sha, ( str, unicode ) ), sha - if path is not DefaultValueForOptionalParameters: + if path is not GithubObject.NotSet: assert isinstance( path, ( str, unicode ) ), path url_parameters = dict() - if sha is not DefaultValueForOptionalParameters: + if sha is not GithubObject.NotSet: url_parameters[ "sha" ] = sha - if path is not DefaultValueForOptionalParameters: + if path is not GithubObject.NotSet: url_parameters[ "path" ] = path status, headers, data = self._request( "GET", @@ -714,12 +713,12 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return GitTag.GitTag( self._requester, data, completed = True ) - def get_git_tree( self, sha, recursive = DefaultValueForOptionalParameters ): + def get_git_tree( self, sha, recursive = GithubObject.NotSet ): assert isinstance( sha, ( str, unicode ) ), sha - if recursive is not DefaultValueForOptionalParameters: + if recursive is not GithubObject.NotSet: assert isinstance( recursive, bool ), recursive url_parameters = dict() - if recursive is not DefaultValueForOptionalParameters: + if recursive is not GithubObject.NotSet: url_parameters[ "recursive" ] = recursive status, headers, data = self._request( "GET", @@ -767,39 +766,39 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return Issue.Issue( self._requester, data, completed = True ) - def get_issues( self, milestone = DefaultValueForOptionalParameters, state = DefaultValueForOptionalParameters, assignee = DefaultValueForOptionalParameters, mentioned = DefaultValueForOptionalParameters, labels = DefaultValueForOptionalParameters, sort = DefaultValueForOptionalParameters, direction = DefaultValueForOptionalParameters, since = DefaultValueForOptionalParameters ): - if milestone is not DefaultValueForOptionalParameters: + def get_issues( self, milestone = GithubObject.NotSet, state = GithubObject.NotSet, assignee = GithubObject.NotSet, mentioned = GithubObject.NotSet, labels = GithubObject.NotSet, sort = GithubObject.NotSet, direction = GithubObject.NotSet, since = GithubObject.NotSet ): + if milestone is not GithubObject.NotSet: assert isinstance( milestone, int ), milestone - if state is not DefaultValueForOptionalParameters: + if state is not GithubObject.NotSet: assert isinstance( state, ( str, unicode ) ), state - if assignee is not DefaultValueForOptionalParameters: + if assignee is not GithubObject.NotSet: assert isinstance( assignee, ( str, unicode ) ), assignee - if mentioned is not DefaultValueForOptionalParameters: + if mentioned is not GithubObject.NotSet: assert isinstance( mentioned, ( str, unicode ) ), mentioned - if labels is not DefaultValueForOptionalParameters: + if labels is not GithubObject.NotSet: assert isinstance( labels, ( str, unicode ) ), labels - if sort is not DefaultValueForOptionalParameters: + if sort is not GithubObject.NotSet: assert isinstance( sort, ( str, unicode ) ), sort - if direction is not DefaultValueForOptionalParameters: + if direction is not GithubObject.NotSet: assert isinstance( direction, ( str, unicode ) ), direction - if since is not DefaultValueForOptionalParameters: + if since is not GithubObject.NotSet: assert isinstance( since, ( str, unicode ) ), since url_parameters = dict() - if milestone is not DefaultValueForOptionalParameters: + if milestone is not GithubObject.NotSet: url_parameters[ "milestone" ] = milestone - if state is not DefaultValueForOptionalParameters: + if state is not GithubObject.NotSet: url_parameters[ "state" ] = state - if assignee is not DefaultValueForOptionalParameters: + if assignee is not GithubObject.NotSet: url_parameters[ "assignee" ] = assignee - if mentioned is not DefaultValueForOptionalParameters: + if mentioned is not GithubObject.NotSet: url_parameters[ "mentioned" ] = mentioned - if labels is not DefaultValueForOptionalParameters: + if labels is not GithubObject.NotSet: url_parameters[ "labels" ] = labels - if sort is not DefaultValueForOptionalParameters: + if sort is not GithubObject.NotSet: url_parameters[ "sort" ] = sort - if direction is not DefaultValueForOptionalParameters: + if direction is not GithubObject.NotSet: url_parameters[ "direction" ] = direction - if since is not DefaultValueForOptionalParameters: + if since is not GithubObject.NotSet: url_parameters[ "since" ] = since status, headers, data = self._request( "GET", @@ -914,19 +913,19 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return Milestone.Milestone( self._requester, data, completed = True ) - def get_milestones( self, state = DefaultValueForOptionalParameters, sort = DefaultValueForOptionalParameters, direction = DefaultValueForOptionalParameters ): - if state is not DefaultValueForOptionalParameters: + def get_milestones( self, state = GithubObject.NotSet, sort = GithubObject.NotSet, direction = GithubObject.NotSet ): + if state is not GithubObject.NotSet: assert isinstance( state, ( str, unicode ) ), state - if sort is not DefaultValueForOptionalParameters: + if sort is not GithubObject.NotSet: assert isinstance( sort, ( str, unicode ) ), sort - if direction is not DefaultValueForOptionalParameters: + if direction is not GithubObject.NotSet: assert isinstance( direction, ( str, unicode ) ), direction url_parameters = dict() - if state is not DefaultValueForOptionalParameters: + if state is not GithubObject.NotSet: url_parameters[ "state" ] = state - if sort is not DefaultValueForOptionalParameters: + if sort is not GithubObject.NotSet: url_parameters[ "sort" ] = sort - if direction is not DefaultValueForOptionalParameters: + if direction is not GithubObject.NotSet: url_parameters[ "direction" ] = direction status, headers, data = self._request( "GET", @@ -968,11 +967,11 @@ class Repository( GithubObject.GithubObject ): self._checkStatus( status, data ) return PullRequest.PullRequest( self._requester, data, completed = True ) - def get_pulls( self, state = DefaultValueForOptionalParameters ): - if state is not DefaultValueForOptionalParameters: + def get_pulls( self, state = GithubObject.NotSet ): + if state is not GithubObject.NotSet: assert isinstance( state, ( str, unicode ) ), state url_parameters = dict() - if state is not DefaultValueForOptionalParameters: + if state is not GithubObject.NotSet: url_parameters[ "state" ] = state status, headers, data = self._request( "GET", @@ -1058,125 +1057,125 @@ class Repository( GithubObject.GithubObject ): return str( self.owner.login ) + "/" + str( self.name ) def _initAttributes( self ): - self._clone_url = None - self._created_at = None - self._description = None - self._fork = None - self._forks = None - self._full_name = None - self._git_url = None - self._has_downloads = None - self._has_issues = None - self._has_wiki = None - self._homepage = None - self._html_url = None - self._id = None - self._language = None - self._master_branch = None - self._name = None - self._open_issues = None - self._organization = None - self._owner = None - self._parent = None - self._permissions = None - self._private = None - self._pushed_at = None - self._size = None - self._source = None - self._ssh_url = None - self._svn_url = None - self._updated_at = None - self._url = None - self._watchers = None + self._clone_url = GithubObject.NotSet + self._created_at = GithubObject.NotSet + self._description = GithubObject.NotSet + self._fork = GithubObject.NotSet + self._forks = GithubObject.NotSet + self._full_name = GithubObject.NotSet + self._git_url = GithubObject.NotSet + self._has_downloads = GithubObject.NotSet + self._has_issues = GithubObject.NotSet + self._has_wiki = GithubObject.NotSet + self._homepage = GithubObject.NotSet + self._html_url = GithubObject.NotSet + self._id = GithubObject.NotSet + self._language = GithubObject.NotSet + self._master_branch = GithubObject.NotSet + self._name = GithubObject.NotSet + self._open_issues = GithubObject.NotSet + self._organization = GithubObject.NotSet + self._owner = GithubObject.NotSet + self._parent = GithubObject.NotSet + self._permissions = GithubObject.NotSet + self._private = GithubObject.NotSet + self._pushed_at = GithubObject.NotSet + self._size = GithubObject.NotSet + self._source = GithubObject.NotSet + self._ssh_url = GithubObject.NotSet + self._svn_url = GithubObject.NotSet + self._updated_at = GithubObject.NotSet + self._url = GithubObject.NotSet + self._watchers = GithubObject.NotSet def _useAttributes( self, attributes ): - if "clone_url" in attributes and attributes[ "clone_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "clone_url" ], ( str, unicode ) ), attributes[ "clone_url" ] + if "clone_url" in attributes: # pragma no branch + assert attributes[ "clone_url" ] is None or isinstance( attributes[ "clone_url" ], ( str, unicode ) ), attributes[ "clone_url" ] self._clone_url = attributes[ "clone_url" ] - if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ] + 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 = attributes[ "created_at" ] - if "description" in attributes and attributes[ "description" ] is not None: # pragma no branch - assert isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ] + if "description" in attributes: # pragma no branch + assert attributes[ "description" ] is None or isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ] self._description = attributes[ "description" ] - if "fork" in attributes and attributes[ "fork" ] is not None: # pragma no branch - assert isinstance( attributes[ "fork" ], bool ), attributes[ "fork" ] + if "fork" in attributes: # pragma no branch + assert attributes[ "fork" ] is None or isinstance( attributes[ "fork" ], bool ), attributes[ "fork" ] self._fork = attributes[ "fork" ] - if "forks" in attributes and attributes[ "forks" ] is not None: # pragma no branch - assert isinstance( attributes[ "forks" ], int ), attributes[ "forks" ] + if "forks" in attributes: # pragma no branch + assert attributes[ "forks" ] is None or isinstance( attributes[ "forks" ], int ), attributes[ "forks" ] self._forks = attributes[ "forks" ] - if "full_name" in attributes and attributes[ "full_name" ] is not None: # pragma no branch - assert isinstance( attributes[ "full_name" ], ( str, unicode ) ), attributes[ "full_name" ] + if "full_name" in attributes: # pragma no branch + assert attributes[ "full_name" ] is None or isinstance( attributes[ "full_name" ], ( str, unicode ) ), attributes[ "full_name" ] self._full_name = attributes[ "full_name" ] - if "git_url" in attributes and attributes[ "git_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "git_url" ], ( str, unicode ) ), attributes[ "git_url" ] + if "git_url" in attributes: # pragma no branch + assert attributes[ "git_url" ] is None or isinstance( attributes[ "git_url" ], ( str, unicode ) ), attributes[ "git_url" ] self._git_url = attributes[ "git_url" ] - if "has_downloads" in attributes and attributes[ "has_downloads" ] is not None: # pragma no branch - assert isinstance( attributes[ "has_downloads" ], bool ), attributes[ "has_downloads" ] + if "has_downloads" in attributes: # pragma no branch + assert attributes[ "has_downloads" ] is None or isinstance( attributes[ "has_downloads" ], bool ), attributes[ "has_downloads" ] self._has_downloads = attributes[ "has_downloads" ] - if "has_issues" in attributes and attributes[ "has_issues" ] is not None: # pragma no branch - assert isinstance( attributes[ "has_issues" ], bool ), attributes[ "has_issues" ] + if "has_issues" in attributes: # pragma no branch + assert attributes[ "has_issues" ] is None or isinstance( attributes[ "has_issues" ], bool ), attributes[ "has_issues" ] self._has_issues = attributes[ "has_issues" ] - if "has_wiki" in attributes and attributes[ "has_wiki" ] is not None: # pragma no branch - assert isinstance( attributes[ "has_wiki" ], bool ), attributes[ "has_wiki" ] + if "has_wiki" in attributes: # pragma no branch + assert attributes[ "has_wiki" ] is None or isinstance( attributes[ "has_wiki" ], bool ), attributes[ "has_wiki" ] self._has_wiki = attributes[ "has_wiki" ] - if "homepage" in attributes and attributes[ "homepage" ] is not None: # pragma no branch - assert isinstance( attributes[ "homepage" ], ( str, unicode ) ), attributes[ "homepage" ] + if "homepage" in attributes: # pragma no branch + assert attributes[ "homepage" ] is None or isinstance( attributes[ "homepage" ], ( str, unicode ) ), attributes[ "homepage" ] self._homepage = attributes[ "homepage" ] - if "html_url" in attributes and attributes[ "html_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ] + 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" ] - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "language" in attributes and attributes[ "language" ] is not None: # pragma no branch - assert isinstance( attributes[ "language" ], ( str, unicode ) ), attributes[ "language" ] + if "language" in attributes: # pragma no branch + assert attributes[ "language" ] is None or isinstance( attributes[ "language" ], ( str, unicode ) ), attributes[ "language" ] self._language = attributes[ "language" ] - if "master_branch" in attributes and attributes[ "master_branch" ] is not None: # pragma no branch - assert isinstance( attributes[ "master_branch" ], ( str, unicode ) ), attributes[ "master_branch" ] + if "master_branch" in attributes: # pragma no branch + assert attributes[ "master_branch" ] is None or isinstance( attributes[ "master_branch" ], ( str, unicode ) ), attributes[ "master_branch" ] self._master_branch = attributes[ "master_branch" ] - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] - if "open_issues" in attributes and attributes[ "open_issues" ] is not None: # pragma no branch - assert isinstance( attributes[ "open_issues" ], int ), attributes[ "open_issues" ] + if "open_issues" in attributes: # pragma no branch + assert attributes[ "open_issues" ] is None or isinstance( attributes[ "open_issues" ], int ), attributes[ "open_issues" ] self._open_issues = attributes[ "open_issues" ] - if "organization" in attributes and attributes[ "organization" ] is not None: # pragma no branch - assert isinstance( attributes[ "organization" ], dict ), attributes[ "organization" ] - self._organization = Organization.Organization( self._requester, attributes[ "organization" ], completed = False ) - if "owner" in attributes and attributes[ "owner" ] is not None: # pragma no branch - assert isinstance( attributes[ "owner" ], dict ), attributes[ "owner" ] - self._owner = NamedUser.NamedUser( self._requester, attributes[ "owner" ], completed = False ) - if "parent" in attributes and attributes[ "parent" ] is not None: # pragma no branch - assert isinstance( attributes[ "parent" ], dict ), attributes[ "parent" ] - self._parent = Repository( self._requester, attributes[ "parent" ], completed = False ) - if "permissions" in attributes and attributes[ "permissions" ] is not None: # pragma no branch - assert isinstance( attributes[ "permissions" ], dict ), attributes[ "permissions" ] - self._permissions = Permissions.Permissions( self._requester, attributes[ "permissions" ], completed = False ) - if "private" in attributes and attributes[ "private" ] is not None: # pragma no branch - assert isinstance( attributes[ "private" ], bool ), attributes[ "private" ] + if "organization" in attributes: # pragma no branch + assert attributes[ "organization" ] is None or isinstance( attributes[ "organization" ], dict ), attributes[ "organization" ] + self._organization = None if attributes[ "organization" ] is None else Organization.Organization( self._requester, attributes[ "organization" ], completed = False ) + if "owner" in attributes: # pragma no branch + assert attributes[ "owner" ] is None or isinstance( attributes[ "owner" ], dict ), attributes[ "owner" ] + self._owner = None if attributes[ "owner" ] is None else NamedUser.NamedUser( self._requester, attributes[ "owner" ], completed = False ) + if "parent" in attributes: # pragma no branch + assert attributes[ "parent" ] is None or isinstance( attributes[ "parent" ], dict ), attributes[ "parent" ] + self._parent = None if attributes[ "parent" ] is None else Repository( self._requester, attributes[ "parent" ], completed = False ) + if "permissions" in attributes: # pragma no branch + assert attributes[ "permissions" ] is None or isinstance( attributes[ "permissions" ], dict ), attributes[ "permissions" ] + self._permissions = None if attributes[ "permissions" ] is None else Permissions.Permissions( self._requester, attributes[ "permissions" ], completed = False ) + if "private" in attributes: # pragma no branch + assert attributes[ "private" ] is None or isinstance( attributes[ "private" ], bool ), attributes[ "private" ] self._private = attributes[ "private" ] - if "pushed_at" in attributes and attributes[ "pushed_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "pushed_at" ], ( str, unicode ) ), attributes[ "pushed_at" ] + 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 = attributes[ "pushed_at" ] - if "size" in attributes and attributes[ "size" ] is not None: # pragma no branch - assert isinstance( attributes[ "size" ], int ), attributes[ "size" ] + if "size" in attributes: # pragma no branch + assert attributes[ "size" ] is None or isinstance( attributes[ "size" ], int ), attributes[ "size" ] self._size = attributes[ "size" ] - if "source" in attributes and attributes[ "source" ] is not None: # pragma no branch - assert isinstance( attributes[ "source" ], dict ), attributes[ "source" ] - self._source = Repository( self._requester, attributes[ "source" ], completed = False ) - if "ssh_url" in attributes and attributes[ "ssh_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "ssh_url" ], ( str, unicode ) ), attributes[ "ssh_url" ] + if "source" in attributes: # pragma no branch + assert attributes[ "source" ] is None or isinstance( attributes[ "source" ], dict ), attributes[ "source" ] + self._source = None if attributes[ "source" ] is None else Repository( self._requester, attributes[ "source" ], completed = False ) + if "ssh_url" in attributes: # pragma no branch + assert attributes[ "ssh_url" ] is None or isinstance( attributes[ "ssh_url" ], ( str, unicode ) ), attributes[ "ssh_url" ] self._ssh_url = attributes[ "ssh_url" ] - if "svn_url" in attributes and attributes[ "svn_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "svn_url" ], ( str, unicode ) ), attributes[ "svn_url" ] + if "svn_url" in attributes: # pragma no branch + assert attributes[ "svn_url" ] is None or isinstance( attributes[ "svn_url" ], ( str, unicode ) ), attributes[ "svn_url" ] self._svn_url = attributes[ "svn_url" ] - if "updated_at" in attributes and attributes[ "updated_at" ] is not None: # pragma no branch - assert isinstance( attributes[ "updated_at" ], ( str, unicode ) ), attributes[ "updated_at" ] + 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 = attributes[ "updated_at" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "url" in attributes: # pragma no branch + assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] self._url = attributes[ "url" ] - if "watchers" in attributes and attributes[ "watchers" ] is not None: # pragma no branch - assert isinstance( attributes[ "watchers" ], int ), attributes[ "watchers" ] + if "watchers" in attributes: # pragma no branch + assert attributes[ "watchers" ] is None or isinstance( attributes[ "watchers" ], int ), attributes[ "watchers" ] self._watchers = attributes[ "watchers" ] diff --git a/src/github/RepositoryKey.py b/src/github/RepositoryKey.py index 12b55dc1..8e0dfe6c 100644 --- a/src/github/RepositoryKey.py +++ b/src/github/RepositoryKey.py @@ -2,7 +2,6 @@ # Do not modify it manually, your work would be lost. import GithubObject -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters class RepositoryKey( GithubObject.GithubObject ): def __init__( self, requester, attributes, completed, repoUrl ): @@ -15,28 +14,28 @@ class RepositoryKey( GithubObject.GithubObject ): @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def key( self ): - self._completeIfNeeded( self._key ) - return self._key + self._completeIfNotSet( self._key ) + return self._NoneIfNotSet( self._key ) @property def title( self ): - self._completeIfNeeded( self._title ) - return self._title + self._completeIfNotSet( self._title ) + return self._NoneIfNotSet( self._title ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) @property def verified( self ): - self._completeIfNeeded( self._verified ) - return self._verified + self._completeIfNotSet( self._verified ) + return self._NoneIfNotSet( self._verified ) def delete( self ): status, headers, data = self._request( @@ -47,15 +46,15 @@ class RepositoryKey( GithubObject.GithubObject ): ) self._checkStatus( status, data ) - def edit( self, title = DefaultValueForOptionalParameters, key = DefaultValueForOptionalParameters ): - if title is not DefaultValueForOptionalParameters: + def edit( self, title = GithubObject.NotSet, key = GithubObject.NotSet ): + if title is not GithubObject.NotSet: assert isinstance( title, ( str, unicode ) ), title - if key is not DefaultValueForOptionalParameters: + if key is not GithubObject.NotSet: assert isinstance( key, ( str, unicode ) ), key post_parameters = dict() - if title is not DefaultValueForOptionalParameters: + if title is not GithubObject.NotSet: post_parameters[ "title" ] = title - if key is not DefaultValueForOptionalParameters: + if key is not GithubObject.NotSet: post_parameters[ "key" ] = key status, headers, data = self._request( "PATCH", @@ -67,25 +66,25 @@ class RepositoryKey( GithubObject.GithubObject ): self._useAttributes( data ) def _initAttributes( self ): - self._id = None - self._key = None - self._title = None - self._url = None - self._verified = None + self._id = GithubObject.NotSet + self._key = GithubObject.NotSet + self._title = GithubObject.NotSet + self._url = GithubObject.NotSet + self._verified = GithubObject.NotSet def _useAttributes( self, attributes ): - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "key" in attributes and attributes[ "key" ] is not None: # pragma no branch - assert isinstance( attributes[ "key" ], ( str, unicode ) ), attributes[ "key" ] + if "key" in attributes: # pragma no branch + assert attributes[ "key" ] is None or isinstance( attributes[ "key" ], ( str, unicode ) ), attributes[ "key" ] self._key = attributes[ "key" ] - if "title" in attributes and attributes[ "title" ] is not None: # pragma no branch - assert isinstance( attributes[ "title" ], ( str, unicode ) ), attributes[ "title" ] + if "title" in attributes: # pragma no branch + assert attributes[ "title" ] is None or isinstance( attributes[ "title" ], ( str, unicode ) ), attributes[ "title" ] self._title = attributes[ "title" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "url" in attributes: # pragma no branch + assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] self._url = attributes[ "url" ] - if "verified" in attributes and attributes[ "verified" ] is not None: # pragma no branch - assert isinstance( attributes[ "verified" ], bool ), attributes[ "verified" ] + if "verified" in attributes: # pragma no branch + assert attributes[ "verified" ] is None or isinstance( attributes[ "verified" ], bool ), attributes[ "verified" ] self._verified = attributes[ "verified" ] diff --git a/src/github/Tag.py b/src/github/Tag.py index 59561240..dd58ed1e 100644 --- a/src/github/Tag.py +++ b/src/github/Tag.py @@ -8,36 +8,36 @@ import Commit class Tag( GithubObject.BasicGithubObject ): @property def commit( self ): - return self._commit + return self._NoneIfNotSet( self._commit ) @property def name( self ): - return self._name + return self._NoneIfNotSet( self._name ) @property def tarball_url( self ): - return self._tarball_url + return self._NoneIfNotSet( self._tarball_url ) @property def zipball_url( self ): - return self._zipball_url + return self._NoneIfNotSet( self._zipball_url ) def _initAttributes( self ): - self._commit = None - self._name = None - self._tarball_url = None - self._zipball_url = None + self._commit = GithubObject.NotSet + self._name = GithubObject.NotSet + self._tarball_url = GithubObject.NotSet + self._zipball_url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "commit" in attributes and attributes[ "commit" ] is not None: # pragma no branch - assert isinstance( attributes[ "commit" ], dict ), attributes[ "commit" ] - self._commit = Commit.Commit( self._requester, attributes[ "commit" ], completed = False ) - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "commit" in attributes: # pragma no branch + assert attributes[ "commit" ] is None or isinstance( attributes[ "commit" ], dict ), attributes[ "commit" ] + self._commit = None if attributes[ "commit" ] is None else Commit.Commit( self._requester, attributes[ "commit" ], completed = False ) + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] - if "tarball_url" in attributes and attributes[ "tarball_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "tarball_url" ], ( str, unicode ) ), attributes[ "tarball_url" ] + if "tarball_url" in attributes: # pragma no branch + assert attributes[ "tarball_url" ] is None or isinstance( attributes[ "tarball_url" ], ( str, unicode ) ), attributes[ "tarball_url" ] self._tarball_url = attributes[ "tarball_url" ] - if "zipball_url" in attributes and attributes[ "zipball_url" ] is not None: # pragma no branch - assert isinstance( attributes[ "zipball_url" ], ( str, unicode ) ), attributes[ "zipball_url" ] + if "zipball_url" in attributes: # pragma no branch + assert attributes[ "zipball_url" ] is None or isinstance( attributes[ "zipball_url" ], ( str, unicode ) ), attributes[ "zipball_url" ] self._zipball_url = attributes[ "zipball_url" ] diff --git a/src/github/Team.py b/src/github/Team.py index 52ef155c..3aa3c269 100644 --- a/src/github/Team.py +++ b/src/github/Team.py @@ -3,7 +3,6 @@ import GithubObject import PaginatedList -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters ########## import Repository import NamedUser @@ -11,33 +10,33 @@ import NamedUser class Team( GithubObject.GithubObject ): @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def members_count( self ): - self._completeIfNeeded( self._members_count ) - return self._members_count + self._completeIfNotSet( self._members_count ) + return self._NoneIfNotSet( self._members_count ) @property def name( self ): - self._completeIfNeeded( self._name ) - return self._name + self._completeIfNotSet( self._name ) + return self._NoneIfNotSet( self._name ) @property def permission( self ): - self._completeIfNeeded( self._permission ) - return self._permission + self._completeIfNotSet( self._permission ) + return self._NoneIfNotSet( self._permission ) @property def repos_count( self ): - self._completeIfNeeded( self._repos_count ) - return self._repos_count + self._completeIfNotSet( self._repos_count ) + return self._NoneIfNotSet( self._repos_count ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) def add_to_members( self, member ): assert isinstance( member, NamedUser.NamedUser ), member @@ -68,14 +67,14 @@ class Team( GithubObject.GithubObject ): ) self._checkStatus( status, data ) - def edit( self, name, permission = DefaultValueForOptionalParameters ): + def edit( self, name, permission = GithubObject.NotSet ): assert isinstance( name, ( str, unicode ) ), name - if permission is not DefaultValueForOptionalParameters: + if permission is not GithubObject.NotSet: assert isinstance( permission, ( str, unicode ) ), permission post_parameters = { "name": name, } - if permission is not DefaultValueForOptionalParameters: + if permission is not GithubObject.NotSet: post_parameters[ "permission" ] = permission status, headers, data = self._request( "PATCH", @@ -157,29 +156,29 @@ class Team( GithubObject.GithubObject ): self._checkStatus( status, data ) def _initAttributes( self ): - self._id = None - self._members_count = None - self._name = None - self._permission = None - self._repos_count = None - self._url = None + self._id = GithubObject.NotSet + self._members_count = GithubObject.NotSet + self._name = GithubObject.NotSet + self._permission = GithubObject.NotSet + self._repos_count = GithubObject.NotSet + self._url = GithubObject.NotSet def _useAttributes( self, attributes ): - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "members_count" in attributes and attributes[ "members_count" ] is not None: # pragma no branch - assert isinstance( attributes[ "members_count" ], int ), attributes[ "members_count" ] + if "members_count" in attributes: # pragma no branch + assert attributes[ "members_count" ] is None or isinstance( attributes[ "members_count" ], int ), attributes[ "members_count" ] self._members_count = attributes[ "members_count" ] - if "name" in attributes and attributes[ "name" ] is not None: # pragma no branch - assert isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] + if "name" in attributes: # pragma no branch + assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ] self._name = attributes[ "name" ] - if "permission" in attributes and attributes[ "permission" ] is not None: # pragma no branch - assert isinstance( attributes[ "permission" ], ( str, unicode ) ), attributes[ "permission" ] + if "permission" in attributes: # pragma no branch + assert attributes[ "permission" ] is None or isinstance( attributes[ "permission" ], ( str, unicode ) ), attributes[ "permission" ] self._permission = attributes[ "permission" ] - if "repos_count" in attributes and attributes[ "repos_count" ] is not None: # pragma no branch - assert isinstance( attributes[ "repos_count" ], int ), attributes[ "repos_count" ] + if "repos_count" in attributes: # pragma no branch + assert attributes[ "repos_count" ] is None or isinstance( attributes[ "repos_count" ], int ), attributes[ "repos_count" ] self._repos_count = attributes[ "repos_count" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + 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/src/github/UserKey.py b/src/github/UserKey.py index 66474a20..35711ef6 100644 --- a/src/github/UserKey.py +++ b/src/github/UserKey.py @@ -2,33 +2,32 @@ # Do not modify it manually, your work would be lost. import GithubObject -from DefaultValueForOptionalParameters import DefaultValueForOptionalParameters class UserKey( GithubObject.GithubObject ): @property def id( self ): - self._completeIfNeeded( self._id ) - return self._id + self._completeIfNotSet( self._id ) + return self._NoneIfNotSet( self._id ) @property def key( self ): - self._completeIfNeeded( self._key ) - return self._key + self._completeIfNotSet( self._key ) + return self._NoneIfNotSet( self._key ) @property def title( self ): - self._completeIfNeeded( self._title ) - return self._title + self._completeIfNotSet( self._title ) + return self._NoneIfNotSet( self._title ) @property def url( self ): - self._completeIfNeeded( self._url ) - return self._url + self._completeIfNotSet( self._url ) + return self._NoneIfNotSet( self._url ) @property def verified( self ): - self._completeIfNeeded( self._verified ) - return self._verified + self._completeIfNotSet( self._verified ) + return self._NoneIfNotSet( self._verified ) def delete( self ): status, headers, data = self._request( @@ -39,15 +38,15 @@ class UserKey( GithubObject.GithubObject ): ) self._checkStatus( status, data ) - def edit( self, title = DefaultValueForOptionalParameters, key = DefaultValueForOptionalParameters ): - if title is not DefaultValueForOptionalParameters: + def edit( self, title = GithubObject.NotSet, key = GithubObject.NotSet ): + if title is not GithubObject.NotSet: assert isinstance( title, ( str, unicode ) ), title - if key is not DefaultValueForOptionalParameters: + if key is not GithubObject.NotSet: assert isinstance( key, ( str, unicode ) ), key post_parameters = dict() - if title is not DefaultValueForOptionalParameters: + if title is not GithubObject.NotSet: post_parameters[ "title" ] = title - if key is not DefaultValueForOptionalParameters: + if key is not GithubObject.NotSet: post_parameters[ "key" ] = key status, headers, data = self._request( "PATCH", @@ -59,25 +58,25 @@ class UserKey( GithubObject.GithubObject ): self._useAttributes( data ) def _initAttributes( self ): - self._id = None - self._key = None - self._title = None - self._url = None - self._verified = None + self._id = GithubObject.NotSet + self._key = GithubObject.NotSet + self._title = GithubObject.NotSet + self._url = GithubObject.NotSet + self._verified = GithubObject.NotSet def _useAttributes( self, attributes ): - if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch - assert isinstance( attributes[ "id" ], int ), attributes[ "id" ] + if "id" in attributes: # pragma no branch + assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ] self._id = attributes[ "id" ] - if "key" in attributes and attributes[ "key" ] is not None: # pragma no branch - assert isinstance( attributes[ "key" ], ( str, unicode ) ), attributes[ "key" ] + if "key" in attributes: # pragma no branch + assert attributes[ "key" ] is None or isinstance( attributes[ "key" ], ( str, unicode ) ), attributes[ "key" ] self._key = attributes[ "key" ] - if "title" in attributes and attributes[ "title" ] is not None: # pragma no branch - assert isinstance( attributes[ "title" ], ( str, unicode ) ), attributes[ "title" ] + if "title" in attributes: # pragma no branch + assert attributes[ "title" ] is None or isinstance( attributes[ "title" ], ( str, unicode ) ), attributes[ "title" ] self._title = attributes[ "title" ] - if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch - assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] + if "url" in attributes: # pragma no branch + assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ] self._url = attributes[ "url" ] - if "verified" in attributes and attributes[ "verified" ] is not None: # pragma no branch - assert isinstance( attributes[ "verified" ], bool ), attributes[ "verified" ] + if "verified" in attributes: # pragma no branch + assert attributes[ "verified" ] is None or isinstance( attributes[ "verified" ], bool ), attributes[ "verified" ] self._verified = attributes[ "verified" ]