diff --git a/senpy/__init__.py b/senpy/__init__.py index ca7dcf1..5a89b74 100644 --- a/senpy/__init__.py +++ b/senpy/__init__.py @@ -17,7 +17,3 @@ """ Sentiment analysis server in Python """ - -import extensions -import blueprints -import plugins diff --git a/senpy/__main__.py b/senpy/__main__.py index 57fa456..6ed8552 100644 --- a/senpy/__main__.py +++ b/senpy/__main__.py @@ -44,6 +44,10 @@ if __name__ == '__main__': action='store_true', default=False, help='Run the application in debug mode') + parser.add_argument('--default-plugins', + action='store_true', + default=False, + help='Run the application in debug mode') parser.add_argument('--host', type=str, default="127.0.0.1", @@ -62,14 +66,14 @@ if __name__ == '__main__': logging.basicConfig(level=getattr(logging, args.level)) app = Flask(__name__) app.debug = args.debug - sp = Senpy(app, args.plugins_folder) + sp = Senpy(app, args.plugins_folder, default_plugins=args.default_plugins) sp.activate_all() import logging http_server = WSGIServer((args.host, args.port), app) try: - print "Server running on port %s:%d. Ctrl+C to quit" % (args.host, - args.port) + print("Server running on port %s:%d. Ctrl+C to quit" % (args.host, + args.port)) http_server.serve_forever() except KeyboardInterrupt: http_server.stop() - print "Bye!" + print("Bye!") diff --git a/senpy/extensions.py b/senpy/extensions.py index 93e14f5..60b96a9 100644 --- a/senpy/extensions.py +++ b/senpy/extensions.py @@ -27,14 +27,14 @@ class Senpy(object): """ Default Senpy extension for Flask """ - def __init__(self, app=None, plugin_folder="plugins", base_plugins=True): + def __init__(self, app=None, plugin_folder="plugins", default_plugins=False): self.app = app self._search_folders = set() self._outdated = True self.add_folder(plugin_folder) - if base_plugins: + if default_plugins: base_folder = os.path.join(os.path.dirname(__file__), "plugins") self.add_folder(base_folder) diff --git a/senpy/models.py b/senpy/models.py index b32c5a8..2b7069e 100644 --- a/senpy/models.py +++ b/senpy/models.py @@ -154,7 +154,7 @@ class Leaf(dict): ' type="application/ld+json"' % url) } del js["@context"] - return FlaskResponse(json.dumps(js), + return FlaskResponse(json.dumps(js, indent=4), status=self.get("status", 200), headers=headers, mimetype="application/json") diff --git a/setup.py b/setup.py index 1a3bc2b..c5a3831 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ except AttributeError: install_reqs = [str(ir.req) for ir in install_reqs] test_reqs = [str(ir.req) for ir in test_reqs] -VERSION = "0.4.6" +VERSION = "0.4.7" setup( name='senpy', @@ -34,5 +34,6 @@ extendable, so new algorithms and sources can be used. classifiers=[], install_requires=install_reqs, tests_require=test_reqs, + test_suite="nose.collector", include_package_data=True, ) diff --git a/test-requirements.txt b/test-requirements.txt index e69de29..c5c60b7 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -0,0 +1,3 @@ +nose +mock +pbr diff --git a/tests/extensions_test/__init__.py b/tests/extensions_test/__init__.py index 204269d..15f3387 100644 --- a/tests/extensions_test/__init__.py +++ b/tests/extensions_test/__init__.py @@ -15,7 +15,7 @@ class ExtensionsTest(TestCase): def create_app(self): self.app = Flask("test_extensions") self.dir = os.path.join(os.path.dirname(__file__), "..") - self.senpy = Senpy(plugin_folder=self.dir, base_plugins=False) + self.senpy = Senpy(plugin_folder=self.dir, default_plugins=False) self.senpy.init_app(self.app) self.senpy.activate_plugin("Dummy", sync=True) return self.app