Blackened
This commit is contained in:
parent
2574e38b47
commit
c85bdcc91d
10 changed files with 49 additions and 30 deletions
|
|
@ -41,4 +41,5 @@ class marshal_with(object):
|
|||
return make_response(self.schema.jsonify(data), code, headers)
|
||||
else:
|
||||
return make_response(self.schema.jsonify(resp))
|
||||
|
||||
return wrapper
|
||||
|
|
|
|||
|
|
@ -72,7 +72,9 @@ class URLFor(Field):
|
|||
self.view_class = None
|
||||
self.endpoint = endpoint
|
||||
else:
|
||||
raise RuntimeError(f"Endpoint {endpoint} is not a valid Flask view or endpoint string.")
|
||||
raise RuntimeError(
|
||||
f"Endpoint {endpoint} is not a valid Flask view or endpoint string."
|
||||
)
|
||||
self.params = kwargs
|
||||
Field.__init__(self, **kwargs)
|
||||
|
||||
|
|
@ -85,7 +87,9 @@ class URLFor(Field):
|
|||
if hasattr(self.view_class, "endpoint"):
|
||||
self.endpoint = self.view_class.endpoint
|
||||
else:
|
||||
raise RuntimeError(f"Resource {self.endpoint} has not been added to a LabThing application. Unable to generate URL.")
|
||||
raise RuntimeError(
|
||||
f"Resource {self.endpoint} has not been added to a LabThing application. Unable to generate URL."
|
||||
)
|
||||
|
||||
# Generate URL for
|
||||
param_values = {}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,14 @@ from . import EXTENSION_NAME
|
|||
|
||||
|
||||
class LabThing(object):
|
||||
def __init__(self, app=None, prefix: str = "", title: str = "", description: str = "", handle_errors: bool = True):
|
||||
def __init__(
|
||||
self,
|
||||
app=None,
|
||||
prefix: str = "",
|
||||
title: str = "",
|
||||
description: str = "",
|
||||
handle_errors: bool = True,
|
||||
):
|
||||
self.app = app
|
||||
|
||||
self.devices = {}
|
||||
|
|
@ -219,7 +226,7 @@ class LabThing(object):
|
|||
|
||||
if self.blueprint:
|
||||
if endpoint.startswith(self.blueprint.name):
|
||||
endpoint = endpoint.split(self.blueprint.name + '.', 1)[-1]
|
||||
endpoint = endpoint.split(self.blueprint.name + ".", 1)[-1]
|
||||
else:
|
||||
return False
|
||||
return endpoint in self.endpoints
|
||||
|
|
@ -254,4 +261,4 @@ class LabThing(object):
|
|||
|
||||
return jsonify(td)
|
||||
|
||||
# TODO: Add a nicer root resource like the old self-documenting system
|
||||
# TODO: Add a nicer root resource like the old self-documenting system
|
||||
|
|
|
|||
|
|
@ -5,10 +5,7 @@ import copy
|
|||
from importlib import util
|
||||
import sys
|
||||
|
||||
from openflexure_microscope.utilities import (
|
||||
camel_to_snake,
|
||||
snake_to_spine,
|
||||
)
|
||||
from openflexure_microscope.utilities import camel_to_snake, snake_to_spine
|
||||
|
||||
|
||||
class BasePlugin:
|
||||
|
|
|
|||
|
|
@ -36,7 +36,11 @@ def plugins_representation(plugin_dict):
|
|||
}
|
||||
|
||||
for view_id, view_data in plugin.views.items():
|
||||
uri = url_for(f"PluginListResource", _external=True) + "/" + view_data["rule"][1:]
|
||||
uri = (
|
||||
url_for(f"PluginListResource", _external=True)
|
||||
+ "/"
|
||||
+ view_data["rule"][1:]
|
||||
)
|
||||
# Make links dictionary if it doesn't yet exist
|
||||
view_d = {"href": uri, **description_from_view(view_data["view"])}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ from openflexure_microscope.common.flask_labthings.schema import Schema
|
|||
from openflexure_microscope.common.flask_labthings import fields
|
||||
from openflexure_microscope.common.labthings_core import tasks
|
||||
from openflexure_microscope.common.flask_labthings.resource import Resource
|
||||
from openflexure_microscope.common.flask_labthings.utilities import description_from_view
|
||||
from openflexure_microscope.common.flask_labthings.utilities import (
|
||||
description_from_view,
|
||||
)
|
||||
|
||||
from marshmallow import pre_dump
|
||||
|
||||
|
|
@ -52,8 +54,8 @@ class TaskSchema(Schema):
|
|||
"self": {
|
||||
"href": url_for(TaskResource.endpoint, id=data.id, _external=True),
|
||||
"mimetype": "application/json",
|
||||
**description_from_view(TaskResource)
|
||||
},
|
||||
**description_from_view(TaskResource),
|
||||
}
|
||||
}
|
||||
return data
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue