diff --git a/map_machine/constructor.py b/map_machine/constructor.py
index 89b6002..97dab3a 100644
--- a/map_machine/constructor.py
+++ b/map_machine/constructor.py
@@ -152,9 +152,7 @@ def try_to_glue(
class Constructor:
- """
- Map Machine node and way constructor.
- """
+ """Map Machine node and way constructor."""
def __init__(
self,
diff --git a/map_machine/doc/moire_manager.py b/map_machine/doc/moire_manager.py
index a6bd0d5..ecd30ff 100644
--- a/map_machine/doc/moire_manager.py
+++ b/map_machine/doc/moire_manager.py
@@ -116,9 +116,9 @@ class ArgumentParser(argparse.ArgumentParser):
class MapMachineMoire(Default, ABC):
"""Moire extension stub for Map Machine."""
- def osm(self, args: Arguments) -> str:
+ def osm(self, arg: Arguments) -> str:
"""OSM tag key or key–value pair of tag."""
- spec: str = self.clear(args[0])
+ spec: str = self.clear(arg[0])
if "=" in spec:
key, tag = spec.split("=")
return (
@@ -129,26 +129,26 @@ class MapMachineMoire(Default, ABC):
return self.get_ref_(f"{PREFIX}Key:{spec}", self.m([spec]))
- def color(self, args: Arguments) -> str:
+ def color(self, arg: Arguments) -> str:
"""Simple color sample."""
raise NotImplementedError("color")
- def page_icon(self, args: Arguments) -> str:
+ def page_icon(self, arg: Arguments) -> str:
"""HTML page icon."""
return ""
- def command(self, args: Arguments) -> str:
+ def command(self, arg: Arguments) -> str:
"""Bash command from integration tests."""
- return "map-machine " + " ".join(COMMAND_LINES[self.clear(args[0])])
+ return "map-machine " + " ".join(COMMAND_LINES[self.clear(arg[0])])
- def icon(self, args: Arguments) -> str:
+ def icon(self, arg: Arguments) -> str:
"""Image with Röntgen icon."""
raise NotImplementedError("icon")
- def options(self, args: Arguments) -> str:
+ def options(self, arg: Arguments) -> str:
"""Table with option descriptions."""
parser: ArgumentParser = ArgumentParser()
- command: str = self.clear(args[0])
+ command: str = self.clear(arg[0])
if command == "render":
cli.add_render_arguments(parser)
elif command == "server":
@@ -167,13 +167,13 @@ class MapMachineMoire(Default, ABC):
)
return self.parse(parser.get_moire_help())
- def kbd(self, args: Arguments) -> str:
+ def kbd(self, arg: Arguments) -> str:
"""Keyboard key."""
- return self.m(args)
+ return self.m(arg)
- def no_wrap(self, args: Arguments) -> str:
+ def no_wrap(self, arg: Arguments) -> str:
"""Do not wrap text at white spaces."""
- return self.parse(args[0])
+ return self.parse(arg[0])
class MapMachineHTML(MapMachineMoire, DefaultHTML):
@@ -197,41 +197,39 @@ class MapMachineHTML(MapMachineMoire, DefaultHTML):
content += f"
{cell}
"
return f""
- def color(self, args: Arguments) -> str:
+ def color(self, arg: Arguments) -> str:
"""Simple color sample."""
return (
f''
+ f'style="background-color: {self.clear(arg[0])};">'
)
- def icon(self, args: Arguments) -> str:
+ def icon(self, arg: Arguments) -> str:
"""Image with Röntgen icon."""
- size: str = self.clear(args[1]) if len(args) > 1 else 16
+ size: str = self.clear(arg[1]) if len(arg) > 1 else 16
return (
f'
'
+ f'src="out/icons_by_id/{self.clear(arg[0])}.svg" />'
)
- def kbd(self, args: Arguments) -> str:
+ def kbd(self, arg: Arguments) -> str:
"""Keyboard key."""
- return f"{self.clear(args[0])}"
+ return f"{self.clear(arg[0])}"
- def page_icon(self, args: Arguments) -> str:
+ def page_icon(self, arg: Arguments) -> str:
"""HTML page icon."""
return (
- f''
)
- def no_wrap(self, args: Arguments) -> str:
+ def no_wrap(self, arg: Arguments) -> str:
"""Do not wrap text at white spaces."""
- return (
- f'{self.parse(args[0])}'
- )
+ return f'{self.parse(arg[0])}'
- def formal(self, args: Arguments) -> str:
+ def formal(self, arg: Arguments) -> str:
"""Formal variable."""
- return f'{self.parse(args[0])}'
+ return f'{self.parse(arg[0])}'
class MapMachineOSMWiki(MapMachineMoire, DefaultWiki):
@@ -248,23 +246,23 @@ class MapMachineOSMWiki(MapMachineMoire, DefaultWiki):
workspace.ICONS_PATH, workspace.ICONS_CONFIG_PATH
)
- def osm(self, args: Arguments) -> str:
+ def osm(self, arg: Arguments) -> str:
"""OSM tag key or key–value pair of tag."""
- spec: str = self.clear(args[0])
+ spec: str = self.clear(arg[0])
if "=" in spec:
key, tag = spec.split("=")
return f"{{{{Key|{key}|{tag}}}}}"
return f"{{{{Tag|{spec}}}}}"
- def color(self, args: Arguments) -> str:
+ def color(self, arg: Arguments) -> str:
"""Simple color sample."""
- return f"{{{{Color box|{self.clear(args[0])}}}}}"
+ return f"{{{{Color box|{self.clear(arg[0])}}}}}"
- def icon(self, args: Arguments) -> str:
+ def icon(self, arg: Arguments) -> str:
"""Image with Röntgen icon."""
- size: str = self.clear(args[1]) if len(args) > 1 else 16
- shape_id: str = self.clear(args[0])
+ size: str = self.clear(arg[1]) if len(arg) > 1 else 16
+ shape_id: str = self.clear(arg[0])
name: str = self.extractor.get_shape(shape_id).name
return f"[[File:Röntgen {name}.svg|{size}px]]"
@@ -274,27 +272,25 @@ class MapMachineMarkdown(MapMachineMoire, DefaultMarkdown):
images = {}
- def color(self, args: Arguments) -> str:
+ def color(self, arg: Arguments) -> str:
"""Simple color sample."""
- return self.clear(args[0])
+ return self.clear(arg[0])
- def icon(self, args: Arguments) -> str:
+ def icon(self, arg: Arguments) -> str:
"""Image with Röntgen icon."""
- return f"[{self.clear(args[0])}]"
+ return f"[{self.clear(arg[0])}]"
- def kbd(self, args: Arguments) -> str:
+ def kbd(self, arg: Arguments) -> str:
"""Keyboard key."""
- return f"{self.clear(args[0])}"
+ return f"{self.clear(arg[0])}"
- def no_wrap(self, args: Arguments) -> str:
+ def no_wrap(self, arg: Arguments) -> str:
"""Do not wrap text at white spaces."""
- return (
- f'{self.parse(args[0])}'
- )
+ return f'{self.parse(arg[0])}'
- def formal(self, args: Arguments) -> str:
+ def formal(self, arg: Arguments) -> str:
"""Formal variable."""
- return f"<{self.parse(args[0])}>"
+ return f"<{self.parse(arg[0])}>"
def convert(input_path: Path, output_path: Path) -> None:
diff --git a/map_machine/doc/taginfo.py b/map_machine/doc/taginfo.py
index 9ad2592..f9796d2 100644
--- a/map_machine/doc/taginfo.py
+++ b/map_machine/doc/taginfo.py
@@ -21,9 +21,7 @@ from map_machine.workspace import workspace
class TaginfoProjectFile:
- """
- JSON structure with OpenStreetMap tag usage.
- """
+ """JSON structure with OpenStreetMap tag usage."""
def __init__(self, path: Path, scheme: Scheme) -> None:
self.path: Path = path
diff --git a/map_machine/drawing.py b/map_machine/drawing.py
index cfec7dc..4433beb 100644
--- a/map_machine/drawing.py
+++ b/map_machine/drawing.py
@@ -23,9 +23,7 @@ PathCommands = list[Union[float, str, np.ndarray]]
@dataclass
class Style:
- """
- Drawing element style.
- """
+ """Drawing element style."""
fill: Optional[Color] = None
stroke: Optional[Color] = None
@@ -60,9 +58,7 @@ class Style:
class Drawing:
- """
- Image.
- """
+ """Image."""
def __init__(self, file_path: Path, width: int, height: int) -> None:
self.file_path: Path = file_path
@@ -95,9 +91,7 @@ class Drawing:
class SVGDrawing(Drawing):
- """
- SVG image.
- """
+ """SVG image."""
def __init__(self, file_path: Path, width: int, height: int) -> None:
super().__init__(file_path, width, height)
@@ -145,9 +139,7 @@ class SVGDrawing(Drawing):
class PNGDrawing(Drawing):
- """
- PNG image.
- """
+ """PNG image."""
def __init__(self, file_path: Path, width: int, height: int) -> None:
super().__init__(file_path, width, height)
diff --git a/map_machine/feature/direction.py b/map_machine/feature/direction.py
index 237f481..cffd8a2 100644
--- a/map_machine/feature/direction.py
+++ b/map_machine/feature/direction.py
@@ -51,9 +51,7 @@ def rotation_matrix(angle: float) -> np.ndarray:
class Sector:
- """
- Sector described by two vectors.
- """
+ """Sector described by two vectors."""
def __init__(self, text: str, angle: Optional[float] = None) -> None:
"""
@@ -120,9 +118,7 @@ class Sector:
class DirectionSet:
- """
- Describes direction, set of directions.
- """
+ """Describes direction, set of directions."""
def __init__(self, text: str) -> None:
"""
diff --git a/map_machine/feature/road.py b/map_machine/feature/road.py
index 04664a9..4c41d80 100644
--- a/map_machine/feature/road.py
+++ b/map_machine/feature/road.py
@@ -33,9 +33,7 @@ USE_BLUR: bool = False
@dataclass
class Lane:
- """
- Road lane specification.
- """
+ """Road lane specification."""
width: Optional[float] = None # Width in meters
is_forward: Optional[bool] = None # Whether lane is forward or backward
@@ -57,9 +55,7 @@ class Lane:
class RoadPart:
- """
- Line part of the road.
- """
+ """Line part of the road."""
def __init__(
self,
@@ -366,9 +362,7 @@ class Intersection:
class Road(Tagged):
- """
- Road or track on the map.
- """
+ """Road or track on the map."""
def __init__(
self,
@@ -755,16 +749,9 @@ class ComplexConnector(Connector):
class SimpleIntersection(Connector):
"""Connection between more than two roads."""
- def __init__(
- self,
- connections: list[tuple[Road, int]],
- flinger: Flinger,
- ) -> None:
- super().__init__(connections, flinger)
-
def draw(self, svg: Drawing) -> None:
"""Draw connection fill."""
- for road, index in sorted(
+ for road, _ in sorted(
self.connections, key=lambda x: x[0].matcher.priority
):
node: OSMNode = self.road_1.nodes[self.index_1]
@@ -776,7 +763,7 @@ class SimpleIntersection(Connector):
def draw_border(self, svg: Drawing) -> None:
"""Draw connection outline."""
- for road, index in self.connections:
+ for road, _ in self.connections:
node: OSMNode = self.road_1.nodes[self.index_1]
point: np.ndarray = self.flinger.fling(node.coordinates)
circle: Circle = svg.circle(
@@ -817,13 +804,13 @@ class Roads:
layered_roads[road.layer] = []
layered_roads[road.layer].append(road)
- for id_ in self.nodes:
- connected: list[tuple[Road, int]] = self.nodes[id_]
+ for _, connected in self.nodes.items():
connector: Connector
- if len(self.nodes[id_]) <= 1:
+ if len(connected) <= 1:
continue
- elif len(self.nodes[id_]) == 2:
+
+ if len(connected) == 2:
road_1, index_1 = connected[0]
road_2, index_2 = connected[1]
if (
@@ -851,11 +838,7 @@ class Roads:
roads: list[Road] = sorted(
layered_roads[layer], key=lambda x: x.matcher.priority
)
- connectors: list[Connector]
- if layer in layered_connectors:
- connectors = layered_connectors[layer]
- else:
- connectors = []
+ connectors: list[Connector] = layered_connectors.get(layer)
# Draw borders.
diff --git a/map_machine/figure.py b/map_machine/figure.py
index 613c048..44a624e 100644
--- a/map_machine/figure.py
+++ b/map_machine/figure.py
@@ -26,9 +26,7 @@ BUILDING_MINIMAL_HEIGHT: float = 8.0
class Figure(Tagged):
- """
- Some figure on the map: way or area.
- """
+ """Some figure on the map: way or area."""
def __init__(
self,
@@ -64,9 +62,7 @@ class Figure(Tagged):
class Building(Figure):
- """
- Building on the map.
- """
+ """Building on the map."""
def __init__(
self,
@@ -193,9 +189,7 @@ class Building(Figure):
class StyledFigure(Figure):
- """
- Figure with stroke and fill style.
- """
+ """Figure with stroke and fill style."""
def __init__(
self,
@@ -209,9 +203,7 @@ class StyledFigure(Figure):
class Crater(Tagged):
- """
- Volcano or impact crater on the map.
- """
+ """Volcano or impact crater on the map."""
def __init__(
self, tags: dict[str, str], coordinates: np.ndarray, point: np.ndarray
@@ -248,9 +240,7 @@ class Crater(Tagged):
class Tree(Tagged):
- """
- Tree on the map.
- """
+ """Tree on the map."""
def __init__(
self, tags: dict[str, str], coordinates: np.ndarray, point: np.ndarray
@@ -280,9 +270,7 @@ class Tree(Tagged):
class DirectionSector(Tagged):
- """
- Sector that represents direction.
- """
+ """Sector that represents direction."""
def __init__(self, tags: dict[str, str], point: np.ndarray) -> None:
super().__init__(tags)
@@ -354,9 +342,7 @@ class DirectionSector(Tagged):
class Segment:
- """
- Closed line segment.
- """
+ """Closed line segment."""
def __init__(self, point_1: np.ndarray, point_2: np.ndarray) -> None:
self.point_1: np.ndarray = point_1
diff --git a/map_machine/geometry/boundary_box.py b/map_machine/geometry/boundary_box.py
index a73ac70..a0379ba 100644
--- a/map_machine/geometry/boundary_box.py
+++ b/map_machine/geometry/boundary_box.py
@@ -17,9 +17,7 @@ LONGITUDE_MAX_DIFFERENCE: float = 0.5
@dataclass
class BoundaryBox:
- """
- Rectangle that limit space on the map.
- """
+ """Rectangle that limit space on the map."""
left: float # Minimum longitude.
bottom: float # Minimum latitude.
diff --git a/map_machine/geometry/flinger.py b/map_machine/geometry/flinger.py
index 0b5555b..c3be23e 100644
--- a/map_machine/geometry/flinger.py
+++ b/map_machine/geometry/flinger.py
@@ -40,9 +40,7 @@ def osm_zoom_level_to_pixels_per_meter(
class Flinger:
- """
- Convert geo coordinates into SVG position points.
- """
+ """Convert geo coordinates into SVG position points."""
def __init__(
self,
diff --git a/map_machine/geometry/vector.py b/map_machine/geometry/vector.py
index 5305c82..4a5666a 100644
--- a/map_machine/geometry/vector.py
+++ b/map_machine/geometry/vector.py
@@ -41,9 +41,7 @@ def norm(vector: np.ndarray) -> np.ndarray:
class Polyline:
- """
- List of connected points.
- """
+ """List of connected points."""
def __init__(self, points: list[np.ndarray]) -> None:
self.points: list[np.ndarray] = points
diff --git a/map_machine/mapcss.py b/map_machine/mapcss.py
index 8b06c6c..65fc51d 100644
--- a/map_machine/mapcss.py
+++ b/map_machine/mapcss.py
@@ -67,9 +67,7 @@ meta {{
class MapCSSWriter:
- """
- Writer that converts Map Machine scheme into MapCSS 0.2 format.
- """
+ """Writer that converts Map Machine scheme into MapCSS 0.2 format."""
def __init__(
self,
diff --git a/map_machine/mapper.py b/map_machine/mapper.py
index 6c73c63..26a38b4 100644
--- a/map_machine/mapper.py
+++ b/map_machine/mapper.py
@@ -33,9 +33,7 @@ __email__ = "me@enzet.ru"
class Map:
- """
- Map drawing.
- """
+ """Map drawing."""
def __init__(
self,
diff --git a/map_machine/osm/osm_reader.py b/map_machine/osm/osm_reader.py
index 38bdf77..91fb615 100644
--- a/map_machine/osm/osm_reader.py
+++ b/map_machine/osm/osm_reader.py
@@ -59,9 +59,7 @@ def parse_levels(string: str) -> list[float]:
@dataclass
class Tagged:
- """
- Something with tags (string to string mapping).
- """
+ """Something with tags (string to string mapping)."""
tags: dict[str, str]
@@ -224,9 +222,7 @@ class OSMWay(Tagged):
@dataclass
class OSMMember:
- """
- Member of OpenStreetMap relation.
- """
+ """Member of OpenStreetMap relation."""
type_: str
ref: int
@@ -298,15 +294,11 @@ class OSMRelation(Tagged):
class NotWellFormedOSMDataException(Exception):
- """
- OSM data structure is not well-formed.
- """
+ """OSM data structure is not well-formed."""
class OSMData:
- """
- The whole OpenStreetMap information about nodes, ways, and relations.
- """
+ """The whole OpenStreetMap information about nodes, ways, and relations."""
def __init__(self) -> None:
self.nodes: dict[int, OSMNode] = {}
diff --git a/map_machine/pictogram/icon.py b/map_machine/pictogram/icon.py
index 4915949..88c515b 100644
--- a/map_machine/pictogram/icon.py
+++ b/map_machine/pictogram/icon.py
@@ -38,9 +38,7 @@ GRID_STEP: int = 16
@dataclass
class Shape:
- """
- SVG icon path description.
- """
+ """SVG icon path description."""
path: str # SVG icon path
offset: np.ndarray # vector that should be used to shift the path
@@ -257,9 +255,7 @@ class ShapeExtractor:
@dataclass
class ShapeSpecification:
- """
- Specification for shape as a part of an icon.
- """
+ """Specification for shape as a part of an icon."""
shape: Shape
color: Color = DEFAULT_COLOR
@@ -335,9 +331,7 @@ class ShapeSpecification:
@dataclass
class Icon:
- """
- Icon that consists of (probably) multiple shapes.
- """
+ """Icon that consists of (probably) multiple shapes."""
shape_specifications: list[ShapeSpecification]
opacity: float = 1.0
@@ -450,9 +444,7 @@ class Icon:
@dataclass
class IconSet:
- """
- Node representation: icons and color.
- """
+ """Node representation: icons and color."""
main_icon: Icon
extra_icons: list[Icon]
diff --git a/map_machine/pictogram/icon_collection.py b/map_machine/pictogram/icon_collection.py
index 190d7df..38ec89b 100644
--- a/map_machine/pictogram/icon_collection.py
+++ b/map_machine/pictogram/icon_collection.py
@@ -25,9 +25,7 @@ __email__ = "me@enzet.ru"
@dataclass
class IconCollection:
- """
- Collection of icons.
- """
+ """Collection of icons."""
icons: list[Icon]
diff --git a/map_machine/scheme.py b/map_machine/scheme.py
index 6976d92..5ae4017 100644
--- a/map_machine/scheme.py
+++ b/map_machine/scheme.py
@@ -33,18 +33,14 @@ IconDescription = list[Union[str, dict[str, str]]]
@dataclass
class LineStyle:
- """
- SVG line style and its priority.
- """
+ """SVG line style and its priority."""
style: dict[str, Union[int, float, str]]
priority: float = 0.0
class MatchingType(Enum):
- """
- Description on how tag was matched.
- """
+ """Description on how tag was matched."""
NOT_MATCHED = 0
MATCHED_BY_SET = 1
@@ -106,9 +102,7 @@ def match_location(restrictions: dict[str, str], country: str) -> bool:
class Matcher:
- """
- Tag matching.
- """
+ """Tag matching."""
def __init__(
self, structure: dict[str, Any], group: Optional[dict[str, Any]] = None
@@ -215,9 +209,7 @@ def get_shape_specifications(
class NodeMatcher(Matcher):
- """
- Tag specification matcher.
- """
+ """Tag specification matcher."""
def __init__(
self, structure: dict[str, Any], group: dict[str, Any]
@@ -265,9 +257,7 @@ class NodeMatcher(Matcher):
class WayMatcher(Matcher):
- """
- Special tag matcher for ways.
- """
+ """Special tag matcher for ways."""
def __init__(self, structure: dict[str, Any], scheme: "Scheme") -> None:
super().__init__(structure)
@@ -289,9 +279,7 @@ class WayMatcher(Matcher):
class RoadMatcher(Matcher):
- """
- Special tag matcher for highways.
- """
+ """Special tag matcher for highways."""
def __init__(self, structure: dict[str, Any], scheme: "Scheme") -> None:
super().__init__(structure)
diff --git a/map_machine/slippy/server.py b/map_machine/slippy/server.py
index 2bb1b6e..6440bf3 100644
--- a/map_machine/slippy/server.py
+++ b/map_machine/slippy/server.py
@@ -17,9 +17,7 @@ __email__ = "me@enzet.ru"
class _Handler(SimpleHTTPRequestHandler):
- """
- HTTP request handler that process sloppy map tile requests.
- """
+ """HTTP request handler that process sloppy map tile requests."""
cache: Path = Path("cache")
update_cache: bool = False
diff --git a/map_machine/slippy/tile.py b/map_machine/slippy/tile.py
index e112d47..5b08897 100644
--- a/map_machine/slippy/tile.py
+++ b/map_machine/slippy/tile.py
@@ -212,9 +212,7 @@ class Tile:
@dataclass
class Tiles:
- """
- Collection of tiles.
- """
+ """Collection of tiles."""
tiles: list[Tile]
tile_1: Tile # Left top tile.
diff --git a/map_machine/text.py b/map_machine/text.py
index 8b4ec1c..d234819 100644
--- a/map_machine/text.py
+++ b/map_machine/text.py
@@ -17,9 +17,7 @@ DEFAULT_COLOR: Color = Color("#444444")
@dataclass
class Label:
- """
- Text label.
- """
+ """Text label."""
text: str
fill: Color = DEFAULT_COLOR
diff --git a/map_machine/ui/completion.py b/map_machine/ui/completion.py
index b7bfe7b..558b9b6 100644
--- a/map_machine/ui/completion.py
+++ b/map_machine/ui/completion.py
@@ -12,9 +12,7 @@ from map_machine.ui.cli import COMMANDS
class ArgumentParser(argparse.ArgumentParser):
- """
- Argument parser that generates fish shell autocompletion commands.
- """
+ """Argument parser that generates fish shell autocompletion commands."""
def __init__(self, *args, **kwargs) -> None:
self.arguments: list[dict[str, Any]] = []
diff --git a/map_machine/util.py b/map_machine/util.py
index d548e17..62bd2b2 100644
--- a/map_machine/util.py
+++ b/map_machine/util.py
@@ -10,9 +10,7 @@ __email__ = "me@enzet.ru"
@dataclass
class MinMax:
- """
- Minimum and maximum.
- """
+ """Minimum and maximum."""
min_: Any = None
max_: Any = None
diff --git a/map_machine/workspace.py b/map_machine/workspace.py
index 6377747..33d23ed 100644
--- a/map_machine/workspace.py
+++ b/map_machine/workspace.py
@@ -17,9 +17,7 @@ def check_and_create(directory: Path) -> Path:
class Workspace:
- """
- Project file and directory paths and generated files and directories.
- """
+ """Project file and directory paths and generated files and directories."""
# Project directories and files, that are the part of the repository.