Correctly place teal imports

This commit is contained in:
Xavier Bustamante Talavera 2018-09-07 12:38:02 +02:00
parent ca7c89633b
commit 804a696390
30 changed files with 58 additions and 53 deletions

View File

@ -1,9 +1,9 @@
from sqlalchemy.exc import DataError from sqlalchemy.exc import DataError
from teal.auth import TokenAuth
from teal.db import ResourceNotFound
from werkzeug.exceptions import Unauthorized from werkzeug.exceptions import Unauthorized
from ereuse_devicehub.resources.user.models import User from ereuse_devicehub.resources.user.models import User
from teal.auth import TokenAuth
from teal.db import ResourceNotFound
class Auth(TokenAuth): class Auth(TokenAuth):

View File

@ -1,13 +1,13 @@
from inspect import isclass from inspect import isclass
from typing import Any, Dict, Iterable, Tuple, Type, Union from typing import Any, Dict, Iterable, Tuple, Type, Union
from ereuse_utils.test import JSON
from flask import Response from flask import Response
from teal.client import Client as TealClient
from teal.marshmallow import ValidationError
from werkzeug.exceptions import HTTPException from werkzeug.exceptions import HTTPException
from ereuse_devicehub.resources import models, schemas from ereuse_devicehub.resources import models, schemas
from ereuse_utils.test import JSON
from teal.client import Client as TealClient
from teal.marshmallow import ValidationError
class Client(TealClient): class Client(TealClient):

View File

