Use ValuedAttribute and NotSet.value (preparation for #195)

This commit is contained in:
Vincent Jacques
2013-09-12 00:40:27 +02:00
parent 2cf722dc9f
commit 4a5009741a
55 changed files with 1122 additions and 1122 deletions
+9 -9
View File
@@ -33,9 +33,16 @@ import Consts
class _NotSetType:
def __repr__(self):
return "NotSet"
value = None
NotSet = _NotSetType()
class ValuedAttribute:
def __init__(self, value):
self.value = value
class GithubObject(object):
"""
Base class for all classes representing objects returned by the API.
@@ -87,13 +94,6 @@ class GithubObject(object):
def _parentUrl(url):
return "/".join(url.split("/")[: -1])
@staticmethod
def _NoneIfNotSet(value):
if value is NotSet:
return None
else:
return value
@staticmethod
def _parseDatetime(s):
if s is None:
@@ -141,7 +141,7 @@ class CompletableGithubObject(GithubObject):
def __complete(self):
headers, data = self._requester.requestJsonAndCheck(
"GET",
self._url
self._url.value
)
self._storeAndUseAttributes(headers, data)
self.__completed = True
@@ -159,7 +159,7 @@ class CompletableGithubObject(GithubObject):
status, responseHeaders, output = self._requester.requestJson(
"GET",
self._url,
self._url.value,
headers=conditionalRequestHeader
)
if status == 304: