MCPcopy Create free account
hub / github.com/comaps/comaps / parse_mapcss_row

Function parse_mapcss_row

tools/python/stylesheet/cat_stat.py:17–45  ·  view source on GitHub ↗
(row)

Source from the content-addressed store, hash-verified

15
16
17def parse_mapcss_row(row):
18 if len(row) < 2:
19 # Allow for empty lines and comments that do not contain ';' symbol
20 return None
21 if len(row) == 3:
22 # Short format: type name, type id, x / replacement type name
23 tag = row[0].replace('|', '=')
24 row = (row[0], '[{0}]'.format(tag), 'x' if len(row[2].strip()) > 0 else '')
25 if len(row[2]) > 0:
26 # Skipping obsolete types
27 return None
28
29 # Lifted off from Kothic
30 cl = row[0].replace("|", "-")
31 pairs = [i.strip(']').split("=") for i in row[1].split(',')[0].split('[')]
32 kv = []
33 for i in pairs:
34 if len(i) == 1:
35 if i[0]:
36 if i[0][0] == "!":
37 kv.append((i[0][1:].strip('?'), "no"))
38 else:
39 kv.append((i[0].strip('?'), "*"))
40 elif len(i) == 2:
41 kv.append(tuple(i))
42 elif len(i) == 3:
43 kv.append((i[0], i[1]))
44 kv.append((i[1], i[2]))
45 return cl, kv
46
47
48def find_in_taginfo(cur, kv, seen):

Callers 1

cat_stat.pyFile · 0.85

Calls 2

formatMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected