text stringlengths 81 112k |
|---|
Create a handler that returns the swagger definition
for an application.
This method assumes the application is using the
TransmuteUrlDispatcher as the router.
def create_swagger_json_handler(app, **kwargs):
"""
Create a handler that returns the swagger definition
for an application.
This... |
Create detail plots (first row) and total block(second row) of experiments.
Args:
tag_ids: list of tag-dictionaries, where the dictionaries must have fields 'name' (used for naming)
and 'id' (used for numbering axis_dict)
Returns:
Figure element fig, ax_di... |
Function used by all angle conversion functions (from_x_to_x_pi(...))
def change_angles(method, theta, tol=1e-10):
""" Function used by all angle conversion functions (from_x_to_x_pi(...))"""
try:
theta_new = np.zeros(theta.shape)
for i, thet in enumerate(theta):
try:
... |
Calcualte rmse between vector or matrix x and xhat, ignoring mod of 2pi.
def rmse_2pi(x, xhat):
''' Calcualte rmse between vector or matrix x and xhat, ignoring mod of 2pi.'''
real_diff = from_0_to_pi(x - xhat)
np.square(real_diff, out=real_diff)
sum_ = np.sum(real_diff)
return sqrt(sum_ / len(x)) |
Calculate coordinates of point Pk given two points Pi, Pj and inner angles. :param theta_ik: Inner angle at Pi to Pk.
:param theta_jk: Inner angle at Pj to Pk.
:param Pi: Coordinates of point Pi.
:param Pj: Coordinates of point Pj.
:return: Coordinate of point Pk.
def get_point(theta_ik, theta_jk, Pi... |
return a list of the content types this set supports.
this is not a complete list: serializers can accept more than
one content type. However, it is a good representation of the
class of content types supported.
def keys(self):
"""
return a list of the content types this set su... |
given a function, categorize which arguments should be passed by
what types of parameters. The choices are:
* query parameters: passed in as query parameters in the url
* body parameters: retrieved from the request body (includes forms)
* header parameters: retrieved from the request header
* path ... |
from a list of paths, return back a list of the
arguments present in those paths.
the arguments available in all of the paths must match: if not,
an exception will be raised.
def _extract_path_parameters_from_paths(paths):
"""
from a list of paths, return back a list of the
arguments present i... |
body is built differently, since it's a single argument no matter what.
def _build_body_schema(serializer, body_parameters):
""" body is built differently, since it's a single argument no matter what. """
description = ""
if isinstance(body_parameters, Param):
schema = serializer.to_json_schema(bod... |
Parse a 17 bytes packet in the Wind format and return a
dictionary containing the data extracted. An example of a return value
would be:
.. code-block:: python
{
'id': "0x2EB2",
'packet_length': 16,
'packet_type': 86,
... |
Fit X to anchors by applying optimal translation, rotation and reflection.
Given m >= d anchor nodes (anchors in R^(m x d)), return transformation
of coordinates X (output of EDM algorithm) optimally matching anchors in least squares sense.
:param anchors: Matrix of shape m x d, where m is number of ancho... |
Reconstruct point set using E(dge)-MDS.
def reconstruct_emds(edm, Om, all_points, method=None, **kwargs):
""" Reconstruct point set using E(dge)-MDS.
"""
from .point_set import dm_from_edm
N = all_points.shape[0]
d = all_points.shape[1]
dm = dm_from_edm(edm)
if method is None:
from ... |
Reconstruct point set from angle and distance measurements, using coordinate difference matrices.
def reconstruct_cdm(dm, absolute_angles, all_points, W=None):
""" Reconstruct point set from angle and distance measurements, using coordinate difference matrices.
"""
from pylocus.point_set import dmi_from_V,... |
Reconstruct point set using MDS and matrix completion algorithms.
def reconstruct_mds(edm, all_points, completion='optspace', mask=None, method='geometric', print_out=False, n=1):
""" Reconstruct point set using MDS and matrix completion algorithms.
"""
from .point_set import dm_from_edm
from .mds impo... |
Reconstruct point set using semi-definite rank relaxation.
def reconstruct_sdp(edm, all_points, W=None, print_out=False, lamda=1000, **kwargs):
""" Reconstruct point set using semi-definite rank relaxation.
"""
from .edm_completion import semidefinite_relaxation
edm_complete = semidefinite_relaxation(
... |
Reconstruct point set using S(quared)R(ange)L(east)S(quares) method.
def reconstruct_srls(edm, all_points, W=None, print_out=False, n=1, rescale=False,
z=None):
""" Reconstruct point set using S(quared)R(ange)L(east)S(quares) method.
"""
from .lateration import SRLS, get_lateration_par... |
Reconstruct point set using alternating coordinate descent.
:param X0: Nxd matrix of starting points.
:param tol: Stopping criterion: if the stepsize in all coordinate directions
is less than tol for 2 consecutive sweeps, we stop.
:param sweep: Maximum number of sweeps. One sweep goes thr... |
Reconstruct point set using d(istributed)w(eighted) MDS.
Refer to paper "Distributed Weighted-Multidimensional Scaling for Node Localization in Sensor Networks" for
implementation details (doi.org/10.1145/1138127.1138129)
:param X0: Nxd matrix of starting points.
:param n: Number of points of unknown... |
Parse a 12 bytes packet in the Rain format and return a
dictionary containing the data extracted. An example of a return value
would be:
.. code-block:: python
{
'id': "0x2EB2",
'packet_length': 11,
'packet_type': 85,
... |
Get parameters relevant for lateration from full all_points, edm and W.
def get_lateration_parameters(all_points, indices, index, edm, W=None):
""" Get parameters relevant for lateration from full all_points, edm and W.
"""
if W is None:
W = np.ones(edm.shape)
# delete points that are not cons... |
Squared range least squares (SRLS)
Algorithm written by A.Beck, P.Stoica in "Approximate and Exact solutions of Source Localization Problems".
:param anchors: anchor points (Nxd)
:param w: weights for the measurements (Nx1)
:param r2: squared distances from anchors to point x. (Nx1)
:param rescale... |
Algorithm used by pozyx (https://www.pozyx.io/Documentation/how_does_positioning_work)
:param anchors: anchor points
:param r2: squared distances from anchors to point x.
:returns: estimated position of point x.
def PozyxLS(anchors, W, r2, print_out=False):
''' Algorithm used by pozyx (https://www.po... |
Range least squares (RLS) using grid search.
Algorithm written by A.Beck, P.Stoica in "Approximate and Exact solutions of Source Localization Problems".
:param anchors: anchor points
:param r2: squared distances from anchors to point x.
:param grid: where to search for solution. (min, max) where min ... |
Range least squares (RLS) using SDR.
Algorithm cited by A.Beck, P.Stoica in "Approximate and Exact solutions of Source Localization Problems".
:param anchors: anchor points
:param r2: squared distances from anchors to point x.
:return: estimated position of point x.
def RLS_SDR(anchors, W, r, print_... |
join parameters from the lhs to the rhs, if compatible.
def _join_parameters(base, nxt):
""" join parameters from the lhs to the rhs, if compatible. """
if nxt is None:
return base
if isinstance(base, set) and isinstance(nxt, set):
return base | nxt
else:
... |
get the swagger_schema operation representation.
def get_swagger_operation(self, context=default_context):
"""
get the swagger_schema operation representation.
"""
consumes = produces = context.contenttype_serializers.keys()
parameters = get_swagger_parameters(self.parameters, c... |
given an result body and an exception object,
return the appropriate result object,
or raise an exception.
def process_result(self, context, result_body, exc, content_type):
"""
given an result body and an exception object,
return the appropriate result object,
or raise ... |
from the given parameters, return back the response type dictionaries.
def _parse_response_types(argspec, attrs):
"""
from the given parameters, return back the response type dictionaries.
"""
return_type = argspec.annotations.get("return") or None
type_description = attrs.param... |
given a root directory for the swagger statics, and
a swagger json path, return back a swagger html designed
to use those values.
def generate_swagger_html(swagger_static_root, swagger_json_url):
"""
given a root directory for the swagger statics, and
a swagger json path, return back a swagger html... |
add a transmute function's swagger definition to the spec
def add_func(self, transmute_func, transmute_context):
""" add a transmute function's swagger definition to the spec """
swagger_path = transmute_func.get_swagger_path(transmute_context)
for p in transmute_func.paths:
self.ad... |
for a given path, add the path items.
def add_path(self, path, path_item):
""" for a given path, add the path items. """
if path not in self._swagger:
self._swagger[path] = path_item
else:
for method, definition in path_item.items():
if definition is not ... |
return a valid swagger spec, with the values passed.
def swagger_definition(self, base_path=None, **kwargs):
"""
return a valid swagger spec, with the values passed.
"""
return Swagger(
{
"info": Info(
{
key: kwargs... |
Wrapper to call the spied-on function. Operates similar to
Expectation.test.
def _call_spy(self, *args, **kwargs):
'''
Wrapper to call the spied-on function. Operates similar to
Expectation.test.
'''
if self._spy_side_effect:
if self._spy_side_effect_args or self._spy_side... |
Wrap side effects for spies.
def side_effect(self, func, *args, **kwargs):
'''
Wrap side effects for spies.
'''
self._spy_side_effect = func
self._spy_side_effect_args = args
self._spy_side_effect_kwargs = kwargs
return self |
This function prepares the interaction items for inclusion in main script's
global scope.
:param glob: main script's global scope dictionary reference
def set_interact_items(glob):
"""
This function prepares the interaction items for inclusion in main script's
global scope.
:param g... |
Logger configuration function for setting either a simple debug mode or a
multi-level one.
:param glob: globals dictionary
:param multi_level: boolean telling if multi-level debug is to be considered
:param relative: use relative time for the logging messages
:param logfile: log ... |
process a result:
transmute_func: the transmute_func function that returned the response.
context: the transmute_context to use.
result: the return value of the function, which will be serialized and
returned back in the API.
exc: the exception object. For Python 2, the traceback should
... |
Implementation of the OptSpace matrix completion algorithm.
An algorithm for Matrix Reconstruction from a partially revealed set.
Sparse treatment of matrices are removed because of indexing problems in Python.
Args:
M_E: 2D numpy array; The partially revealed matrix.
Matrix ... |
In contrast to MATLAB, numpy's svds() arranges the singular
values in ascending order. In order to have matching codes,
we wrap it around by a function which re-sorts the singular
values and singular vectors.
Args:
M: 2D numpy array; the matrix whose SVD is to be computed.
k: Numbe... |
Guess the rank of the incomplete matrix
def guess_rank(M_E):
'''Guess the rank of the incomplete matrix '''
n, m = M_E.shape
epsilon = np.count_nonzero(M_E) / np.sqrt(m * n)
_, S0, _ = svds_descending(M_E, min(100, max(M_E.shape) - 1))
S0 = np.diag(S0)
S1 = S0[:-1] - S0[1:]
S1_ = S... |
Compute the distortion
def F_t(X, Y, S, M_E, E, m0, rho):
''' Compute the distortion '''
r = X.shape[1]
out1 = (((np.dot(np.dot(X, S), Y.T) - M_E) * E)**2).sum() / 2
out2 = rho * G(Y, m0, r)
out3 = rho * G(X, m0, r)
return out1 + out2 + out3 |
Compute the gradient.
def gradF_t(X, Y, S, M_E, E, m0, rho):
''' Compute the gradient.
'''
n, r = X.shape
m, r = Y.shape
XS = np.dot(X, S)
YS = np.dot(Y, S.T)
XSY = np.dot(XS, Y.T)
Qx = np.dot(np.dot(X.T, ((M_E - XSY) * E)), YS) / n
Qy = np.dot(np.dot(Y.T, ((M_E - XSY) ... |
Find Sopt given X, Y
def getoptS(X, Y, M_E, E):
''' Find Sopt given X, Y
'''
n, r = X.shape
C = np.dot(np.dot(X.T, M_E), Y)
C = C.flatten()
A = np.zeros((r * r, r * r))
for i in range(r):
for j in range(r):
ind = j * r + i
temp = np.dot(
... |
Perform line search
def getoptT(X, W, Y, Z, S, M_E, E, m0, rho):
''' Perform line search
'''
iter_max = 20
norm2WZ = np.linalg.norm(W, ord='fro')**2 + np.linalg.norm(Z, ord='fro')**2
f = np.zeros(iter_max + 1)
f[0] = F_t(X, Y, S, M_E, E, m0, rho)
t = -1e-1
for i in range(iter_... |
recover points from euclidean distance matrix using classic MDS algorithm.
def MDS(D, dim, method='simple', theta=False):
""" recover points from euclidean distance matrix using classic MDS algorithm.
"""
N = D.shape[0]
if method == 'simple':
d1 = D[0, :]
# buf_ = d1 * np.ones([1, N]).... |
Find the set of points from an edge kernel.
def superMDS(X0, N, d, **kwargs):
""" Find the set of points from an edge kernel.
"""
Om = kwargs.get('Om', None)
dm = kwargs.get('dm', None)
if Om is not None and dm is not None:
KE = kwargs.get('KE', None)
if KE is not None:
... |
Find the set of points from an edge kernel with geometric constraints, using iterative projection
def iterativeEMDS(X0, N, d, C, b, max_it=10, print_out=False, **kwargs):
""" Find the set of points from an edge kernel with geometric constraints, using iterative projection
"""
from pylocus.basics import ms... |
Find the set of points from an edge kernel with geometric constraints, using convex rank relaxation.
def relaxedEMDS(X0, N, d, C, b, KE, print_out=False, lamda=10):
""" Find the set of points from an edge kernel with geometric constraints, using convex rank relaxation.
"""
E = C.shape[1]
X = Variable((... |
Find the set of points from a cdm.
def signedMDS(cdm, W=None):
""" Find the set of points from a cdm.
"""
N = cdm.shape[0]
D_sym = (cdm - cdm.T)
D_sym /= 2
if W is None:
x_est = np.mean(D_sym, axis=1)
x_est -= np.min(x_est)
return x_est
W_sub = W[1:, 1:]
sum_... |
Stub an attribute of an object. Will return an existing stub if
there already is one.
def _stub_attr(obj, attr_name):
'''
Stub an attribute of an object. Will return an existing stub if
there already is one.
'''
# Annoying circular reference requires importing here. Would like to see
# this... |
Stub an object directly.
def _stub_obj(obj):
'''
Stub an object directly.
'''
# Annoying circular reference requires importing here. Would like to see
# this cleaned up. @AW
from .mock import Mock
# Return an existing stub
if isinstance(obj, Stub):
return obj
# If a Mock o... |
Assert that all expectations on the stub have been met.
def unmet_expectations(self):
'''
Assert that all expectations on the stub have been met.
'''
unmet = []
for exp in self._expectations:
if not exp.closed(with_counts=True):
unmet.append(Expectati... |
Clean up all expectations and restore the original attribute of the
mocked object.
def teardown(self):
'''
Clean up all expectations and restore the original attribute of the
mocked object.
'''
if not self._torn:
self._expectations = []
self._torn... |
Add an expectation to this stub. Return the expectation.
def expect(self):
'''
Add an expectation to this stub. Return the expectation.
'''
exp = Expectation(self)
self._expectations.append(exp)
return exp |
Add a spy to this stub. Return the spy.
def spy(self):
'''
Add a spy to this stub. Return the spy.
'''
spy = Spy(self)
self._expectations.append(spy)
return spy |
Calls the original function.
def call_orig(self, *args, **kwargs):
'''
Calls the original function.
'''
if hasattr(self._obj, '__self__') and \
inspect.isclass(self._obj.__self__) and \
self._obj.__self__ is self._instance:
return self._obj.__... |
Put the original method back in place. This will also handle the
special case when it putting back a class method.
The following code snippet best describe why it fails using settar,
the class method would be replaced with a bound method not a class
method.
>>> class Example(ob... |
Replace the original method.
def _teardown(self):
'''
Replace the original method.
'''
if not self._was_object_method:
setattr(self._instance, self._attr, self._obj)
else:
delattr(self._instance, self._attr) |
Calls the original function. Simulates __new__ and __init__ together.
def call_orig(self, *args, **kwargs):
'''
Calls the original function. Simulates __new__ and __init__ together.
'''
rval = super(StubNew, self).call_orig(self._type)
rval.__init__(*args, **kwargs)
retu... |
Overload so that we can clear out the cache after a test run.
def _teardown(self):
'''
Overload so that we can clear out the cache after a test run.
'''
# __new__ is a super-special case in that even when stubbing a class
# which implements its own __new__ and subclasses object,... |
Calls the original function.
def call_orig(self, *args, **kwargs):
'''
Calls the original function.
'''
return self._orig(self._obj, *args, **kwargs) |
Performs the RFXtrx initialisation protocol in a Future.
Currently this is the rough workflow of the interactions with the
RFXtrx. We also do a few extra things - flush the buffer, and attach
readers/writers to the asyncio loop.
1. Write a RESET packet (write all zeros)
2. Wait... |
Add the callback to the event loop, we use call soon because we just
want it to be called at some point, but don't care when particularly.
def do_callback(self, pkt):
"""Add the callback to the event loop, we use call soon because we just
want it to be called at some point, but don't care when ... |
We have been called to read! As a consumer, continue to read for
the length of the packet and then pass to the callback.
def read(self):
"""We have been called to read! As a consumer, continue to read for
the length of the packet and then pass to the callback.
"""
data = self.d... |
Executes an HTTP DELETE request for the given URL.
``params`` should be a dictionary
def delete(self, url, params=None):
""" Executes an HTTP DELETE request for the given URL.
``params`` should be a dictionary
"""
response = self.http.delete(url,
... |
Executes an HTTP GET request for the given URL.
``data`` should be a dictionary of url parameters
def get(self, url, data=None):
""" Executes an HTTP GET request for the given URL.
``data`` should be a dictionary of url parameters
"""
response = self.http.get(url,
... |
Executes an HTTP POST request for the given URL.
def post(self, url, body=None):
""" Executes an HTTP POST request for the given URL. """
response = self.http.post(url,
headers=self.headers,
data=body,
... |
Executes an HTTP PUT request for the given URL.
def put(self, url, data=None, body=None):
""" Executes an HTTP PUT request for the given URL. """
response = self.http.put(url,
headers=self.headers,
data=body,
... |
Returns HTTP backend agnostic ``Response`` data.
def process(self, response):
""" Returns HTTP backend agnostic ``Response`` data. """
try:
code = response.status_code
# 204 - No Content
if code == 204:
body = None
# add an error message... |
Creates an account with Zencoder, no API Key necessary.
https://app.zencoder.com/docs/api/accounts/create
def create(self, email, tos=1, options=None):
""" Creates an account with Zencoder, no API Key necessary.
https://app.zencoder.com/docs/api/accounts/create
"""
data = {'e... |
Creates a transcoding job. Here are some examples::
job.create('s3://zencodertesting/test.mov')
job.create(live_stream=True)
job.create(input='http://example.com/input.mov',
outputs=({'label': 'test output'},))
https://app.zencoder.com/docs/api/jobs/c... |
Lists Jobs.
https://app.zencoder.com/docs/api/jobs/list
def list(self, page=1, per_page=50):
""" Lists Jobs.
https://app.zencoder.com/docs/api/jobs/list
"""
data = {"page": page,
"per_page": per_page}
return self.get(self.base_url, data=data) |
Resubmits the given ``job_id``.
https://app.zencoder.com/docs/api/jobs/resubmit
def resubmit(self, job_id):
""" Resubmits the given ``job_id``.
https://app.zencoder.com/docs/api/jobs/resubmit
"""
url = self.base_url + '/%s/resubmit' % str(job_id)
return self.put(url) |
Cancels the given ``job_id``.
https://app.zencoder.com/docs/api/jobs/cancel
def cancel(self, job_id):
""" Cancels the given ``job_id``.
https://app.zencoder.com/docs/api/jobs/cancel
"""
if self.version == 'v1':
verb = self.get
else:
verb = self... |
Gets a detailed Report of encoded minutes and billable minutes for a
date range.
**Warning**: ``start_date`` and ``end_date`` must be ``datetime.date`` objects.
Example::
import datetime
start = datetime.date(2012, 12, 31)
end = datetime.today()
... |
attach a transmute route.
def route(app_or_blueprint, context=default_context, **kwargs):
""" attach a transmute route. """
def decorator(fn):
fn = describe(**kwargs)(fn)
transmute_func = TransmuteFunction(fn)
routes, handler = create_routes_and_handler(transmute_func, context)
... |
Stub an object. If attr is not None, will attempt to stub that
attribute on the object. Only required for modules and other rare
cases where we can't determine the binding from the object.
def stub(self, obj, attr=None):
'''
Stub an object. If attr is not None, will attempt to stub that... |
Return a mock object.
def mock(self, obj=None, attr=None, **kwargs):
'''
Return a mock object.
'''
rval = Mock(**kwargs)
if obj is not None and attr is not None:
rval._object = obj
rval._attr = attr
if hasattr(obj, attr):
orig... |
Create an error from validation exception.
def from_validation_exception(cls, exception, **kwargs):
"""Create an error from validation exception."""
errors = []
def flatten(error, path=""):
if isinstance(error, halogen.exceptions.ValidationError):
if not path.endswi... |
given a bytes object, should return a base python data
structure that represents the object.
def load(raw_bytes):
"""
given a bytes object, should return a base python data
structure that represents the object.
"""
try:
return yaml.load(raw_bytes)
exc... |
two formats are accepted, for transmute routes. One allows
for a more traditional aiohttp syntax, while the other
allows for a flask-like variant.
.. code-block:: python
# if the path and method are not added in describe.
add_transmute_route("GET", "/route", fn)
... |
this will theoretically be compatible with everything,
as cattrs can handle many basic types as well.
def can_handle(self, cls):
"""
this will theoretically be compatible with everything,
as cattrs can handle many basic types as well.
"""
# cattrs uses a Singledispatch l... |
Converts unstructured data into structured data, recursively.
def load(self, model, value):
"""
Converts unstructured data into structured data, recursively.
"""
try:
return self._cattrs_converter.structure(value, model)
except (ValueError, TypeError) as e:
... |
Convert attrs data into unstructured data with basic types, recursively:
- attrs classes => dictionaries
- Enumeration => values
- Other types are let through without conversion,
such as, int, boolean, dict, other classes.
def dump(self, model, value):
"""
Convert att... |
Detect the cahracter encoding of a file.
:param fp: Open Python file pointer.
:param default: Fallback encoding to use.
:returns: The detected encoding.
.. note:: The file pointer is returned at its original read position.
def detect_encoding(fp, default=None):
"""Detect the cahracter encoding of... |
Deserialization of value.
:return: Deserialized value.
:raises: :class:`halogen.exception.ValidationError` exception if value is not valid.
def deserialize(self, value, **kwargs):
"""Deserialization of value.
:return: Deserialized value.
:raises: :class:`halogen.exception.Vali... |
Determine if value is an instance or subclass of the class Type.
def is_type(value):
"""Determine if value is an instance or subclass of the class Type."""
if isinstance(value, type):
return issubclass(value, Type)
return isinstance(value, Type) |
Serialize every item of the list.
def serialize(self, value, **kwargs):
"""Serialize every item of the list."""
return [self.item_type.serialize(val, **kwargs) for val in value] |
Deserialize every item of the list.
def deserialize(self, value, **kwargs):
"""Deserialize every item of the list."""
if self.allow_scalar and not isinstance(value, (list, tuple)):
value = [value]
value = super(List, self).deserialize(value)
result = []
errors = []
... |
Format UTC times.
def format_as_utc(self, value):
"""Format UTC times."""
if isinstance(value, datetime.datetime):
if value.tzinfo is not None:
value = value.astimezone(pytz.UTC)
value = value.replace(microsecond=0)
return value.isoformat().replace('+00:0... |
Return the dictionary representation of an Amount object.
Amount object must have amount and currency properties and as_tuple method which will return (currency, amount)
and as_quantized method to quantize amount property.
:param amount: instance of Amount object
:return: dict with am... |
Deserialize the amount.
:param value: Amount in CURRENCYAMOUNT or {"currency": CURRENCY, "amount": AMOUNT} format. For example EUR35.50
or {"currency": "EUR", "amount": "35.50"}
:return: A paylogic Amount object.
:raises ValidationError: when amount can"t be deserialzied
:r... |
given a bytes object, should return a base python data
structure that represents the object.
def load(raw_bytes):
"""
given a bytes object, should return a base python data
structure that represents the object.
"""
try:
if not isinstance(raw_bytes, string_typ... |
a decorator that adds a transmute route to the application.
def add_route(app, fn, context=default_context):
"""
a decorator that adds a transmute route to the application.
"""
transmute_func = TransmuteFunction(
fn,
args_not_from_request=["request"]
)
handler = create_handler(t... |
Preview file for given record.
Plug this method into your ``RECORDS_UI_ENDPOINTS`` configuration:
.. code-block:: python
RECORDS_UI_ENDPOINTS = dict(
recid=dict(
# ...
route='/records/<pid_value/preview/<path:filename>',
view_imp='invenio_pr... |
Function for creating a template script or tool.
:param template: template to be used ; one of TEMPLATES
:param target: type of script/tool to be created
:param name: name of the new script/tool
def new(template, target=None, name=None):
"""
Function for creating a template script or too... |
a convenience method for both adding a swagger.json route,
as well as adding a page showing the html documentation
def add_swagger(app, json_route, html_route, **kwargs):
"""
a convenience method for both adding a swagger.json route,
as well as adding a page showing the html documentation
"""
a... |
mount a swagger statics page.
app: the flask app object
target_route: the path to mount the statics page.
swagger_json_route: the path where the swagger json definitions is
expected to be.
def add_swagger_api_route(app, target_route, swagger_json_route):
"""
mount a swagger statics page.
... |
Create a handler that returns the swagger definition
for an application.
This method assumes the application is using the
TransmuteUrlDispatcher as the router.
def create_swagger_json_handler(app, **kwargs):
"""
Create a handler that returns the swagger definition
for an application.
This... |
Command for working with test data.
def fixtures():
"""Command for working with test data."""
temp_path = os.path.join(os.path.dirname(__file__), 'temp')
demo_files_path = os.path.join(os.path.dirname(__file__), 'demo_files')
# Create location
loc = Location(name='local', uri=temp_path, default=Tr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.