Skip to content

Commit ab7902e

Browse files
authored
Merge pull request #114 from labthings/100-restructure
Structural flattening and reorganisation
2 parents efe2be7 + f0b8f48 commit ab7902e

File tree

157 files changed

+7916
-2953
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+7916
-2953
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[run]
22
branch = True
33
source = ./src/labthings
4-
omit = .venv/*, ./src/labthings/server/wsgi/*, ./src/labthings/server/monkey.py
4+
omit = .venv/*, ./src/labthings/wsgi.py, ./src/labthings/monkey.py, ./src/labthings/server/*, ./src/labthings/core/*
55
concurrency = greenlet
66

77
[report]

examples/simple_thing.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#!/usr/bin/env python
2-
from gevent import monkey
2+
from labthings import monkey
33

4-
# Patch most system modules. Leave threads untouched so we can still use them normally if needed.
5-
print("Monkey patching with Gevenet")
6-
monkey.patch_all(thread=False)
7-
print("Monkey patching successful")
4+
monkey.patch_all()
85

96
import random
107
import math
@@ -25,11 +22,6 @@
2522
"""
2623

2724

28-
from gevent.monkey import get_original
29-
30-
get_ident = get_original("_thread", "get_ident")
31-
32-
3325
class MyComponent:
3426
def __init__(self):
3527
self.x_range = range(-100, 100)

poetry.lock

Lines changed: 1 addition & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ flask-cors = "^3.0.8"
2121
gevent = ">=1.4,<21.0"
2222
gevent-websocket = "^0.10.1"
2323
zeroconf = ">=0.24.5,<0.28.0"
24-
cbor2 = "^5.1.0"
2524

2625
[tool.poetry.dev-dependencies]
2726
pytest = "^5.4"

src/labthings/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
from .core import tasks, lock

src/labthings/apispec/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .apispec import rule_to_apispec_path
2+
from .plugins import MarshmallowPlugin
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from apispec import APISpec
2-
from .paths import rule_to_path, rule_to_params
2+
from ..json.paths import rule_to_path, rule_to_params
33
from .utilities import convert_to_schema_or_json
44

5-
from labthings.core.utilities import get_docstring, get_summary
5+
from ..utilities import get_docstring, get_summary
66

77
from werkzeug.routing import Rule
88
from http import HTTPStatus

src/labthings/apispec/converter.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from apispec.ext.marshmallow import OpenAPIConverter
2+
3+
4+
class ExtendedOpenAPIConverter(OpenAPIConverter):
5+
field_mapping = OpenAPIConverter.field_mapping
6+
7+
def init_attribute_functions(self, *args, **kwargs):
8+
OpenAPIConverter.init_attribute_functions(self, *args, **kwargs)
9+
self.attribute_functions.append(self.bytes2json)
10+
11+
def bytes2json(self, field, **kwargs):
12+
ret = {}
13+
if hasattr(field, "_jsonschema_type_mapping"):
14+
schema = field._jsonschema_type_mapping()
15+
ret.update(schema)
16+
return ret

src/labthings/apispec/plugins.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from apispec.ext.marshmallow import MarshmallowPlugin as _MarshmallowPlugin
2+
from .converter import ExtendedOpenAPIConverter
3+
4+
5+
class MarshmallowPlugin(_MarshmallowPlugin):
6+
Converter = ExtendedOpenAPIConverter

0 commit comments

Comments
 (0)