From 5cd7ad5f4898b538f771290548ba131f7063d94c Mon Sep 17 00:00:00 2001 From: David Medina Date: Sat, 16 Jun 2012 13:10:32 +0200 Subject: Refact normalize of dates into base.Service --- pygithub3/services/base.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'pygithub3/services/base.py') 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 -- cgit v1.2.3-59-g8ed1b