From bbc6885e4186193ca1fd8d888f1cb0d517594c9e Mon Sep 17 00:00:00 2001 From: hfaran Date: Sun, 16 Feb 2014 05:20:25 -0800 Subject: [PATCH 1/2] Make compatible with Python3 --- .travis.yml | 1 + README.md | 2 -- README.rst | 2 -- setup.py | 5 ----- tornado_json/api_doc_gen.py | 2 +- tornado_json/application.py | 2 +- tornado_json/requesthandlers.py | 2 +- tornado_json/routes.py | 8 +++----- tornado_json/test/test_tornado_json.py | 2 +- 9 files changed, 8 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1b1a1df..b979cb8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: python python: - "2.7" + - "3.3" install: - "pip install -r requirements.txt --use-mirrors" - "pip install pytest" diff --git a/README.md b/README.md index bcc2876..4b9e0c5 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,6 @@ Some of the key features the included modules provide: # Dependencies -*Python2.7 is the only supported version (as you might suspect).* - These dependencies can be satisfied by running `pip install -r requirements.txt` * tornado diff --git a/README.rst b/README.rst index 8843c02..8395d2e 100644 --- a/README.rst +++ b/README.rst @@ -38,8 +38,6 @@ being said, use it at your own risk.*\ Dependencies ============ -*Python2.7 is the only supported version (as you might suspect).* - These dependencies can be satisfied by running ``pip install -r requirements.txt`` diff --git a/setup.py b/setup.py index 50ec71a..7ddb875 100644 --- a/setup.py +++ b/setup.py @@ -10,11 +10,6 @@ import tornado_json -if not sys.version_info[:2] == (2, 7): - print "Sorry, only Python2.7 is supported." - exit() - - def read(filename): """Read and return `filename` in root dir of project and return string""" return codecs.open(os.path.join(__DIR__, filename), 'r').read() diff --git a/tornado_json/api_doc_gen.py b/tornado_json/api_doc_gen.py index 22b72ec..17c6d3a 100644 --- a/tornado_json/api_doc_gen.py +++ b/tornado_json/api_doc_gen.py @@ -63,7 +63,7 @@ def api_doc_gen(routes): ``` """.format(json.dumps(rh.apid[method]["output_example"], indent=4)) if rh.apid[method].get("output_example") else "", - ) for method in rh.apid.keys() + ) for method in list(rh.apid.keys()) ] ) ) diff --git a/tornado_json/application.py b/tornado_json/application.py index 940ead7..155cb5f 100755 --- a/tornado_json/application.py +++ b/tornado_json/application.py @@ -22,7 +22,7 @@ def __init__(self, routes, settings, db_conn=None): api_doc_gen(routes) # Unless gzip was specifically set to False in settings, enable it - if "gzip" not in settings.keys(): + if "gzip" not in list(settings.keys()): settings["gzip"] = True tornado.web.Application.__init__( diff --git a/tornado_json/requesthandlers.py b/tornado_json/requesthandlers.py index dd4c6c0..62810c0 100644 --- a/tornado_json/requesthandlers.py +++ b/tornado_json/requesthandlers.py @@ -63,7 +63,7 @@ def write_error(self, status_code, **kwargs): self.clear() # If exc_info is not in kwargs, something is very fubar - if not "exc_info" in kwargs.keys(): + if not "exc_info" in list(kwargs.keys()): logging.error("exc_info not provided") self.set_status(500) self.error(message="Internal Server Error", code=500) diff --git a/tornado_json/routes.py b/tornado_json/routes.py index 8943592..2ff2b57 100644 --- a/tornado_json/routes.py +++ b/tornado_json/routes.py @@ -4,6 +4,7 @@ import inspect import types from itertools import chain +from functools import reduce def get_routes(package): @@ -98,10 +99,7 @@ def yield_args(module, cls_name, method_name): # method = getattr(getattr(module, cls_name), method_name) wrapped_method = reduce(getattr, [module, cls_name, method_name]) method = extract_method(wrapped_method) - return filter( - lambda a: a not in ["self"], - inspect.getargspec(method).args - ) + return [a for a in inspect.getargspec(method).args if a not in ["self"]] if not custom_routes: custom_routes = [] @@ -138,7 +136,7 @@ def yield_args(module, cls_name, method_name): ] if has_method(module, k, method_name) ])) # foreach classname, pyclbr.Class in rhs - for k, v in rhs.iteritems() + for k, v in rhs.items() # Only add the pair to auto_routes if: # * the superclass is in the list of supers we want # * the requesthandler isn't already paired in custom_routes diff --git a/tornado_json/test/test_tornado_json.py b/tornado_json/test/test_tornado_json.py index ec9792e..75c2c78 100644 --- a/tornado_json/test/test_tornado_json.py +++ b/tornado_json/test/test_tornado_json.py @@ -9,7 +9,7 @@ from tornado_json import jsend sys.path.append('demos/helloworld') import helloworld -except ImportError: +except ImportError as e: print("Please run `py.test` from the root project directory") exit(1) From 19f14dce08f57187fddfaead731dfc6739eb9a21 Mon Sep 17 00:00:00 2001 From: hfaran Date: Sun, 16 Feb 2014 05:23:09 -0800 Subject: [PATCH 2/2] Bump version 0.12 --- tornado_json/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tornado_json/__init__.py b/tornado_json/__init__.py index c3f4387..32c3823 100644 --- a/tornado_json/__init__.py +++ b/tornado_json/__init__.py @@ -5,4 +5,4 @@ # Alternatively, just put the version in a text file or something to avoid # this. -__version__ = '0.11' +__version__ = '0.12'