diff options
| author | 2012-02-04 19:07:23 +0100 | |
|---|---|---|
| committer | 2012-02-04 19:07:23 +0100 | |
| commit | 8a723b0815841ea9e34c148b06c0fa6529b90e33 (patch) | |
| tree | 6161c4aef077d2ac9e2430d935f53e37117a0b9b /pygithub3/models | |
| parent | Full support to Result dynamic and lazy iterator (diff) | |
| download | python-github3-8a723b0815841ea9e34c148b06c0fa6529b90e33.tar.xz python-github3-8a723b0815841ea9e34c148b06c0fa6529b90e33.zip | |
Renaming (What I was thinking?)
resources => ghrequests
models => resources
+ Also it's near to complete user service
Diffstat (limited to '')
| -rw-r--r-- | pygithub3/resources/__init__.py (renamed from pygithub3/models/__init__.py) | 0 | ||||
| -rw-r--r-- | pygithub3/resources/base.py (renamed from pygithub3/models/base.py) | 22 | ||||
| -rw-r--r-- | pygithub3/resources/users.py (renamed from pygithub3/models/users.py) | 6 |
3 files changed, 14 insertions, 14 deletions
diff --git a/pygithub3/models/__init__.py b/pygithub3/resources/__init__.py index dae354a..dae354a 100644 --- a/pygithub3/models/__init__.py +++ b/pygithub3/resources/__init__.py diff --git a/pygithub3/models/base.py b/pygithub3/resources/base.py index 722d545..5a9418a 100644 --- a/pygithub3/models/base.py +++ b/pygithub3/resources/base.py @@ -7,7 +7,7 @@ except ImportError: import json -class Model(object): +class Resource(object): _dates = () _maps = {} @@ -41,37 +41,37 @@ class Model(object): date = None return date - def parse_map(model, raw_resource): + def parse_map(resource, raw_resource): if hasattr(raw_resource, 'items'): - return model.__load(raw_resource) + return resource.__load(raw_resource) - def parse_collection_map(model, raw_resources): + def parse_collection_map(resource, raw_resources): # Dict of resources (Ex: Gist file) if hasattr(raw_resources, 'items'): dict_map = {} for key, raw_resource in raw_resources.items(): - dict_map[key] = model.__load(raw_resource) + dict_map[key] = resource.__load(raw_resource) return dict_map # list of resources elif hasattr(raw_resources, '__iter__'): - return [model.__load(raw_resource) + return [resource.__load(raw_resource) for raw_resource in raw_resources] raw_resource.update( {attr: parse_date(raw_resource[attr]) for attr in self._dates if attr in raw_resource}) raw_resource.update( - {attr: parse_map(model, raw_resource[attr]) - for attr, model in self._maps.items() + {attr: parse_map(resource , raw_resource[attr]) + for attr, resource in self._maps.items() if attr in raw_resource}) raw_resource.update( - {attr: parse_collection_map(model, raw_resource[attr]) - for attr, model in self._collection_maps.items() + {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) -class Raw(Model): +class Raw(Resource): @classmethod def loads(self, json_content): diff --git a/pygithub3/models/users.py b/pygithub3/resources/users.py index c94a704..7e40025 100644 --- a/pygithub3/models/users.py +++ b/pygithub3/resources/users.py @@ -1,18 +1,18 @@ #!/usr/bin/env python # -*- encoding: utf-8 -*- -from .base import Model +from .base import Resource __all__ = ('Plan', 'User') -class Plan(Model): +class Plan(Resource): def __str__(self): return '<Plan (%s)>' % getattr(self, 'name', '') -class User(Model): +class User(Resource): """ """ _maps = {'plan': Plan} |
