brittany-ferries/ferry/read_config.py

18 lines
536 B
Python
Raw Normal View History

2023-01-08 12:22:36 +00:00
import configparser
import os.path
from . import Vehicle
ferry_config = configparser.ConfigParser()
ferry_config.read(os.path.expanduser("~edward/config/brittany-ferries/config"))
def vehicle_from_config(config: configparser.ConfigParser) -> Vehicle:
"""Generate a vehicle object from config."""
return Vehicle(
type=config.get("vehicle", "type"),
registration=config.get("vehicle", "registration"),
height=config.getint("vehicle", "height"),
length=config.getint("vehicle", "length"),
)