aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Medina <davidmedina9@gmail.com>2012-02-03 14:45:32 +0100
committerDavid Medina <davidmedina9@gmail.com>2012-02-03 14:46:54 +0100
commitf01bc94a33d8644da65b5fa895c222e9ee057b50 (patch)
tree3bfc837901a54f97a30f1d24431d8322906de192
parentPypi environment by setuptools (diff)
downloadpython-github3-f01bc94a33d8644da65b5fa895c222e9ee057b50.tar.xz
python-github3-f01bc94a33d8644da65b5fa895c222e9ee057b50.zip
Fix imports to new environment
Absolute imports as PEP8 tells
-rw-r--r--github3/core/resources/user/__init__.py2
-rw-r--r--github3/core/resources/user/emails.py8
-rw-r--r--github3/tests/__init__.py0
-rw-r--r--pygithub3/__init__.py8
-rw-r--r--pygithub3/core/__init__.py (renamed from github3/core/__init__.py)0
-rw-r--r--pygithub3/core/client.py (renamed from github3/core/client.py)4
-rw-r--r--pygithub3/core/errors.py (renamed from github3/errors.py)0
-rw-r--r--pygithub3/core/resources/__init__.py (renamed from github3/core/resources/__init__.py)10
-rw-r--r--pygithub3/core/resources/users/__init__.py4
-rw-r--r--pygithub3/core/resources/users/emails.py9
-rw-r--r--pygithub3/core/resources/users/followers.py (renamed from github3/core/resources/user/followers.py)0
-rw-r--r--pygithub3/core/resources/users/keys.py (renamed from github3/core/resources/user/keys.py)0
-rw-r--r--pygithub3/core/resources/users/user.py (renamed from github3/core/resources/user/user.py)4
-rw-r--r--pygithub3/github.py2
-rw-r--r--pygithub3/models/__init__.py1
-rw-r--r--pygithub3/models/base.py (renamed from github3/models/base.py)1
-rw-r--r--pygithub3/models/users.py (renamed from github3/models/user.py)4
-rw-r--r--pygithub3/services/__init__.py (renamed from github3/models/__init__.py)0
-rw-r--r--pygithub3/services/base.py (renamed from github3/services/base.py)6
-rw-r--r--pygithub3/services/users.py (renamed from github3/services/user.py)15
-rw-r--r--pygithub3/tests/__init__.py (renamed from github3/services/__init__.py)0
-rw-r--r--pygithub3/tests/test_errors.py (renamed from github3/tests/test_errors.py)0
22 files changed, 51 insertions, 27 deletions
diff --git a/github3/core/resources/user/__init__.py b/github3/core/resources/user/__init__.py
deleted file mode 100644
index 8248571..0000000
--- a/github3/core/resources/user/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-from core.resources import Resource
-from user import *
diff --git a/github3/core/resources/user/emails.py b/github3/core/resources/user/emails.py
deleted file mode 100644
index 83644db..0000000
--- a/github3/core/resources/user/emails.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env python
-# -*- encoding: utf-8 -*-
-
-from core.uris import Manager
-from models.base import Model
-
-class List(Manager):
- pass
diff --git a/github3/tests/__init__.py b/github3/tests/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/github3/tests/__init__.py
+++ /dev/null
diff --git a/pygithub3/__init__.py b/pygithub3/__init__.py
new file mode 100644
index 0000000..7c48d06
--- /dev/null
+++ b/pygithub3/__init__.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+
+__title__ = 'pygithub3'
+__version__ = '0.1'
+__author__ = 'David Medina'
+__license__ = 'ISC'
+__copyright__ = 'Copyright 2012 David Medina'
diff --git a/github3/core/__init__.py b/pygithub3/core/__init__.py
index e69de29..e69de29 100644
--- a/github3/core/__init__.py
+++ b/pygithub3/core/__init__.py
diff --git a/github3/core/client.py b/pygithub3/core/client.py
index 99a88f0..d4247af 100644
--- a/github3/core/client.py
+++ b/pygithub3/core/client.py
@@ -2,8 +2,8 @@
# -*- encoding: utf-8 -*-
import requests
-from errors import GithubError
+from .errors import GithubError
VALID_REQUEST_ARGS = set((
'params', 'data', 'headers', 'cookies', 'files', 'auth', 'timeout',
@@ -65,7 +65,7 @@ class Client(object):
def wrapper(self, verb, resource, **kwargs):
diffs = kwargs.viewkeys() - VALID_REQUEST_ARGS
new_params = kwargs.get('params') or {}
- new_params.update({key:kwargs[key] for key in diffs})
+ new_params.update({key: kwargs[key] for key in diffs})
kwargs['params'] = new_params
return func(self, verb, resource, **kwargs)
return wrapper
diff --git a/github3/errors.py b/pygithub3/core/errors.py
index 0d58c16..0d58c16 100644
--- a/github3/errors.py
+++ b/pygithub3/core/errors.py
diff --git a/github3/core/resources/__init__.py b/pygithub3/core/resources/__init__.py
index c5dee18..bca9607 100644
--- a/github3/core/resources/__init__.py
+++ b/pygithub3/core/resources/__init__.py
@@ -3,6 +3,9 @@
import re
+ABS_IMPORT_PREFIX = 'pygithub3.core.resources'
+
+
class UriNotFound(Exception):
pass
@@ -41,6 +44,7 @@ class Resource(object):
class Factory(object):
""" """
+
import_pattern = re.compile(r'^(\w+\.)+\w+$')
def __init__(self, **kwargs):
@@ -59,11 +63,13 @@ class Factory(object):
""" """
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('core.resources.%s' % module_chunk)
+ 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)
@@ -78,4 +84,4 @@ class Factory(object):
def __call__(self, resource_class=''):
resource = resource_class(self.args)
assert isinstance(resource, Resource)
- return resource
+ return resource
diff --git a/pygithub3/core/resources/users/__init__.py b/pygithub3/core/resources/users/__init__.py
new file mode 100644
index 0000000..84759a2
--- /dev/null
+++ b/pygithub3/core/resources/users/__init__.py
@@ -0,0 +1,4 @@
+# -*- encoding: utf-8 -*-
+
+from pygithub3.core.resources import Resource
+from user import *
diff --git a/pygithub3/core/resources/users/emails.py b/pygithub3/core/resources/users/emails.py
new file mode 100644
index 0000000..18d520c
--- /dev/null
+++ b/pygithub3/core/resources/users/emails.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+
+from . import Resource
+#from pygithub3.models.
+
+
+class List(Resource):
+ pass
diff --git a/github3/core/resources/user/followers.py b/pygithub3/core/resources/users/followers.py
index e69de29..e69de29 100644
--- a/github3/core/resources/user/followers.py
+++ b/pygithub3/core/resources/users/followers.py
diff --git a/github3/core/resources/user/keys.py b/pygithub3/core/resources/users/keys.py
index e69de29..e69de29 100644
--- a/github3/core/resources/user/keys.py
+++ b/pygithub3/core/resources/users/keys.py
diff --git a/github3/core/resources/user/user.py b/pygithub3/core/resources/users/user.py
index 4308f01..1399ff8 100644
--- a/github3/core/resources/user/user.py
+++ b/pygithub3/core/resources/users/user.py
@@ -2,10 +2,11 @@
# -*- encoding: utf-8 -*-
from . import Resource
-from models.user import User
+from pygithub3.models.users import User
__all__ = ('Get', 'Update')
+
class Get(Resource):
model = User
@@ -19,5 +20,6 @@ class Get(Resource):
else:
return 'user'
+
class Update(Resource):
pass
diff --git a/pygithub3/github.py b/pygithub3/github.py
new file mode 100644
index 0000000..ff6ea1e
--- /dev/null
+++ b/pygithub3/github.py
@@ -0,0 +1,2 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
diff --git a/pygithub3/models/__init__.py b/pygithub3/models/__init__.py
new file mode 100644
index 0000000..dae354a
--- /dev/null
+++ b/pygithub3/models/__init__.py
@@ -0,0 +1 @@
+# -*- encoding: utf-8 -*-
diff --git a/github3/models/base.py b/pygithub3/models/base.py
index a2c3ac7..2f0cbd7 100644
--- a/github3/models/base.py
+++ b/pygithub3/models/base.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
+
class Model(object):
dates = ()
diff --git a/github3/models/user.py b/pygithub3/models/users.py
index c87afc3..0ceef90 100644
--- a/github3/models/user.py
+++ b/pygithub3/models/users.py
@@ -1,7 +1,9 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
-from base import Model
+from .base import Model
+
+__all__ = ('Plan', 'User')
class Plan(Model):
diff --git a/github3/models/__init__.py b/pygithub3/services/__init__.py
index e69de29..e69de29 100644
--- a/github3/models/__init__.py
+++ b/pygithub3/services/__init__.py
diff --git a/github3/services/base.py b/pygithub3/services/base.py
index c74aa2e..303b3a0 100644
--- a/github3/services/base.py
+++ b/pygithub3/services/base.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
-from core.client import Client
+from pygithub3.core.client import Client
+
class Base(object):
@@ -23,11 +24,12 @@ class Base(object):
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.resource = resource
self.args = kwargs
def __repr__(self):
diff --git a/github3/services/user.py b/pygithub3/services/users.py
index 0a7e740..70826f2 100644
--- a/github3/services/user.py
+++ b/pygithub3/services/users.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
-from base import Base
-from core.resources import Factory
+from .base import Base
+from pygithub3.core.resources import Factory
class Keys(Base):
@@ -14,17 +14,13 @@ class Keys(Base):
class Followers(Base):
def list(self, user):
- user = user or self.client.user
- if user:
- return self.get_resource('users/%s/followers' % user)
- else:
- return self.get_resource('user/followers')
+ pass
class Emails(Base):
def list(self):
- return self.get_resource('user/emails')
+ pass
def add(self):
pass
@@ -32,6 +28,7 @@ class Emails(Base):
def delete(self):
pass
+
class User(Base):
def __init__(self, **kwargs):
@@ -42,7 +39,7 @@ class User(Base):
def get(self, user):
resource = Factory(user=user or self.client.user)
- return self._get_result(resource('user.Get'))
+ return self._get_result(resource('users.get'))
def update(self):
pass
diff --git a/github3/services/__init__.py b/pygithub3/tests/__init__.py
index e69de29..e69de29 100644
--- a/github3/services/__init__.py
+++ b/pygithub3/tests/__init__.py
diff --git a/github3/tests/test_errors.py b/pygithub3/tests/test_errors.py
index 36f33d9..36f33d9 100644
--- a/github3/tests/test_errors.py
+++ b/pygithub3/tests/test_errors.py