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
ecc2a831
Commit
ecc2a831
authored
Nov 02, 2015
by
J. Fernando Sánchez
Browse files
Still not functional
parent
aafd6a09
Changes
4
Hide whitespace changes
Inline
Side-by-side
senpy/blueprints.py
View file @
ecc2a831
...
...
@@ -19,6 +19,7 @@ Blueprints for Senpy
"""
from
flask
import
Blueprint
,
request
,
current_app
,
Flask
,
redirect
,
url_for
,
render_template
from
.models
import
Error
,
Response
,
Leaf
from
future.utils
import
iteritems
import
json
import
logging
...
...
@@ -58,7 +59,7 @@ def get_params(req, params=BASIC_PARAMS):
outdict
=
{}
wrong_params
=
{}
for
param
,
options
in
params
.
iteritems
():
for
param
,
options
in
iteritems
(
params
):
if
param
[
0
]
!=
"@"
:
# Exclude json-ld properties
logger
.
debug
(
"Param: %s - Options: %s"
,
param
,
options
)
for
alias
in
options
[
"aliases"
]:
...
...
@@ -79,7 +80,7 @@ def get_params(req, params=BASIC_PARAMS):
"message"
:
"Missing or invalid parameters"
,
"parameters"
:
outdict
,
"errors"
:
{
param
:
error
for
param
,
error
in
wrong_params
.
iteritems
(
)}
iteritems
(
wrong_params
)}
})
raise
ValueError
(
message
)
return
outdict
...
...
senpy/extensions.py
View file @
ecc2a831
"""
"""
from
future
import
standard_library
standard_library
.
install_aliases
()
import
gevent
from
gevent
import
monkey
monkey
.
patch_all
()
...
...
@@ -102,7 +104,7 @@ class Senpy(object):
def
default_plugin
(
self
):
candidates
=
self
.
filter_plugins
(
is_activated
=
True
)
if
len
(
candidates
)
>
0
:
candidate
=
candidates
.
values
()[
0
]
candidate
=
list
(
candidates
.
values
()
)
[
0
]
logger
.
debug
(
"Default: {}"
.
format
(
candidate
))
return
candidate
else
:
...
...
senpy/models.py
View file @
ecc2a831
import
json
import
os
import
logging
from
builtins
import
str
from
collections
import
defaultdict
from
pyld
import
jsonld
import
logging
from
flask
import
Response
as
FlaskResponse
...
...
@@ -93,7 +95,7 @@ class Leaf(dict):
return
contexts
elif
isinstance
(
context
,
dict
):
return
context
elif
isinstance
(
context
,
basestring
):
elif
isinstance
(
context
,
str
):
try
:
with
open
(
context
)
as
f
:
return
json
.
loads
(
f
.
read
())
...
...
senpy/plugins.py
View file @
ecc2a831
from
future
import
standard_library
standard_library
.
install_aliases
()
import
inspect
import
os.path
import
shelve
import
logging
import
ConfigParser
from
.models
import
Response
,
Leaf
logger
=
logging
.
getLogger
(
__name__
)
...
...
Write
Preview
Supports
Markdown
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