@ -2,13 +2,14 @@ from distutils.version import StrictVersion
from itertools import chain from itertools import chain
from typing import Set from typing import Set
from ereuse_devicehub.resources import agent, device, event, inventory, lot, tag, user
from ereuse_devicehub.resources.enums import PriceSoftware, RatingSoftware
from teal.auth import TokenAuth from teal.auth import TokenAuth
from teal.config import Config from teal.config import Config
from teal.enums import Currency from teal.enums import Currency
from teal.utils import import_resource from teal.utils import import_resource
from ereuse_devicehub.resources import agent, device, event, inventory, lot, tag, user
from ereuse_devicehub.resources.enums import PriceSoftware, RatingSoftware
class DevicehubConfig(Config): class DevicehubConfig(Config):
RESOURCE_DEFINITIONS = set(chain(import_resource(device), RESOURCE_DEFINITIONS = set(chain(import_resource(device),

View File

@ -1,13 +1,13 @@
from typing import Type from typing import Type
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from teal.config import Config as ConfigClass
from teal.teal import Teal
from ereuse_devicehub.auth import Auth from ereuse_devicehub.auth import Auth
from ereuse_devicehub.client import Client from ereuse_devicehub.client import Client
from ereuse_devicehub.db import db from ereuse_devicehub.db import db
from ereuse_devicehub.dummy.dummy import Dummy from ereuse_devicehub.dummy.dummy import Dummy
from teal.config import Config as ConfigClass
from teal.teal import Teal
class Devicehub(Teal): class Devicehub(Teal):

View File

@ -1,9 +1,9 @@
from marshmallow.fields import missing_ from marshmallow.fields import missing_
from ereuse_devicehub.db import db
from teal.db import SQLAlchemy from teal.db import SQLAlchemy
from teal.marshmallow import NestedOn as TealNestedOn from teal.marshmallow import NestedOn as TealNestedOn
from ereuse_devicehub.db import db
class NestedOn(TealNestedOn): class NestedOn(TealNestedOn):
__doc__ = TealNestedOn.__doc__ __doc__ = TealNestedOn.__doc__

View File

@ -1,10 +1,10 @@
import click import click
from flask import current_app as app from flask import current_app as app
from teal.db import SQLAlchemy
from teal.resource import Converters, Resource
from ereuse_devicehub.db import db from ereuse_devicehub.db import db
from ereuse_devicehub.resources.agent import models, schemas from ereuse_devicehub.resources.agent import models, schemas
from teal.db import SQLAlchemy
from teal.resource import Converters, Resource
class AgentDef(Resource): class AgentDef(Resource):

View File

@ -8,13 +8,13 @@ from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.ext.declarative import declared_attr from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import backref, relationship from sqlalchemy.orm import backref, relationship
from sqlalchemy_utils import EmailType, PhoneNumberType from sqlalchemy_utils import EmailType, PhoneNumberType
from ereuse_devicehub.resources.models import STR_SIZE, STR_SM_SIZE, Thing
from ereuse_devicehub.resources.user.models import User
from teal import enums from teal import enums
from teal.db import INHERIT_COND, POLYMORPHIC_ID, \ from teal.db import INHERIT_COND, POLYMORPHIC_ID, \
POLYMORPHIC_ON POLYMORPHIC_ON
from ereuse_devicehub.resources.models import STR_SIZE, STR_SM_SIZE, Thing
from ereuse_devicehub.resources.user.models import User
class JoinedTableMixin: class JoinedTableMixin:
# noinspection PyMethodParameters # noinspection PyMethodParameters

View File

@ -4,12 +4,12 @@ from typing import List, Set
from sqlalchemy import Column from sqlalchemy import Column
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
from sqlalchemy_utils import PhoneNumber from sqlalchemy_utils import PhoneNumber
from teal import enums
from ereuse_devicehub.resources.event.models import Event, Trade from ereuse_devicehub.resources.event.models import Event, Trade
from ereuse_devicehub.resources.models import Thing from ereuse_devicehub.resources.models import Thing
from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.tag.model import Tag
from ereuse_devicehub.resources.user import User from ereuse_devicehub.resources.user import User
from teal import enums
class Agent(Thing): class Agent(Thing):

View File

@ -1,11 +1,11 @@
from marshmallow import fields as ma_fields, validate as ma_validate from marshmallow import fields as ma_fields, validate as ma_validate
from marshmallow.fields import Email from marshmallow.fields import Email
from teal import enums
from teal.marshmallow import EnumField, Phone
from ereuse_devicehub.marshmallow import NestedOn from ereuse_devicehub.marshmallow import NestedOn
from ereuse_devicehub.resources.models import STR_SIZE, STR_SM_SIZE from ereuse_devicehub.resources.models import STR_SIZE, STR_SM_SIZE
from ereuse_devicehub.resources.schemas import Thing from ereuse_devicehub.resources.schemas import Thing
from teal import enums
from teal.marshmallow import EnumField, Phone
class Agent(Thing): class Agent(Thing):

View File

@ -1,6 +1,7 @@
from teal.resource import Converters, Resource
from ereuse_devicehub.resources.device import schemas from ereuse_devicehub.resources.device import schemas
from ereuse_devicehub.resources.device.views import DeviceView from ereuse_devicehub.resources.device.views import DeviceView
from teal.resource import Converters, Resource
class DeviceDef(Resource): class DeviceDef(Resource):

View File

@ -3,6 +3,7 @@ from itertools import chain
from operator import attrgetter from operator import attrgetter
from typing import Dict, Set from typing import Dict, Set
from ereuse_utils.naming import Naming
from sqlalchemy import BigInteger, Boolean, Column, Enum as DBEnum, Float, ForeignKey, Integer, \ from sqlalchemy import BigInteger, Boolean, Column, Enum as DBEnum, Float, ForeignKey, Integer, \
Sequence, SmallInteger, Unicode, inspect Sequence, SmallInteger, Unicode, inspect
from sqlalchemy.ext.declarative import declared_attr from sqlalchemy.ext.declarative import declared_attr
@ -10,13 +11,12 @@ from sqlalchemy.orm import ColumnProperty, backref, relationship, validates
from sqlalchemy.util import OrderedSet from sqlalchemy.util import OrderedSet
from sqlalchemy_utils import ColorType from sqlalchemy_utils import ColorType
from stdnum import imei, meid from stdnum import imei, meid
from teal.db import CASCADE, POLYMORPHIC_ID, POLYMORPHIC_ON, ResourceNotFound, check_range
from teal.marshmallow import ValidationError
from ereuse_devicehub.resources.enums import ComputerChassis, DataStorageInterface, DisplayTech, \ from ereuse_devicehub.resources.enums import ComputerChassis, DataStorageInterface, DisplayTech, \
RamFormat, RamInterface RamFormat, RamInterface
from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE, STR_SM_SIZE, Thing from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE, STR_SM_SIZE, Thing
from ereuse_utils.naming import Naming
from teal.db import CASCADE, POLYMORPHIC_ID, POLYMORPHIC_ON, ResourceNotFound, check_range
from teal.marshmallow import ValidationError
class Device(Thing): class Device(Thing):

View File

@ -3,6 +3,7 @@ from marshmallow.fields import Boolean, Float, Integer, Str
from marshmallow.validate import Length, OneOf, Range from marshmallow.validate import Length, OneOf, Range
from sqlalchemy.util import OrderedSet from sqlalchemy.util import OrderedSet
from stdnum import imei, meid from stdnum import imei, meid
from teal.marshmallow import EnumField, ValidationError
from ereuse_devicehub.marshmallow import NestedOn from ereuse_devicehub.marshmallow import NestedOn
from ereuse_devicehub.resources.device import models as m from ereuse_devicehub.resources.device import models as m
@ -10,7 +11,6 @@ from ereuse_devicehub.resources.enums import ComputerChassis, DataStorageInterfa
RamFormat, RamInterface RamFormat, RamInterface
from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE
from ereuse_devicehub.resources.schemas import Thing, UnitCodes from ereuse_devicehub.resources.schemas import Thing, UnitCodes
from teal.marshmallow import EnumField, ValidationError
class Device(Thing): class Device(Thing):

View File

@ -5,14 +5,14 @@ from typing import Iterable, Set
from sqlalchemy import inspect from sqlalchemy import inspect
from sqlalchemy.exc import IntegrityError from sqlalchemy.exc import IntegrityError
from sqlalchemy.util import OrderedSet from sqlalchemy.util import OrderedSet
from teal.db import ResourceNotFound
from teal.marshmallow import ValidationError
from ereuse_devicehub.db import db from ereuse_devicehub.db import db
from ereuse_devicehub.resources.device.exceptions import NeedsId from ereuse_devicehub.resources.device.exceptions import NeedsId
from ereuse_devicehub.resources.device.models import Component, Computer, Device from ereuse_devicehub.resources.device.models import Component, Computer, Device
from ereuse_devicehub.resources.event.models import Remove from ereuse_devicehub.resources.event.models import Remove
from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.tag.model import Tag
from teal.db import ResourceNotFound
from teal.marshmallow import ValidationError
class Sync: class Sync:

View File

@ -1,6 +1,7 @@
from ereuse_devicehub.resources.device.models import Device
from teal.resource import View from teal.resource import View
from ereuse_devicehub.resources.device.models import Device
class DeviceView(View): class DeviceView(View):

View File

@ -1,9 +1,10 @@
from typing import Callable, Iterable, Tuple from typing import Callable, Iterable, Tuple
from teal.resource import Converters, Resource
from ereuse_devicehub.resources.device.sync import Sync from ereuse_devicehub.resources.device.sync import Sync
from ereuse_devicehub.resources.event import schemas from ereuse_devicehub.resources.event import schemas
from ereuse_devicehub.resources.event.views import EventView, SnapshotView from ereuse_devicehub.resources.event.views import EventView, SnapshotView
from teal.resource import Converters, Resource
class EventDef(Resource): class EventDef(Resource):

View File

@ -9,6 +9,9 @@ from boltons.urlutils import URL
from sqlalchemy import Column from sqlalchemy import Column
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
from sqlalchemy_utils import Currency from sqlalchemy_utils import Currency
from teal import enums
from teal.db import Model
from teal.enums import Country
from ereuse_devicehub.resources.agent.models import Agent from ereuse_devicehub.resources.agent.models import Agent
from ereuse_devicehub.resources.device.models import Component, Computer, Device from ereuse_devicehub.resources.device.models import Component, Computer, Device
@ -18,9 +21,6 @@ from ereuse_devicehub.resources.enums import AppearanceRange, Bios, Functionalit
from ereuse_devicehub.resources.image.models import Image from ereuse_devicehub.resources.image.models import Image
from ereuse_devicehub.resources.models import Thing from ereuse_devicehub.resources.models import Thing
from ereuse_devicehub.resources.user.models import User from ereuse_devicehub.resources.user.models import User
from teal import enums
from teal.db import Model
from teal.enums import Country
class Event(Thing): class Event(Thing):

View File

@ -6,6 +6,9 @@ from marshmallow.fields import Boolean, DateTime, Decimal, Float, Integer, List,
TimeDelta, URL, UUID TimeDelta, URL, UUID
from marshmallow.validate import Length, Range from marshmallow.validate import Length, Range
from sqlalchemy.util import OrderedSet from sqlalchemy.util import OrderedSet
from teal.enums import Country, Currency, Subdivision
from teal.marshmallow import EnumField, IP, Version
from teal.resource import Schema
from ereuse_devicehub.marshmallow import NestedOn from ereuse_devicehub.marshmallow import NestedOn
from ereuse_devicehub.resources.agent.schemas import Agent from ereuse_devicehub.resources.agent.schemas import Agent
@ -17,9 +20,6 @@ from ereuse_devicehub.resources.event import models as m
from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE
from ereuse_devicehub.resources.schemas import Thing from ereuse_devicehub.resources.schemas import Thing
from ereuse_devicehub.resources.user.schemas import User from ereuse_devicehub.resources.user.schemas import User
from teal.enums import Country, Currency, Subdivision
from teal.marshmallow import EnumField, IP, Version
from teal.resource import Schema
class Event(Thing): class Event(Thing):

View File

@ -4,12 +4,12 @@ from sqlalchemy import BigInteger, Column, Enum as DBEnum, ForeignKey, Unicode
from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import backref, relationship from sqlalchemy.orm import backref, relationship
from sqlalchemy.util import OrderedSet from sqlalchemy.util import OrderedSet
from teal.db import CASCADE_OWN
from ereuse_devicehub.db import db from ereuse_devicehub.db import db
from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.resources.enums import ImageMimeTypes, Orientation from ereuse_devicehub.resources.enums import ImageMimeTypes, Orientation
from ereuse_devicehub.resources.models import STR_BIG_SIZE, Thing from ereuse_devicehub.resources.models import STR_BIG_SIZE, Thing
from teal.db import CASCADE_OWN
class ImageList(Thing): class ImageList(Thing):

View File

@ -4,14 +4,14 @@ from marshmallow import Schema as MarshmallowSchema
from marshmallow.fields import Float, Integer, Nested, Str from marshmallow.fields import Float, Integer, Nested, Str
from marshmallow.validate import Range from marshmallow.validate import Range
from sqlalchemy import Column from sqlalchemy import Column
from teal.query import Between, FullTextSearch, ILike, Join, Or, Query, Sort, SortField
from teal.resource import Resource, View
from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.resources.event.models import Rate from ereuse_devicehub.resources.event.models import Rate
from ereuse_devicehub.resources.lot.models import Lot from ereuse_devicehub.resources.lot.models import Lot
from ereuse_devicehub.resources.schemas import Thing from ereuse_devicehub.resources.schemas import Thing
from ereuse_devicehub.resources.tag import Tag from ereuse_devicehub.resources.tag import Tag
from teal.query import Between, FullTextSearch, ILike, Join, Or, Query, Sort, SortField
from teal.resource import Resource, View
class Inventory(Thing): class Inventory(Thing):

View File

@ -1,9 +1,10 @@
import pathlib import pathlib
from teal.resource import Converters, Resource
from ereuse_devicehub.db import db from ereuse_devicehub.db import db
from ereuse_devicehub.resources.lot import schemas from ereuse_devicehub.resources.lot import schemas
from ereuse_devicehub.resources.lot.views import LotView from ereuse_devicehub.resources.lot.views import LotView
from teal.resource import Converters, Resource
class LotDef(Resource): class LotDef(Resource):

View File

@ -1,10 +1,10 @@
import uuid import uuid
from flask import current_app as app, request from flask import current_app as app, request
from teal.resource import View
from ereuse_devicehub.db import db from ereuse_devicehub.db import db
from ereuse_devicehub.resources.lot.models import Lot from ereuse_devicehub.resources.lot.models import Lot
from teal.resource import View
class LotView(View): class LotView(View):

View File

@ -2,9 +2,9 @@ from enum import Enum
from marshmallow import post_load from marshmallow import post_load
from marshmallow.fields import DateTime, List, String, URL from marshmallow.fields import DateTime, List, String, URL
from teal.resource import Schema
from ereuse_devicehub.resources import models as m from ereuse_devicehub.resources import models as m
from teal.resource import Schema
class UnitCodes(Enum): class UnitCodes(Enum):

View File

@ -1,13 +1,13 @@
from typing import Tuple from typing import Tuple
from click import argument, option from click import argument, option
from teal.resource import Resource
from teal.teal import Teal
from ereuse_devicehub.db import db from ereuse_devicehub.db import db
from ereuse_devicehub.resources.tag import schema from ereuse_devicehub.resources.tag import schema
from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.tag.model import Tag
from ereuse_devicehub.resources.tag.view import TagView, get_device_from_tag from ereuse_devicehub.resources.tag.view import TagView, get_device_from_tag
from teal.resource import Resource
from teal.teal import Teal
class TagDef(Resource): class TagDef(Resource):

View File

@ -1,12 +1,12 @@
from sqlalchemy import BigInteger, Column, ForeignKey, Unicode, UniqueConstraint from sqlalchemy import BigInteger, Column, ForeignKey, Unicode, UniqueConstraint
from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import backref, relationship, validates from sqlalchemy.orm import backref, relationship, validates
from teal.db import DB_CASCADE_SET_NULL, URL
from teal.marshmallow import ValidationError
from ereuse_devicehub.resources.agent.models import Organization from ereuse_devicehub.resources.agent.models import Organization
from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.resources.models import Thing from ereuse_devicehub.resources.models import Thing
from teal.db import DB_CASCADE_SET_NULL, URL
from teal.marshmallow import ValidationError
class Tag(Thing): class Tag(Thing):

View File

@ -1,9 +1,9 @@
from marshmallow.fields import String from marshmallow.fields import String
from teal.marshmallow import URL
from ereuse_devicehub.marshmallow import NestedOn from ereuse_devicehub.marshmallow import NestedOn
from ereuse_devicehub.resources.device.schemas import Device from ereuse_devicehub.resources.device.schemas import Device
from ereuse_devicehub.resources.schemas import Thing from ereuse_devicehub.resources.schemas import Thing
from teal.marshmallow import URL
class Tag(Thing): class Tag(Thing):

View File

@ -1,11 +1,11 @@
from flask import Response, current_app as app, request from flask import Response, current_app as app, request
from marshmallow.fields import List, String, URL from marshmallow.fields import List, String, URL
from teal.marshmallow import ValidationError
from teal.resource import Schema, View
from webargs.flaskparser import parser from webargs.flaskparser import parser
from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.resources.tag import Tag from ereuse_devicehub.resources.tag import Tag
from teal.marshmallow import ValidationError
from teal.resource import Schema, View
class TagView(View): class TagView(View):

View File

@ -1,10 +1,10 @@
from click import argument, option from click import argument, option
from teal.resource import Converters, Resource
from ereuse_devicehub.db import db from ereuse_devicehub.db import db
from ereuse_devicehub.resources.user import schemas from ereuse_devicehub.resources.user import schemas
from ereuse_devicehub.resources.user.models import User from ereuse_devicehub.resources.user.models import User
from ereuse_devicehub.resources.user.views import UserView, login from ereuse_devicehub.resources.user.views import UserView, login
from teal.resource import Converters, Resource
class UserDef(Resource): class UserDef(Resource):

View File

@ -1,11 +1,11 @@
from uuid import UUID from uuid import UUID
from flask import g, request from flask import g, request
from teal.resource import View
from ereuse_devicehub.resources.user.exceptions import WrongCredentials from ereuse_devicehub.resources.user.exceptions import WrongCredentials
from ereuse_devicehub.resources.user.models import User from ereuse_devicehub.resources.user.models import User
from ereuse_devicehub.resources.user.schemas import User as UserS from ereuse_devicehub.resources.user.schemas import User as UserS
from teal.resource import View
class UserView(View): class UserView(View):