Skip to content

Commit

Permalink
Ran Isort
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Collins committed Sep 3, 2020
1 parent 04af64c commit 264474b
Show file tree
Hide file tree
Showing 59 changed files with 217 additions and 279 deletions.
11 changes: 5 additions & 6 deletions examples/nested_thing.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import random
import logging
import math
import random
import uuid
import logging

from labthings.server.quick import create_app
from labthings.server.view import PropertyView
from labthings.server import fields
from labthings.server.find import find_component
from labthings.server.quick import create_app
from labthings.server.schema import Schema
from labthings.server import fields

from labthings.server.view import PropertyView

"""
Class for our lab component functionality. This could include serial communication,
Expand Down
15 changes: 6 additions & 9 deletions examples/simple_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

patch_all()

import random
import logging
import math
import random
import time
import logging

from labthings.server.quick import create_app
from labthings.server.view import ActionView, PropertyView
from labthings.server.find import find_component
from labthings.server import fields
from labthings.core.utilities import path_relative_to

from labthings.server import fields
from labthings.server.extensions import BaseExtension

import logging
from labthings.server.find import find_component
from labthings.server.quick import create_app
from labthings.server.view import ActionView, PropertyView

logging.basicConfig(level=logging.DEBUG)

Expand Down
5 changes: 2 additions & 3 deletions examples/simple_thing.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env python
import time

from labthings import create_app, semantics, find_component, fields
from labthings.views import ActionView, PropertyView, op
from labthings import create_app, fields, find_component, semantics
from labthings.example_components import PretendSpectrometer
from labthings.json import encode_json

from labthings.views import ActionView, PropertyView, op

"""
Class for our lab component functionality. This could include serial communication,
Expand Down
43 changes: 12 additions & 31 deletions src/labthings/__init__.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
# Main LabThing class
# Submodules
from . import extensions, fields, json, marshalling, semantics, views
# Action threads
from .actions import (ActionKilledException, current_action,
update_action_data, update_action_progress)
# Functions to speed up finding global objects
from .find import (current_labthing, find_component, find_extension,
registered_components, registered_extensions)
from .labthing import LabThing

# Quick-create app+LabThing function
from .quick import create_app

# Suggested WSGI+WebSocket server class
from .wsgi import Server

# Functions to speed up finding global objects
from .find import current_labthing
from .find import registered_extensions
from .find import registered_components
from .find import find_extension
from .find import find_component

# Synchronisation classes
from .sync import StrictLock
from .sync import CompositeLock
from .sync import ClientEvent

# Action threads
from .actions import current_action
from .actions import update_action_progress
from .actions import update_action_data
from .actions import ActionKilledException

# Schema and field
from .schema import Schema
from . import fields

# Submodules
from . import extensions
from . import views
from . import marshalling
from . import semantics
from . import json
# Synchronisation classes
from .sync import ClientEvent, CompositeLock, StrictLock
# Suggested WSGI+WebSocket server class
from .wsgi import Server

__all__ = [
"LabThing",
Expand Down
10 changes: 3 additions & 7 deletions src/labthings/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
"ActionKilledException",
]

from .pool import (
Pool,
current_action,
update_action_progress,
update_action_data,
)
from .thread import ActionThread, ActionKilledException
from .pool import (Pool, current_action, update_action_data,
update_action_progress)
from .thread import ActionKilledException, ActionThread

