aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/resources/base.py
diff options
context:
space:
mode:
authorDavid Medina <davidmedina9@gmail.com>2012-02-10 00:59:01 +0100
committerDavid Medina <davidmedina9@gmail.com>2012-02-10 00:59:01 +0100
commit46d535027b5247a9f1b242b4944e2ee8d65b4fad (patch)
treef303b79c167c3b94ab741594e93e5603a5dadfb6 /pygithub3/resources/base.py
parentjson:dumps.loads mocked (diff)
downloadpython-github3-46d535027b5247a9f1b242b4944e2ee8d65b4fad.tar.xz
python-github3-46d535027b5247a9f1b242b4944e2ee8d65b4fad.zip
Resources tests
resources.core * Also detected and fixed memory bug
Diffstat (limited to 'pygithub3/resources/base.py')
-rw-r--r--pygithub3/resources/base.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/pygithub3/resources/base.py b/pygithub3/resources/base.py
index ae038bd..dfa285f 100644
--- a/pygithub3/resources/base.py
+++ b/pygithub3/resources/base.py
@@ -22,6 +22,9 @@ class Resource(object):
for attr in self._attrs:
setattr(self, attr, self._attrs[attr])
+ def __str__(self):
+ return "<%s>" % self.__class__.__name__
+
def __repr__(self):
return self.__str__()
@@ -59,19 +62,21 @@ class Resource(object):
elif hasattr(raw_resources, '__iter__'):
return [resource.__load(raw_resource)
for raw_resource in raw_resources]
- raw_resource.update(
+
+ new_resource = raw_resource.copy()
+ new_resource.update(
{attr: parse_date(raw_resource[attr])
for attr in self._dates if attr in raw_resource})
- raw_resource.update(
+ new_resource.update(
{attr: parse_map(resource, raw_resource[attr])
for attr, resource in self._maps.items()
if attr in raw_resource})
- raw_resource.update(
+ new_resource.update(
{attr: parse_collection_map(resource, raw_resource[attr])
for attr, resource in self._collection_maps.items()
if attr in raw_resource})
- return self(raw_resource)
+ return self(new_resource)
class Raw(Resource):