Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
the-infinity committed Nov 10, 2023
1 parent dfe232b commit dc3f2fd
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 25 deletions.
3 changes: 1 addition & 2 deletions webapp/common/dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Use of this source code is governed by an MIT-style license that can be found in the LICENSE.txt.
"""

from dataclasses import is_dataclass, asdict
from dataclasses import asdict, is_dataclass
from typing import Any

from validataclass.helpers import UnsetValue
Expand All @@ -26,6 +26,5 @@ def filter_unset_value(data: Any) -> Any:


class DataclassMixin:

def to_dict(self):
return filter_unset_value(recursive_to_dict(self))
6 changes: 6 additions & 0 deletions webapp/public_rest_api/datex2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Copyright 2023 binary butterfly GmbH
Use of this source code is governed by an MIT-style license that can be found in the LICENSE.txt.
"""

from .datex2_rest_api import Datex2Blueprint
12 changes: 8 additions & 4 deletions webapp/public_rest_api/datex2/datex2_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@

from webapp.models import ParkingSite
from webapp.models.parking_site import OpeningStatus, ParkingSiteType
from webapp.public_rest_api.datex2.datex2_models import Datex2ParkingSite, Datex2LocationAndDimension, Datex2Coordinate, \
Datex2ParkingSiteType, Datex2Publication, Datex2ParkingPublicationLight
from webapp.public_rest_api.datex2.datex2_models import (
Datex2Coordinate,
Datex2LocationAndDimension,
Datex2ParkingPublicationLight,
Datex2ParkingSite,
Datex2ParkingSiteType,
Datex2Publication,
)


class Datex2Mapper:

def map_parking_sites(self, name: str, parking_sites: list[ParkingSite]) -> Datex2Publication:
publication = Datex2Publication(
parkingPublicationLight=Datex2ParkingPublicationLight(
Expand Down Expand Up @@ -66,5 +71,4 @@ def map_parking_site_type(parking_site_type: ParkingSiteType) -> Datex2ParkingSi
ParkingSiteType.ON_STREET: Datex2ParkingSiteType.onStreet,
ParkingSiteType.UNDERGROUND: Datex2ParkingSiteType.carPark,
ParkingSiteType.OFF_STREET_PARKING_GROUND: Datex2ParkingSiteType.offStreetParkingGround,

}.get(parking_site_type, Datex2ParkingSiteType.other)
1 change: 1 addition & 0 deletions webapp/public_rest_api/datex2/datex2_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from webapp.public_rest_api.base_blueprint import PublicApiBaseBlueprint
from webapp.public_rest_api.base_method_view import PublicApiBaseMethodView
from webapp.shared.parking_site.parking_site_search_query import ParkingSiteSearchInput

from .datex2_handler import Datex2Handler
from .datex2_schema import (
datex2_parking_sites_example,
Expand Down
43 changes: 25 additions & 18 deletions webapp/public_rest_api/datex2/datex2_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,33 @@
Use of this source code is governed by an MIT-style license that can be found in the LICENSE.txt.
"""

from flask_openapi.schema import JsonSchema, StringField, ObjectField, ArrayField, DateTimeField, IntegerField, EnumField, BooleanField, \
UriField, NumericField
from flask_openapi.schema import (
ArrayField,
BooleanField,
DateTimeField,
EnumField,
IntegerField,
JsonSchema,
NumericField,
ObjectField,
StringField,
UriField,
)

from webapp.public_rest_api.datex2.datex2_models import (
Datex2Availability,
Datex2Accessibility,
Datex2AssignmentType,
Datex2Availability,
Datex2FuelType,
Datex2ParkingOccupancyTrend,
Datex2ParkingSiteType,
Datex2FuelType,
Datex2AssignmentType,
Datex2UserType,
Datex2VehicleType,
)


datex2_coordinate_schema = ObjectField(
description='A pair of planar coordinates defining the geodetic position of a single point using the European Terrestrial Reference '
'System 1989 (ETRS89).',
'System 1989 (ETRS89).',
properties={
'latitude': NumericField(description='Latitude in decimal degrees using the European Terrestrial Reference System 1989 (ETRS89).'),
'longitude': NumericField(
Expand All @@ -36,14 +45,14 @@

datex2_dimension = ObjectField(
description='A component that provides dimension information. The product of width and height must not be necessarily be the square '
'footage (e.g. in multi-storey buildings or when some zones are not part of the square footage).',
'footage (e.g. in multi-storey buildings or when some zones are not part of the square footage).',
properties={
'height': NumericField(required=False, description='Height in meters.'),
'length': NumericField(required=False, description='Length in meters.'),
'orientationOfLengthAxis': NumericField(
required=False,
description='The orientation of the length axis in degree. In the case of a parking space, this corresponds to the direction,'
' in which a vehicle is parked.',
' in which a vehicle is parked.',
),
'usableArea': NumericField(
required=False,
Expand All @@ -61,7 +70,7 @@
minimum=0,
required=False,
description='The total number of currently vacant parking spaces within this site for the given assignment. (e.g. for lorries).'
' Use only with type of assignment = "optimised" or "allowed". Do not use when describing a single parking space.',
' Use only with type of assignment = "optimised" or "allowed". Do not use when describing a single parking space.',
),
'fuelType': EnumField(enum=Datex2FuelType, required=False, description='The type of fuel this assignment refers to.'),
'typeOfAssignment': EnumField(
Expand All @@ -82,7 +91,7 @@
'level': IntegerField(
required=False,
description='The level of the parking space (0 = ground etc.), or the first level of the entire parking site (for example, if '
'a parking site is located on the roof of a building).',
'a parking site is located on the roof of a building).',
),
'locationDescriptor': StringField(required=False, description='Supplementary human-readable description of the location'),
'roadName': StringField(required=False, description='Information on a road'),
Expand All @@ -91,14 +100,14 @@
items=StringField(),
required=False,
description='Information on one specific access (entrance or exit) in human readable text, for example the corresponding road '
'where it is located.',
'where it is located.',
),
},
)

datex_2_parking_site_schema = ObjectField(
description='A collection of parking spaces within a building, an open ground or some on street area. Usually seen as one entity and'
' manged as such.',
' manged as such.',
properties={
'_id': StringField(),
'assignedFor': ArrayField(items=datex2_assignment_schema, required=False),
Expand Down Expand Up @@ -156,13 +165,13 @@
'temporaryClosed': BooleanField(
required=False,
description='True, if the parking site is closed ignoring its regular opening times, for example due to maintenance or '
'constructions.',
'constructions.',
),
'type': EnumField(enum=Datex2ParkingSiteType, description='Type of this parking site.'),
'urlLinkAddress': UriField(
required=False,
description='A Uniform Resource Locator (URL) address pointing to a resource available on the Internet from where further '
'relevant information may be obtained.',
'relevant information may be obtained.',
),
'zoneDescription': ArrayField(
items=StringField(),
Expand Down Expand Up @@ -223,6 +232,4 @@
},
)

datex2_parking_sites_example = {

}
datex2_parking_sites_example = {}
2 changes: 1 addition & 1 deletion webapp/public_rest_api/public_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from webapp.common.blueprint import Blueprint

from .base_blueprint import PublicApiBaseBlueprint
from .datex2.datex2_rest_api import Datex2Blueprint
from .datex2 import Datex2Blueprint
from .park_api_v1 import ParkApiV1Blueprint
from .park_api_v2 import ParkApiV2Blueprint
from .parking_sites import ParkingSiteBlueprint
Expand Down

0 comments on commit dc3f2fd

Please sign in to comment.