diff options
| author | 2012-02-03 14:45:32 +0100 | |
|---|---|---|
| committer | 2012-02-03 14:46:54 +0100 | |
| commit | f01bc94a33d8644da65b5fa895c222e9ee057b50 (patch) | |
| tree | 3bfc837901a54f97a30f1d24431d8322906de192 /pygithub3/services | |
| parent | Pypi environment by setuptools (diff) | |
| download | python-github3-f01bc94a33d8644da65b5fa895c222e9ee057b50.tar.xz python-github3-f01bc94a33d8644da65b5fa895c222e9ee057b50.zip | |
Fix imports to new environment
Absolute imports as PEP8 tells
Diffstat (limited to 'pygithub3/services')
| -rw-r--r-- | pygithub3/services/__init__.py | 0 | ||||
| -rw-r--r-- | pygithub3/services/base.py | 43 | ||||
| -rw-r--r-- | pygithub3/services/users.py | 45 |
3 files changed, 88 insertions, 0 deletions
diff --git a/pygithub3/services/__init__.py b/pygithub3/services/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/pygithub3/services/__init__.py diff --git a/pygithub3/services/base.py b/pygithub3/services/base.py new file mode 100644 index 0000000..303b3a0 --- /dev/null +++ b/pygithub3/services/base.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from pygithub3.core.client import Client + + +class Base(object): + + def __init__(self, **config): + self.client = Client(**config) + + def get_user(self): + return self.client.user + + def set_user(self, user): + self.client.user = user + + def get_repo(self): + return self.client.repo + + def set_repo(self, repo): + self.client.repo = repo + + def _get_result(self, resource, **kwargs): + return Result(self.client.get, resource, **kwargs) + + +class Result(object): # move + + def __init__(self, method, resource, **kwargs): + self.method = method + self.resource = resource + self.args = kwargs + + def __repr__(self): + pass + + def process(self): + model = self.resource.get_model() + raw = self.method(self.resource, **self.args) + if model: + import json + return model.loads(json.loads(raw.content)) diff --git a/pygithub3/services/users.py b/pygithub3/services/users.py new file mode 100644 index 0000000..70826f2 --- /dev/null +++ b/pygithub3/services/users.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from .base import Base +from pygithub3.core.resources import Factory + + +class Keys(Base): + + def list(self): + return self.get_resource('user/keys') + + +class Followers(Base): + + def list(self, user): + pass + + +class Emails(Base): + + def list(self): + pass + + def add(self): + pass + + def delete(self): + pass + + +class User(Base): + + def __init__(self, **kwargs): + self.keys = Keys(**kwargs) + self.emails = Emails(**kwargs) + self.followers = Followers(**kwargs) + super(User, self).__init__(**kwargs) + + def get(self, user): + resource = Factory(user=user or self.client.user) + return self._get_result(resource('users.get')) + + def update(self): + pass |
