diff options
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} |
