Fix code style.

This commit is contained in:
Sergey Vartanov 2021-08-15 17:18:30 +03:00
parent 96aaa92535
commit edd3512526
7 changed files with 31 additions and 15 deletions

View file

@ -1,3 +1,6 @@
"""
Figures displayed on the map.
"""
from typing import Any, Dict, List, Optional
import numpy as np

View file

@ -2,7 +2,7 @@
MapCSS scheme creation.
"""
from pathlib import Path
from typing import List, Optional, Dict
from typing import List, Optional, Dict, TextIO
import logging
from colour import Color
@ -66,6 +66,10 @@ meta {{
class MapCSSWriter:
"""
Writer that converts Röntgen scheme into MapCSS 0.2 format.
"""
def __init__(
self,
scheme: Scheme,
@ -89,6 +93,15 @@ class MapCSSWriter:
prefix: str = "",
opacity: Optional[float] = None,
) -> str:
"""
Add MapCSS 0.2 selector for node, way, relation, or area.
:param target: `node`, `way`, `relation`, or `area`
:param matcher: tag matcher of Röntgen scheme
:param prefix: tag prefix
:param opacity: icon opacity
:return:
"""
elements: Dict[str, str] = {}
clean_shapes = matcher.get_clean_shapes()
@ -126,7 +139,7 @@ class MapCSSWriter:
return selector
def write(self, output_file: Path) -> None:
def write(self, output_file: TextIO) -> None:
"""
Construct icon selectors for MapCSS 0.2 scheme.
"""

View file

@ -145,6 +145,7 @@ class RoentgenMoire(Default, ABC):
return test_configuration.get_command(self.clear(args[0]))
def icon(self, args: Arguments) -> str:
"""Image with Röntgen icon."""
raise NotImplementedError("icon")
def options(self, args: Arguments) -> str:

View file

@ -16,6 +16,8 @@ __email__ = "me@enzet.ru"
class NetworkError(Exception):
"""Failed network request."""
def __init__(self, message: str):
super().__init__()
self.message: str = message
@ -36,7 +38,7 @@ def get_osm(
if not to_update and result_file_name.is_file():
return result_file_name.open().read()
content: Optional[bytes] = get_data(
content: Optional[str] = get_data(
"api.openstreetmap.org/api/0.6/map",
{"bbox": boundary_box.get_format()},
is_secure=True,

View file

@ -3,11 +3,11 @@ Reading OpenStreetMap data from XML file.
"""
import json
import re
import xml.etree.ElementTree as ET
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path
from typing import Any, Dict, List, Optional, Set
from xml.etree import ElementTree
import numpy as np
@ -65,14 +65,13 @@ class Tagged:
return None
def get_float(self, key: str) -> Optional[float]:
"""Parse float from tag value."""
if key in self.tags:
return parse_float(self.tags[key])
return None
def get_length(self, key: str) -> Optional[float]:
"""
Get length in meters.
"""
"""Get length in meters."""
if key not in self.tags:
return None
@ -420,7 +419,7 @@ class OSMReader:
:param file_name: input XML file
:return: parsed map
"""
return self.parse_osm(ET.parse(file_name).getroot())
return self.parse_osm(ElementTree.parse(file_name).getroot())
def parse_osm_text(self, text: str) -> Map:
"""
@ -429,7 +428,7 @@ class OSMReader:
:param text: XML text representation
:return: parsed map
"""
return self.parse_osm(ET.fromstring(text))
return self.parse_osm(ElementTree.fromstring(text))
def parse_osm(self, root) -> Map:
"""

View file

@ -1,3 +1,6 @@
"""
Rasterize vector graphics using Inkscape.
"""
import os
import subprocess
from pathlib import Path

View file

@ -29,13 +29,8 @@ class Lane:
change: Optional[str] = None # "not_left", "not_right"
destination: Optional[str] = None # Lane destination
def set_forward(self, is_forward: bool) -> None:
self.is_forward = is_forward
def get_width(self, scale: float):
"""
Get lane width. We use standard 3.7 m lane.
"""
"""Get lane width. We use standard 3.7 m lane."""
if self.width is None:
return 3.7 * scale
return self.width * scale