__all__ = [
"Pool",
Expand Down
2 changes: 1 addition & 1 deletion src/labthings/actions/pool.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import threading
from functools import wraps

import threading
from .thread import ActionThread


Expand Down
5 changes: 3 additions & 2 deletions src/labthings/actions/thread.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import ctypes
from flask import copy_current_request_context, has_request_context
import datetime
import logging
import threading
import traceback
import uuid
import threading

from flask import copy_current_request_context, has_request_context

from ..utilities import TimeoutTracker

Expand Down
2 changes: 1 addition & 1 deletion src/labthings/apispec/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .plugins import MarshmallowPlugin, FlaskLabThingsPlugin
from .plugins import FlaskLabThingsPlugin, MarshmallowPlugin

__all__ = ["MarshmallowPlugin", "FlaskLabThingsPlugin"]
13 changes: 6 additions & 7 deletions src/labthings/apispec/plugins.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from apispec.ext.marshmallow import MarshmallowPlugin as _MarshmallowPlugin
from apispec.ext.marshmallow import OpenAPIConverter
import re

from flask.views import http_method_funcs

from apispec import BasePlugin
from apispec.ext.marshmallow import MarshmallowPlugin as _MarshmallowPlugin
from apispec.ext.marshmallow import OpenAPIConverter
from flask.views import http_method_funcs

from ..utilities import merge, get_docstring, get_summary
from ..views import PropertyView, ActionView
from .. import fields
from ..json.schemas import schema_to_json
from ..schema import build_action_schema
from .. import fields
from ..utilities import get_docstring, get_summary, merge
from ..views import ActionView, PropertyView


class ExtendedOpenAPIConverter(OpenAPIConverter):
Expand Down
6 changes: 3 additions & 3 deletions src/labthings/default_views/actions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from flask import abort

from ..views import View
from .. import fields
from ..find import current_labthing
from ..marshalling import use_args
from ..schema import ActionSchema
from ..find import current_labthing
from .. import fields
from ..views import View


class ActionQueueView(View):
Expand Down
4 changes: 2 additions & 2 deletions src/labthings/default_views/docs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from flask import render_template, Blueprint, make_response
from flask import Blueprint, make_response, render_template

from ...views import View
from ...find import current_labthing
from ...views import View


class APISpecView(View):
Expand Down
2 changes: 1 addition & 1 deletion src/labthings/default_views/extensions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Top-level representation of attached and enabled Extensions"""
from ..views import View
from ..find import registered_extensions
from ..schema import ExtensionSchema
from ..views import View


class ExtensionList(View):
Expand Down
5 changes: 2 additions & 3 deletions src/labthings/default_views/sockets.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from ..sockets import SocketSubscriber
from ..find import current_labthing

import logging

from ..find import current_labthing
from ..sockets import SocketSubscriber

STATIC_SOCKET_RESPONSES = {"__unittest": "__unittest_response"}

Expand Down
2 changes: 1 addition & 1 deletion src/labthings/example_components/spectrometer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import random
import math
import random
import time


Expand Down
12 changes: 6 additions & 6 deletions src/labthings/extensions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import glob
import logging
import os
import sys
import traceback
from flask import url_for

from importlib import util
import sys
import os
import glob

from flask import url_for

from .utilities import camel_to_snake, get_docstring, snake_to_spine
from .views.static import static_from
from .utilities import get_docstring, camel_to_snake, snake_to_spine


class BaseExtension:
Expand Down
38 changes: 5 additions & 33 deletions src/labthings/fields.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,12 @@
# Marshmallow fields
from marshmallow import ValidationError

from base64 import b64decode

from marshmallow import ValidationError
from marshmallow.fields import (
Field,
Raw,
Nested,
Mapping,
Dict,
List,
Tuple,
String,
UUID,
Number,
Integer,
Decimal,
Boolean,
Float,
DateTime,
NaiveDateTime,
AwareDateTime,
Time,
Date,
TimeDelta,
Url,
URL,
Email,
Method,
Function,
Str,
Bool,
Int,
Constant,
Pluck,
)
URL, UUID, AwareDateTime, Bool, Boolean, Constant, Date, DateTime, Decimal,
Dict, Email, Field, Float, Function, Int, Integer, List, Mapping, Method,
NaiveDateTime, Nested, Number, Pluck, Raw, Str, String, Time, TimeDelta,
Tuple, Url)

__all__ = [
"Bytes",
Expand Down
3 changes: 2 additions & 1 deletion src/labthings/find.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging
from flask import current_app, url_for
import weakref

from flask import current_app, url_for

from .names import EXTENSION_NAME

__all__ = [
Expand Down
7 changes: 3 additions & 4 deletions src/labthings/httperrorhandler.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from flask import escape
from werkzeug.exceptions import default_exceptions
from werkzeug.exceptions import HTTPException

import logging

from flask import escape
from werkzeug.exceptions import HTTPException, default_exceptions


class SerializedExceptionHandler:

Expand Down
5 changes: 3 additions & 2 deletions src/labthings/json/encoder.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Flask JSON encoder so we get UUID, datetime etc support
from flask.json import JSONEncoder
import json
from base64 import b64encode
from collections import UserString
import json

from flask.json import JSONEncoder


class LabThingsJSONEncoder(JSONEncoder):
Expand Down
5 changes: 3 additions & 2 deletions src/labthings/json/marshmallow_jsonschema/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import uuid
from inspect import isclass

from marshmallow import fields, missing, Schema, validate
from marshmallow import Schema, fields, missing, validate
from marshmallow.class_registry import get_class

from .exceptions import UnsupportedValueError
from .validation import handle_length, handle_one_of, handle_range, handle_regexp
from .validation import (handle_length, handle_one_of, handle_range,
handle_regexp)

__all__ = ("JSONSchema",)

Expand Down
7 changes: 4 additions & 3 deletions src/labthings/json/schemas.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import werkzeug.routing
import re
from marshmallow import Schema, fields
from collections.abc import Mapping
from .marshmallow_jsonschema import JSONSchema

import werkzeug.routing
from marshmallow import Schema, fields

from .marshmallow_jsonschema import JSONSchema

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

0 comments on commit 264474b

Please sign in to comment.