Fix icon sorting.

This commit is contained in:
Sergey Vartanov 2021-06-08 02:07:14 +03:00
parent 9bc71ebf92
commit 9fd2d869ff
2 changed files with 12 additions and 10 deletions

View file

@ -60,20 +60,22 @@ def draw_all_icons(
continue continue
if matcher.under_icon: if matcher.under_icon:
for icon_id in matcher.under_icon: for icon_id in matcher.under_icon:
current_set = set([icon_id] + matcher.over_icon) current_set = [icon_id] + matcher.over_icon
add() add()
if not (matcher.under_icon and matcher.with_icon): if not (matcher.under_icon and matcher.with_icon):
continue continue
for icon_id in matcher.under_icon: for icon_id in matcher.under_icon:
for icon_2_id in matcher.with_icon: for icon_2_id in matcher.with_icon:
current_set: Set[str] = set( current_set: List[str] = (
[icon_id] + [icon_2_id] + matcher.over_icon) [icon_id] + [icon_2_id] + matcher.over_icon
)
add() add()
for icon_2_id in matcher.with_icon: for icon_2_id in matcher.with_icon:
for icon_3_id in matcher.with_icon: for icon_3_id in matcher.with_icon:
current_set = set( current_set = (
[icon_id] + [icon_2_id] + [icon_3_id] + [icon_id] + [icon_2_id] + [icon_3_id] +
matcher.over_icon) matcher.over_icon
)
if (icon_2_id != icon_3_id and icon_2_id != icon_id and if (icon_2_id != icon_3_id and icon_2_id != icon_id and
icon_3_id != icon_id): icon_3_id != icon_id):
add() add()
@ -81,7 +83,7 @@ def draw_all_icons(
specified_ids: Set[str] = set() specified_ids: Set[str] = set()
for icon in icons: for icon in icons:
specified_ids |= icon.get_shape_ids() specified_ids |= set(icon.get_shape_ids())
print( print(
"Icons with no tag specification: \n " + "Icons with no tag specification: \n " +
", ".join(sorted(extractor.shapes.keys() - specified_ids)) + "." ", ".join(sorted(extractor.shapes.keys() - specified_ids)) + "."

View file

@ -290,11 +290,11 @@ class Icon:
shape_specifications: List[ShapeSpecification] shape_specifications: List[ShapeSpecification]
def get_shape_ids(self) -> Set[str]: def get_shape_ids(self) -> List[str]:
""" """
Get all shape identifiers in the icon. Get all shape identifiers in the icon.
""" """
return set(x.shape.id_ for x in self.shape_specifications) return [x.shape.id_ for x in self.shape_specifications]
def get_names(self) -> List[str]: def get_names(self) -> List[str]:
""" """
@ -368,8 +368,8 @@ class Icon:
def __lt__(self, other) -> bool: def __lt__(self, other) -> bool:
return ( return (
sorted(self.shape_specifications)[0].shape.id_ "".join([x.shape.id_ for x in self.shape_specifications])
< sorted(other.shape_specifications)[0].shape.id_ < "".join([x.shape.id_ for x in other.shape_specifications])
) )