From dbba1c41e0237ad37be0905cf7502e609fca58ab Mon Sep 17 00:00:00 2001 From: Konstantin Pastbin Date: Tue, 20 Jun 2023 18:18:40 +0300 Subject: [PATCH] Allow comments in mapcss-mapping.csv Signed-off-by: Konstantin Pastbin --- src/libkomwm.py | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/libkomwm.py b/src/libkomwm.py index d741ca1..03e12d8 100644 --- a/src/libkomwm.py +++ b/src/libkomwm.py @@ -148,32 +148,12 @@ def komap_mapswithme(options): # Build classificator tree from mapcss-mapping.csv file types_file = open(os.path.join(ddir, 'types.txt'), "w") - # Mapcss-mapping format - # - # A CSV table mapping tags to types. Some types can be deemed obsolete, either completely or replaced with a different type. - # - # Example row: highway|bus_stop;[highway=bus_stop];;name;int_name;22; (mind the last semicolon!) - # It contains: - # - type name: "highway|bus_stop" ('|' is converted to '-' internally) - # - mapcss selector for tags: "[highway=bus_stop]" (you can group selectors and use e.g. [oneway?]) - # - "x" for an obsolete type or an empty cell otherwise - # - primary title tag (usually "name") - # - secondary title tag (usually "int_name") - # - type id, sequential starting from 1 - # - replacement type for an obsolete tag, if exists - # - # A shorter format for above example: highway|bus_stop;22; - # It leaves only columns 1, 6 and 7. For obsolete types with no replacement put "x" into the last column. - # Obviously it works only for simple types that are produced from tags replacing '=' with '|'. - # - # An example of type with replacement: - # highway|unsurfaced|disused;[highway=unsurfaced][disused?];x;name;int_name;838;highway|unclassified - + # The mapcss-mapping.csv format is described inside the file itself. cnt = 1 unique_types_check = set() for row in csv.reader(open(os.path.join(ddir, 'mapcss-mapping.csv')), delimiter=';'): - if len(row) <= 1: - # Allow for empty lines and comments that do not contain ';' symbol + if len(row) <= 1 or row[0].startswith('#'): + # Allow for empty lines and comment lines starting with '#'. continue if len(row) == 3: # Short format: type name, type id, x / replacement type name