Commit c13648b1 authored by Marius Kriegerowski's avatar Marius Kriegerowski
Browse files

Add blank lines after doc-strings

parent ff3abd15
......@@ -23,6 +23,7 @@ from collections import defaultdict
def group_tags(occupancy_mapping: list[dict[str, str]]) -> dict[str, dict[str, str]]:
"""Extract groups of identical tags and group them in nested dicts."""
grouped_tag_mapping = defaultdict(dict)
for row in occupancy_mapping:
......@@ -62,6 +63,7 @@ class OccupancyMapper:
@classmethod
def read_csv(cls, fn: str) -> list[dict[str, str]]:
"""Read content from csv into list of dicts."""
with open(fn) as csvfile:
mapping = list(csv.DictReader(csvfile))
......@@ -70,6 +72,7 @@ class OccupancyMapper:
@classmethod
def from_csv(cls, fn: str) -> OccupancyMapper:
"""Read a csv and initialize a `OccupancyMapper`."""
occupancy_mapping = cls.read_csv(fn)
occupancy_mapping_grouped = group_tags(occupancy_mapping)
......@@ -88,6 +91,8 @@ class OverridingOccupancy:
self.mapping = mapping
def apply(self, occupancies: list[str]):
"""Apply the loaded mapping to a list of `occupancies`."""
for candidate, occupancy in self.mapping.items():
if candidate in occupancies:
return occupancy
......@@ -98,6 +103,7 @@ class OverridingOccupancy:
@classmethod
def read_csv(cls, fn: str) -> dict[str, str]:
"""Read content from csv into list of dicts."""
with open(fn) as csvfile:
mapping = {k.strip(): v.strip() for (k, v) in csv.reader(csvfile)}
......@@ -106,6 +112,6 @@ class OverridingOccupancy:
@classmethod
def from_csv(cls, fn: str) -> OverridingOccupancy:
"""Read a csv and initialize a `OverridingOccupancy` instance."""
occupancy_mapping = cls.read_csv(fn)
occupancy_mapping = cls.read_csv(fn)
return cls(mapping=occupancy_mapping)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment