Use a special value for not set attributes and parameters

This commit is contained in:
Vincent Jacques
2012-05-31 18:04:22 +02:00
parent ccf59e62af
commit 6f564e5aca
50 changed files with 2116 additions and 2128 deletions
+137 -138
View File
@@ -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" ]