Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
senpy
senpy
Commits
b484b453
Commit
b484b453
authored
Sep 29, 2015
by
J. Fernando Sánchez
Browse files
Added indentation and default plugins
* setup.py:
parent
7c2e0dde
Changes
7
Hide whitespace changes
Inline
Side-by-side
senpy/__init__.py
View file @
b484b453
...
...
@@ -17,7 +17,3 @@
"""
Sentiment analysis server in Python
"""
import
extensions
import
blueprints
import
plugins
senpy/__main__.py
View file @
b484b453
...
...
@@ -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!"
)
senpy/extensions.py
View file @
b484b453
...
...
@@ -27,14 +27,14 @@ class Senpy(object):
""" Default Senpy extension for Flask """
def
__init__
(
self
,
app
=
None
,
plugin_folder
=
"plugins"
,
base
_plugins
=
Tru
e
):
def
__init__
(
self
,
app
=
None
,
plugin_folder
=
"plugins"
,
default
_plugins
=
Fals
e
):
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
)
...
...
senpy/models.py
View file @
b484b453
...
...
@@ -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"
)
...
...
setup.py
View file @
b484b453
...
...
@@ -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
,
)
test-requirements.txt
View file @
b484b453
nose
mock
pbr
tests/extensions_test/__init__.py
View file @
b484b453
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment