aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/resources
diff options
context:
space:
mode:
authorDavid Medina <davidmedina9@gmail.com>2012-06-03 13:02:54 +0200
committerDavid Medina <davidmedina9@gmail.com>2012-06-03 13:02:54 +0200
commit897671db979e64754de2c53cbbe83fcbae37bb02 (patch)
tree11ac9ede303971d2bcaf270d833fd4112c923509 /pygithub3/resources
parentMerge 'services/orgs' (diff)
parentChange "Edit" to "Update" in docstring (diff)
downloadpython-github3-897671db979e64754de2c53cbbe83fcbae37bb02.tar.xz
python-github3-897671db979e64754de2c53cbbe83fcbae37bb02.zip
Merge branch 'services/issues' of https://github.com/alejandrogomez/python-github3 into services/issues
Conflicts: docs/services.rst pygithub3/github.py pygithub3/requests/repos/__init__.py
Diffstat (limited to 'pygithub3/resources')
-rw-r--r--pygithub3/resources/issues.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/pygithub3/resources/issues.py b/pygithub3/resources/issues.py
new file mode 100644
index 0000000..69f905a
--- /dev/null
+++ b/pygithub3/resources/issues.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+
+import re
+
+from .base import Resource
+from .users import User
+from .pull_requests import PullRequest
+
+
+class Label(Resource):
+
+ @staticmethod
+ def is_valid_color(color):
+ valid_color = re.compile(r'[0-9abcdefABCDEF]{6}')
+ match = valid_color.match(color)
+ if match is None:
+ return False
+ return match.start() == 0 and match.end() == len(color)
+
+ def __str__(self):
+ return '<Label (%s)>' % getattr(self, 'name', '')
+
+
+class Milestone(Resource):
+
+ _dates = ('created_at', 'due_on')
+ _maps = {'creator': User}
+
+ def __str__(self):
+ return '<Milestone (%s)>' % getattr(self, 'title', '')
+
+
+class Issue(Resource):
+
+ _dates = ('created_at', 'updated_at', 'closed_at')
+ _maps = {
+ 'assignee': User,
+ 'user': User,
+ 'milestone': Milestone,
+ 'pull_request': PullRequest
+ }
+
+ _collection_maps = {'labels': Label}
+
+ def __str__(self):
+ return '<Issue (%s)>' % getattr(self, 'number', '')
+
+
+class Comment(Resource):
+
+ _dates = ('created_at', 'updated_at')
+ _maps = {'user': User}
+
+ def __str__(self):
+ return '<Comment (%s)>' % (getattr(self, 'user', ''))
+
+
+class Event(Resource):
+
+ _dates = ('created_at', )
+ _maps = {'actor': User, 'issue': Issue}
+
+ def __str__(self):
+ return '<Event (%s)>' % (getattr(self, 'commit_id', ''))