Split power tower collections; fix code style.

This commit is contained in:
Sergey Vartanov 2021-11-27 19:28:07 +03:00
parent d2fe421d39
commit 7a74cc56ba

View file

@ -138,7 +138,7 @@ class SVGTable:
def draw_delimiter(self) -> None: def draw_delimiter(self) -> None:
"""Draw line between column and row titles.""" """Draw line between column and row titles."""
if self.column_values: if self.column_values:
line = self.svg.line( line: Line = self.svg.line(
self.start_point - self.half_step - self.border, self.start_point - self.half_step - self.border,
self.start_point self.start_point
- self.half_step - self.half_step
@ -225,10 +225,9 @@ class Collection:
# List of tag values to be used in columns # List of tag values to be used in columns
column_values: list[str] = field(default_factory=list) column_values: list[str] = field(default_factory=list)
def generate_table(self) -> tuple[str, list[Icon]]: def generate_wiki_table(self) -> tuple[str, list[Icon]]:
""" """
Generate Röntgen icon table for the OpenStreetMap wiki page. Generate Röntgen icon table for the OpenStreetMap wiki page.
""" """
icons: list[Icon] = [] icons: list[Icon] = []
text: str = '{| class="wikitable"\n' text: str = '{| class="wikitable"\n'
@ -278,7 +277,7 @@ class Collection:
return text, icons return text, icons
def draw_table(self, svg: Drawing): def draw_table(self, svg: Drawing) -> np.ndarray:
"""Draw SVG table.""" """Draw SVG table."""
table: SVGTable = SVGTable( table: SVGTable = SVGTable(
svg, svg,
@ -409,15 +408,24 @@ collections = [
"two-level", "two-level",
"three-level", "three-level",
"four-level", "four-level",
"donau",
"donau_inverse",
"barrel",
"asymmetric", "asymmetric",
"triangle", "triangle",
"flag", "flag",
"delta", "delta",
"delta_two-level", "delta_two-level",
"delta_three-level", "delta_three-level",
],
),
Collection(
"Key:design_2",
{},
"power",
["tower"],
"design",
[
"donau",
"donau_inverse",
"barrel",
"y-frame", "y-frame",
"x-frame", "x-frame",
"h-frame", "h-frame",
@ -430,17 +438,18 @@ collections = [
] ]
def main() -> None: def draw_svg_tables(output_path: Path, html_file_path: Path) -> None:
with Path("result.html").open("w+") as html_file: """Draw SVG tables of icon collections."""
with html_file_path.open("w+") as html_file:
for collection in collections: for collection in collections:
path: Path = Path("doc") / f"{collection.page_name}.svg" path: Path = output_path / f"{collection.page_name}.svg"
svg: svgwrite = svgwrite.Drawing(path.name) svg: svgwrite = svgwrite.Drawing(path.name)
width, height = collection.draw_table(svg) width, height = collection.draw_table(svg)
svg.update({"width": width, "height": height}) svg.update({"width": width, "height": height})
with path.open("w+") as output_file: with path.open("w+") as output_file:
svg.write(output_file) svg.write(output_file)
html_file.write(f'<img src="doc/{path.name}" />\n') html_file.write(f'<img src="{path}" />\n')
if __name__ == "__main__": if __name__ == "__main__":
main() draw_svg_tables(Path("doc"), Path("result.html"))