aboutsummaryrefslogtreecommitdiffstats
path: root/github3/handlers/base.py
diff options
context:
space:
mode:
authorDavid Medina <davidmedina9@gmail.com>2011-11-28 01:07:42 +0100
committerDavid Medina <davidmedina9@gmail.com>2011-11-28 01:07:42 +0100
commit8060db65c51d551107eff76bf4e94ef82d9f869b (patch)
tree167577d9ccaa8ff175ee5c7595f2c71bd22ad52f /github3/handlers/base.py
parentDiff between 'my' and 'get' (diff)
downloadpython-github3-8060db65c51d551107eff76bf4e94ef82d9f869b.tar.xz
python-github3-8060db65c51d551107eff76bf4e94ef82d9f869b.zip
MimeType mixin
Diffstat (limited to 'github3/handlers/base.py')
-rw-r--r--github3/handlers/base.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/github3/handlers/base.py b/github3/handlers/base.py
index a85ce20..7bc55d2 100644
--- a/github3/handlers/base.py
+++ b/github3/handlers/base.py
@@ -4,6 +4,38 @@
from github3.core import Paginate
from github3.converters import Modelizer
+
+class MimeTypeMixin(object):
+
+ VERSION = 'beta'
+
+ def __init__(self):
+ self.mimetypes = set()
+
+ def _parse_mime_type(self, type):
+ return 'application/vnd.github.%s.%s+json' % (
+ self.VERSION, type)
+
+ def add_raw(self):
+ self.mimetypes.add(self._parse_mime_type('raw'))
+ return self
+
+ def add_text(self):
+ self.mimetypes.add(self._parse_mime_type('text'))
+ return self
+
+ def add_html(self):
+ self.mimetypes.add(self._parse_mime_type('html'))
+ return self
+
+ def add_full(self):
+ self.mimetypes.add(self._parse_mime_type('full'))
+ return self
+
+ def mime_header(self):
+ return {'Accept': ', '.join(self.mimetypes)}
+
+
class Handler(object):
""" Handler base. Requests to API and modelize responses """