diff --git a/src/libkomwm.py b/src/libkomwm.py index b7b0641..3b93298 100644 --- a/src/libkomwm.py +++ b/src/libkomwm.py @@ -231,10 +231,11 @@ def komap_mapswithme(options): # Build optimization tree - class/type -> StyleChoosers for cl in class_order: clname = cl if cl.find('-') == -1 else cl[:cl.find('-')] - cltags = classificator[cl] - style.build_choosers_tree(clname, "line", cltags) - style.build_choosers_tree(clname, "area", cltags) - style.build_choosers_tree(clname, "node", cltags) + # Get first tag of the class/type. + cltag = next(iter(classificator[cl].keys())) + style.build_choosers_tree(clname, "line", cltag) + style.build_choosers_tree(clname, "area", cltag) + style.build_choosers_tree(clname, "node", cltag) style.restore_choosers_order("line") style.restore_choosers_order("area") style.restore_choosers_order("node") diff --git a/src/mapcss/Rule.py b/src/mapcss/Rule.py index a652f30..ede2543 100644 --- a/src/mapcss/Rule.py +++ b/src/mapcss/Rule.py @@ -59,10 +59,12 @@ class Rule(): def extract_tags(self): a = set() for condition in self.conditions: - a.add(condition.extract_tag()) - if "*" in a: - a = set(["*"]) - break + tag = condition.extract_tag() + if tag != '*': + a.add(tag) + elif len(a) == 0: + return set(["*"]) + return a diff --git a/src/mapcss/__init__.py b/src/mapcss/__init__.py index d2bcfb1..13bfd13 100644 --- a/src/mapcss/__init__.py +++ b/src/mapcss/__init__.py @@ -112,7 +112,7 @@ class MapCSS(): else: logging.error("unparsed zoom: %s" % s) - def build_choosers_tree(self, clname, type, tags={}): + def build_choosers_tree(self, clname, type, cltag): if type not in self.choosers_by_type_and_tag: self.choosers_by_type_and_tag[type] = {} if clname not in self.choosers_by_type_and_tag[type]: @@ -120,7 +120,7 @@ class MapCSS(): if type in self.choosers_by_type: for chooser in self.choosers_by_type[type]: for tag in chooser.extract_tags(): - if tag == "*" or tag in tags: + if tag == "*" or tag == cltag: if chooser not in self.choosers_by_type_and_tag[type][clname]: self.choosers_by_type_and_tag[type][clname].add(chooser) break