From 39dcad7bd36bb902414fa855c7a4ff290c9f3f1e Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 18 Aug 2010 12:35:52 -0400 Subject: [PATCH] Refactorings Moved Tests Added proper datetime --- gistapi/__init__.py | 9 ++++++++- gistapi/{gistapi.py => core.py} | 16 +++++++--------- gistapi/tests/__init__.py | 1 + gistapi/tests/test_examples.py | 8 ++++++++ {tests => gistapi/tests}/test_gist.py | 0 reqs.txt | 2 ++ requirments.txt | 1 - tests/test_examples.py | 0 8 files changed, 26 insertions(+), 11 deletions(-) rename gistapi/{gistapi.py => core.py} (91%) create mode 100644 gistapi/tests/__init__.py create mode 100644 gistapi/tests/test_examples.py rename {tests => gistapi/tests}/test_gist.py (100%) create mode 100644 reqs.txt delete mode 100644 requirments.txt delete mode 100644 tests/test_examples.py diff --git a/gistapi/__init__.py b/gistapi/__init__.py index 8528d58..472a608 100644 --- a/gistapi/__init__.py +++ b/gistapi/__init__.py @@ -1,6 +1,13 @@ # encoding: utf-8 -from gistapi import * +""" +GistAPI.py -- A Python wrapper for GitHub's Gist API +(c) 2010 Kenneth Reitz. MIT License. +""" + + +from core import * + __author__ = 'Kenneth Reitz' __version__ = '0.1.4' diff --git a/gistapi/gistapi.py b/gistapi/core.py similarity index 91% rename from gistapi/gistapi.py rename to gistapi/core.py index 17ccca5..8dce053 100644 --- a/gistapi/gistapi.py +++ b/gistapi/core.py @@ -1,8 +1,7 @@ -### !/usr/bin/env python # encoding: utf-8 """ -GistAPI.py -- A Python wrapper for the Gist API +GistAPI.py -- A Python wrapper for GitHub's Gist API (c) 2010 Kenneth Reitz. MIT License. Example usage: @@ -16,8 +15,8 @@ u'kennethreitz' >>> Gist('d4507e882a07ac6f9f92').description u'Example Gist for gist.py' ->>> Gist('d4507e882a07ac6f9f92').created_at -u'2010/05/16 10:51:15 -0700' +>>> Gist('d4507e882a07ac6f9f92').created_at.isoformat() +'2010-05-16T10:51:15-07:00' >>> Gist('d4507e882a07ac6f9f92').public False @@ -34,6 +33,7 @@ u'My .bashrc configuration' import urllib +from dateutil.parser import parse as dtime try: @@ -92,6 +92,9 @@ class Gist(object): elif key == 'public': # Attach booleans setattr(self, key, value) + elif key == 'created_at': + # Attach datetime + setattr(self, key, dtime(value)) else: # Attach properties to object @@ -129,8 +132,3 @@ class Gists(object): # Return a list of Gist objects return [Gist(json=g) for g in json.load(urllib.urlopen(_url))['gists']] - -if __name__ == '__main__': - import doctest - - doctest.testmod() diff --git a/gistapi/tests/__init__.py b/gistapi/tests/__init__.py new file mode 100644 index 0000000..7c68785 --- /dev/null +++ b/gistapi/tests/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- \ No newline at end of file diff --git a/gistapi/tests/test_examples.py b/gistapi/tests/test_examples.py new file mode 100644 index 0000000..e20b17f --- /dev/null +++ b/gistapi/tests/test_examples.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import doctest +import gistapi + +# run doctests +doctest.testmod(gistapi) \ No newline at end of file diff --git a/tests/test_gist.py b/gistapi/tests/test_gist.py similarity index 100% rename from tests/test_gist.py rename to gistapi/tests/test_gist.py diff --git a/reqs.txt b/reqs.txt new file mode 100644 index 0000000..695083a --- /dev/null +++ b/reqs.txt @@ -0,0 +1,2 @@ +simplejson +python-dateutil \ No newline at end of file diff --git a/requirments.txt b/requirments.txt deleted file mode 100644 index 60540ac..0000000 --- a/requirments.txt +++ /dev/null @@ -1 +0,0 @@ -simplejson \ No newline at end of file diff --git a/tests/test_examples.py b/tests/test_examples.py deleted file mode 100644 index e69de29..0000000