Skip to content

Commit 264474b

Browse files
author
Joel Collins
committed
Ran Isort
1 parent 04af64c commit 264474b

Some content is hidden

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

59 files changed

+217
-279
lines changed

examples/nested_thing.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import random
1+
import logging
22
import math
3+
import random
34
import uuid
4-
import logging
55

6-
from labthings.server.quick import create_app
7-
from labthings.server.view import PropertyView
6+
from labthings.server import fields
87
from labthings.server.find import find_component
8+
from labthings.server.quick import create_app
99
from labthings.server.schema import Schema
10-
from labthings.server import fields
11-
10+
from labthings.server.view import PropertyView
1211

1312
"""
1413
Class for our lab component functionality. This could include serial communication,

examples/simple_extensions.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22

33
patch_all()
44

5-
import random
5+
import logging
66
import math
7+
import random
78
import time
8-
import logging
99

10-
from labthings.server.quick import create_app
11-
from labthings.server.view import ActionView, PropertyView
12-
from labthings.server.find import find_component
13-
from labthings.server import fields
1410
from labthings.core.utilities import path_relative_to
15-
11+
from labthings.server import fields
1612
from labthings.server.extensions import BaseExtension
17-
18-
import logging
13+
from labthings.server.find import find_component
14+
from labthings.server.quick import create_app
15+
from labthings.server.view import ActionView, PropertyView
1916

2017
logging.basicConfig(level=logging.DEBUG)
2118

examples/simple_thing.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env python
22
import time
33

4-
from labthings import create_app, semantics, find_component, fields
5-
from labthings.views import ActionView, PropertyView, op
4+
from labthings import create_app, fields, find_component, semantics
65
from labthings.example_components import PretendSpectrometer
76
from labthings.json import encode_json
8-
7+
from labthings.views import ActionView, PropertyView, op
98

109
"""
1110
Class for our lab component functionality. This could include serial communication,

src/labthings/__init__.py

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,21 @@
11
# Main LabThing class
2+
# Submodules
3+
from . import extensions, fields, json, marshalling, semantics, views
4+
# Action threads
5+
from .actions import (ActionKilledException, current_action,
6+
update_action_data, update_action_progress)
7+
# Functions to speed up finding global objects
8+
from .find import (current_labthing, find_component, find_extension,
9+
registered_components, registered_extensions)
210
from .labthing import LabThing
3-
411
# Quick-create app+LabThing function
512
from .quick import create_app
6-
7-
# Suggested WSGI+WebSocket server class
8-
from .wsgi import Server
9-
10-
# Functions to speed up finding global objects
11-
from .find import current_labthing
12-
from .find import registered_extensions
13-
from .find import registered_components
14-
from .find import find_extension
15-
from .find import find_component
16-
17-
# Synchronisation classes
18-
from .sync import StrictLock
19-
from .sync import CompositeLock
20-
from .sync import ClientEvent
21-
22-
# Action threads
23-
from .actions import current_action
24-
from .actions import update_action_progress
25-
from .actions import update_action_data
26-
from .actions import ActionKilledException
27-
2813
# Schema and field
2914
from .schema import Schema
30-
from . import fields
31-
32-
# Submodules
33-
from . import extensions
34-
from . import views
35-
from . import marshalling
36-
from . import semantics
37-
from . import json
15+
# Synchronisation classes
16+
from .sync import ClientEvent, CompositeLock, StrictLock
17+
# Suggested WSGI+WebSocket server class
18+
from .wsgi import Server
3819

3920
__all__ = [
4021
"LabThing",

src/labthings/actions/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55
"ActionKilledException",
66
]
77

8-
from .pool import (
9-
Pool,
10-
current_action,
11-
update_action_progress,
12-
update_action_data,
13-
)
14-
from .thread import ActionThread, ActionKilledException
8+
from .pool import (Pool, current_action, update_action_data,
9+
update_action_progress)
10+
from .thread import ActionKilledException, ActionThread
1511

