diff options
Diffstat (limited to '')
| -rw-r--r-- | pygithub3/core/ghrequests/users/__init__.py (renamed from pygithub3/core/resources/users/__init__.py) | 2 | ||||
| -rw-r--r-- | pygithub3/core/ghrequests/users/keys.py (renamed from pygithub3/core/resources/users/keys.py) | 0 | ||||
| -rw-r--r-- | pygithub3/core/ghrequests/users/user.py (renamed from pygithub3/core/resources/users/user.py) | 10 | ||||
| -rw-r--r-- | pygithub3/core/resources/__init__.py | 87 | ||||
| -rw-r--r-- | pygithub3/core/resources/users/emails.py | 16 | ||||
| -rw-r--r-- | pygithub3/core/resources/users/followers.py | 0 |
6 files changed, 6 insertions, 109 deletions
diff --git a/pygithub3/core/resources/users/__init__.py b/pygithub3/core/ghrequests/users/__init__.py index 84759a2..08986f6 100644 --- a/pygithub3/core/resources/users/__init__.py +++ b/pygithub3/core/ghrequests/users/__init__.py @@ -1,4 +1,4 @@ # -*- encoding: utf-8 -*- -from pygithub3.core.resources import Resource +from pygithub3.core.ghrequests import Request from user import * diff --git a/pygithub3/core/resources/users/keys.py b/pygithub3/core/ghrequests/users/keys.py index e69de29..e69de29 100644 --- a/pygithub3/core/resources/users/keys.py +++ b/pygithub3/core/ghrequests/users/keys.py diff --git a/pygithub3/core/resources/users/user.py b/pygithub3/core/ghrequests/users/user.py index 1399ff8..18a356e 100644 --- a/pygithub3/core/resources/users/user.py +++ b/pygithub3/core/ghrequests/users/user.py @@ -1,15 +1,15 @@ #!/usr/bin/env python # -*- encoding: utf-8 -*- -from . import Resource -from pygithub3.models.users import User +from . import Request +from pygithub3.resources.users import User __all__ = ('Get', 'Update') -class Get(Resource): +class Get(Request): - model = User + resource = User def validate(self): pass @@ -21,5 +21,5 @@ class Get(Resource): return 'user' -class Update(Resource): +class Update(Request): pass diff --git a/pygithub3/core/resources/__init__.py b/pygithub3/core/resources/__init__.py deleted file mode 100644 index bca9607..0000000 --- a/pygithub3/core/resources/__init__.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -import re - -ABS_IMPORT_PREFIX = 'pygithub3.core.resources' - - -class UriNotFound(Exception): - pass - - -class UriInvalid(Exception): - pass - - -class Resource(object): - """ """ - - def __init__(self, args): - """ """ - self.args = args - self.validate() - self.uri = self.set_uri() - - def validate(self, args): - raise NotImplementedError - - def set_uri(self): - raise NotImplementedError - - def get_uri(self): - return str(self.uri).strip('/') - - def get_model(self): - return getattr(self, 'model', '') - - def __getattr__(self, name): - return self.args.get(name) - - def __str__(self): - return self.get_uri() - - -class Factory(object): - """ """ - - import_pattern = re.compile(r'^(\w+\.)+\w+$') - - def __init__(self, **kwargs): - self.args = kwargs - - def __validate(func): - """ """ - - def wrapper(self, resource_path): - if not Factory.import_pattern.match(resource_path): - raise UriInvalid("'%s' isn't valid form" % resource_path) - return func(self, resource_path.lower()) - return wrapper - - def __dispatch(func): - """ """ - - from importlib import import_module - - def wrapper(self, resource_path): - module_chunk, s, uri_chunk = resource_path.rpartition('.') - try: - # TODO: CamelCase and under_score support, now only Class Name - module = import_module('%s.%s' - % (ABS_IMPORT_PREFIX, module_chunk)) - uri = getattr(module, uri_chunk.capitalize()) - except ImportError: - raise UriNotFound("'%s' module does not exists" % module_chunk) - except AttributeError: - raise UriNotFound("'%s' uri doesn't exists into '%s' module" - % (uri_chunk.capitalize(), module_chunk)) - return func(self, uri) - return wrapper - - @__validate - @__dispatch - def __call__(self, resource_class=''): - resource = resource_class(self.args) - assert isinstance(resource, Resource) - return resource diff --git a/pygithub3/core/resources/users/emails.py b/pygithub3/core/resources/users/emails.py deleted file mode 100644 index 9523977..0000000 --- a/pygithub3/core/resources/users/emails.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -from . import Resource -from pygithub3.models.base import Raw - - -class List(Resource): - - model = Raw - - def validate(self): - pass - - def set_uri(self): - return 'user/emails' diff --git a/pygithub3/core/resources/users/followers.py b/pygithub3/core/resources/users/followers.py deleted file mode 100644 index e69de29..0000000 --- a/pygithub3/core/resources/users/followers.py +++ /dev/null |
