code styling: add comments and fix pep8

This commit is contained in:
Marco Thomas
2022-07-27 17:58:29 +02:00
parent 68885ff560
commit 8a0a59c222
4 changed files with 49 additions and 12 deletions

View File

@@ -1,14 +1,24 @@
"""
All types used in the project
"""
from enum import Enum
import math
class ParsingMode(Enum):
"""
Used for parsing
"""
LOCATIONS = 1
FLIGHTSCHEDULE = 2
FINDCONNECTION = 3
class LocationType(Enum):
"""
Differenciate between types of location
"""
LOCATION = 1
HALTESTELLE = 2
FLUGHAFEN = 3
@@ -27,6 +37,10 @@ class TransportData():
class TransportMethod(Enum):
"""
More precise methods of transportation.
They are subgroups of TransportKind.
"""
WALK = TransportData(0, 4)
CITY = TransportData(0.189, 30)
AUTOBAHN = TransportData(0.189, 100)
@@ -37,7 +51,8 @@ class TransportMethod(Enum):
class TransportKind(Enum):
"""
distance_penalty
General transportation kind.
Value: distance_penalty
"""
INDIVIDUAL = 0.2
TRAIN = 0.1
@@ -57,14 +72,20 @@ class Coordinate:
class Location:
def __init__(self, coord: Coordinate, continent: int, name: str, type: LocationType):
def __init__(
self,
coord: Coordinate,
continent: int,
name: str,
type: LocationType):
self.coord = coord
self.continent = continent
self.name = name
self.type = type
def __str__(self):
return f"{{Location: {self.coord}, continent: {self.continent}, name: {self.name}, type: {self.type}}}"
return f"{{Location: {self.coord}, continent: {self.continent}, \
name: {self.name}, type: {self.type}}}"
def __repr__(self):
return self.__str__()
@@ -88,13 +109,18 @@ class Location:
class DataSet:
"""
Represent the parsed data
"""
def __init__(self, locations: dict, flights: dict, connection: tuple):
self.locations = locations
self.flights = flights
self.connection = connection
def __str__(self):
return f"locations: {self.locations}, flights: {self.flights}, connection: {self.connection}"
return f"locations: {self.locations}, flights: {self.flights}, \
connection: {self.connection}"
def __repr__(self):
return self.__str__()