1612
__all__ = [
1713
"Pool",

src/labthings/actions/pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
2+
import threading
23
from functools import wraps
34

4-
import threading
55
from .thread import ActionThread
66

77

src/labthings/actions/thread.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import ctypes
2-
from flask import copy_current_request_context, has_request_context
32
import datetime
43
import logging
4+
import threading
55
import traceback
66
import uuid
7-
import threading
7+
8+
from flask import copy_current_request_context, has_request_context
89

910
from ..utilities import TimeoutTracker
1011

src/labthings/apispec/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from .plugins import MarshmallowPlugin, FlaskLabThingsPlugin
1+
from .plugins import FlaskLabThingsPlugin, MarshmallowPlugin
22

33
__all__ = ["MarshmallowPlugin", "FlaskLabThingsPlugin"]

src/labthings/apispec/plugins.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
from apispec.ext.marshmallow import MarshmallowPlugin as _MarshmallowPlugin
2-
from apispec.ext.marshmallow import OpenAPIConverter
31
import re
42

5-
from flask.views import http_method_funcs
6-
73
from apispec import BasePlugin
4+
from apispec.ext.marshmallow import MarshmallowPlugin as _MarshmallowPlugin
5+
from apispec.ext.marshmallow import OpenAPIConverter
6+
from flask.views import http_method_funcs
87

9-
from ..utilities import merge, get_docstring, get_summary
10-
from ..views import PropertyView, ActionView
8+
from .. import fields
119
from ..json.schemas import schema_to_json
1210
from ..schema import build_action_schema
13-
from .. import fields
11+
from ..utilities import get_docstring, get_summary, merge
12+
from ..views import ActionView, PropertyView
1413

1514

1615
class ExtendedOpenAPIConverter(OpenAPIConverter):

src/labthings/default_views/actions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from flask import abort
22

3-
from ..views import View
3+
from .. import fields
4+
from ..find import current_labthing
45
from ..marshalling import use_args
56
from ..schema import ActionSchema
6-
from ..find import current_labthing
7-
from .. import fields
7+
from ..views import View
88

99

1010
class ActionQueueView(View):

src/labthings/default_views/docs/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from flask import render_template, Blueprint, make_response
1+
from flask import Blueprint, make_response, render_template
22

3-
from ...views import View
43
from ...find import current_labthing
4+
from ...views import View
55

66

77
class APISpecView(View):

src/labthings/default_views/extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Top-level representation of attached and enabled Extensions"""
2-
from ..views import View
32
from ..find import registered_extensions
43
from ..schema import ExtensionSchema
4+
from ..views import View
55

66

77
class ExtensionList(View):

src/labthings/default_views/sockets.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from ..sockets import SocketSubscriber
2-
from ..find import current_labthing
3-
41
import logging
52

3+
from ..find import current_labthing
4+
from ..sockets import SocketSubscriber
65

76
STATIC_SOCKET_RESPONSES = {"__unittest": "__unittest_response"}
87

src/labthings/example_components/spectrometer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import random
21
import math
2+
import random
33
import time
44

55

src/labthings/extensions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import glob
12
import logging
3+
import os
4+
import sys
25
import traceback
3-
from flask import url_for
4-
56
from importlib import util
6-
import sys
7-
import os
8-
import glob
97

8+
from flask import url_for
9+
10+
from .utilities import camel_to_snake, get_docstring, snake_to_spine
1011
from .views.static import static_from
11-
from .utilities import get_docstring, camel_to_snake, snake_to_spine
1212

1313

1414
class BaseExtension:

src/labthings/fields.py

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,12 @@
11
# Marshmallow fields
2-
from marshmallow import ValidationError
3-
42
from base64 import b64decode
53

4+
from marshmallow import ValidationError
65
from marshmallow.fields import (
7-
Field,
8-
Raw,
9-
Nested,
10-
Mapping,
11-
Dict,
12-
List,
13-
Tuple,
14-
String,
15-
UUID,
16-
Number,
17-
Integer,
18-
Decimal,
19-
Boolean,
20-
Float,
21-
DateTime,
22-
NaiveDateTime,
23-
AwareDateTime,
24-
Time,
25-
Date,
26-
TimeDelta,
27-
Url,
28-
URL,
29-
Email,
30-
Method,
31-
Function,
32-
Str,
33-
Bool,
34-
Int,
35-
Constant,
36-
Pluck,
37-
)
6+
URL, UUID, AwareDateTime, Bool, Boolean, Constant, Date, DateTime, Decimal,
7+
Dict, Email, Field, Float, Function, Int, Integer, List, Mapping, Method,
8+
NaiveDateTime, Nested, Number, Pluck, Raw, Str, String, Time, TimeDelta,
9+
Tuple, Url)
3810

3911
__all__ = [
4012
"Bytes",

src/labthings/find.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import logging
2-
from flask import current_app, url_for
32
import weakref
43

4+
from flask import current_app, url_for
5+
56
from .names import EXTENSION_NAME
67

78
__all__ = [

src/labthings/httperrorhandler.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
from flask import escape
2-
from werkzeug.exceptions import default_exceptions
3-
from werkzeug.exceptions import HTTPException
4-
51
import logging
62

3+
from flask import escape
4+
from werkzeug.exceptions import HTTPException, default_exceptions
5+
76

87
class SerializedExceptionHandler:
98

src/labthings/json/encoder.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Flask JSON encoder so we get UUID, datetime etc support
2-
from flask.json import JSONEncoder
2+
import json
33
from base64 import b64encode
44
from collections import UserString
5-
import json
5+
6+
from flask.json import JSONEncoder
67

78

89
class LabThingsJSONEncoder(JSONEncoder):

src/labthings/json/marshmallow_jsonschema/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
import uuid
44
from inspect import isclass
55

6-
from marshmallow import fields, missing, Schema, validate
6+
from marshmallow import Schema, fields, missing, validate
77
from marshmallow.class_registry import get_class
88

99
from .exceptions import UnsupportedValueError
10-
from .validation import handle_length, handle_one_of, handle_range, handle_regexp
10+
from .validation import (handle_length, handle_one_of, handle_range,
11+
handle_regexp)
1112

1213
__all__ = ("JSONSchema",)
1314

src/labthings/json/schemas.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import werkzeug.routing
21
import re
3-
from marshmallow import Schema, fields
42
from collections.abc import Mapping
5-
from .marshmallow_jsonschema import JSONSchema
63

4+
import werkzeug.routing
5+
from marshmallow import Schema, fields
6+
7+
from .marshmallow_jsonschema import JSONSchema
78

89
PATH_RE = re.compile(r"<(?:[^:<>]+:)?([^<>]+)>")
910
# Conversion map of werkzeug rule converters to Javascript schema types

0 commit comments

Comments
 (0)