Change scheme format.

Use "shapes" key instead of "icon", "add_shapes" key instead of
"add_icon", "exception" instead of "no_tag".
This commit is contained in:
Sergey Vartanov 2021-05-24 00:32:35 +03:00
parent 1bc7a1f726
commit 2ece66d5d0
3 changed files with 319 additions and 319 deletions

View file

@ -56,7 +56,7 @@ def draw_all_icons(
for group in scheme.icons: for group in scheme.icons:
for element in group["tags"]: # type: Dict[str, Any] for element in group["tags"]: # type: Dict[str, Any]
for key in ["icon", "add_icon"]: for key in ["shapes", "add_shapes"]:
if key in element: if key in element:
current_set = element[key] current_set = element[key]
add() add()

View file

@ -85,10 +85,10 @@ def is_matched(matcher: Dict[str, Any], tags: Dict[str, str]) -> bool:
matched = False matched = False
break break
if "no_tags" in matcher: if "exception" in matcher:
for config_tag_key in matcher["no_tags"]: for config_tag_key in matcher["exception"]:
config_tag_key: str config_tag_key: str
tag_matcher = matcher["no_tags"][config_tag_key] tag_matcher = matcher["exception"][config_tag_key]
if ( if (
is_matched_tag(config_tag_key, tag_matcher, tags) != is_matched_tag(config_tag_key, tag_matcher, tags) !=
MatchingType.NOT_MATCHED MatchingType.NOT_MATCHED
@ -212,10 +212,10 @@ class Scheme:
priority = len(self.icons) - index priority = len(self.icons) - index
if "draw" in matcher and not matcher["draw"]: if "draw" in matcher and not matcher["draw"]:
processed |= set(matcher_tags) processed |= set(matcher_tags)
if "icon" in matcher: if "shapes" in matcher:
main_icon = Icon([ main_icon = Icon([
ShapeSpecification.from_structure(x, icon_extractor, self) ShapeSpecification.from_structure(x, icon_extractor, self)
for x in matcher["icon"] for x in matcher["shapes"]
]) ])
processed |= set(matcher_tags) processed |= set(matcher_tags)
if "over_icon" in matcher: if "over_icon" in matcher:
@ -228,12 +228,12 @@ class Scheme:
]) ])
for key in matcher_tags: for key in matcher_tags:
processed.add(key) processed.add(key)
if "add_icon" in matcher: if "add_shapes" in matcher:
extra_icons += [Icon([ extra_icons += [Icon([
ShapeSpecification.from_structure( ShapeSpecification.from_structure(
x, icon_extractor, self, Color("#888888") x, icon_extractor, self, Color("#888888")
) )
for x in matcher["add_icon"] for x in matcher["add_shapes"]
])] ])]
for key in matcher_tags: for key in matcher_tags:
processed.add(key) processed.add(key)
@ -296,8 +296,8 @@ class Scheme:
priority = element["priority"] priority = element["priority"]
for key in element: # type: str for key in element: # type: str
if key not in [ if key not in [
"tags", "no_tags", "priority", "level", "icon", "r", "r1", "tags", "exception", "priority", "level", "shapes", "r",
"r2" "r1", "r2"
]: ]:
value = element[key] value = element[key]
if isinstance(value, str) and value.endswith("_color"): if isinstance(value, str) and value.endswith("_color"):

File diff suppressed because it is too large Load diff