diff options
author | 2012-06-16 13:10:32 +0200 | |
---|---|---|
committer | 2012-06-16 13:10:32 +0200 | |
commit | 5cd7ad5f4898b538f771290548ba131f7063d94c (patch) | |
tree | 4636f091e5018bee6b32c9e6de2688a48e5d6ca0 /pygithub3/services/base.py | |
parent | Remove list_milestones from repo service (diff) | |
download | python-github3-5cd7ad5f4898b538f771290548ba131f7063d94c.tar.xz python-github3-5cd7ad5f4898b538f771290548ba131f7063d94c.zip |
Refact normalize of dates into base.Service
Diffstat (limited to 'pygithub3/services/base.py')
-rw-r--r-- | pygithub3/services/base.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/pygithub3/services/base.py b/pygithub3/services/base.py index 649b2b3..5fed1db 100644 --- a/pygithub3/services/base.py +++ b/pygithub3/services/base.py @@ -1,10 +1,13 @@ #!/usr/bin/env python # -*- encoding: utf-8 -*- +from datetime import datetime + from pygithub3.core.client import Client +from pygithub3.core.errors import NotFound from pygithub3.core.result import smart, normal from pygithub3.requests.base import Factory -from pygithub3.core.errors import NotFound +from pygithub3.resources.base import GITHUB_DATE_FORMAT class Service(object): @@ -41,6 +44,15 @@ class Service(object): self._client = Client(**config) self.request_builder = Factory() + def _normalize_date(self, key, _dict): + """ If ``key`` comes as ``datetime``, it'll normalize it """ + try: + key = str(key) + date = datetime.strftime(_dict.get(key), GITHUB_DATE_FORMAT) + _dict.update({key: date}) + except: + pass + @property def remaining_requests(self): return Client.remaining_requests |