[55] fix multiple overlay names

pull/935/head
meisnate12 2 years ago
parent b1f355dba0
commit 2331cb107f

@ -8,7 +8,6 @@ RUN echo "**** install system packages ****" \
&& apt-get install -y gcc g++ libxml2-dev libxslt-dev libz-dev wget \ && apt-get install -y gcc g++ libxml2-dev libxslt-dev libz-dev wget \
&& wget -O /tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-"$(dpkg --print-architecture | awk -F- '{ print $NF }')" \ && wget -O /tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-"$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& chmod +x /tini \ && chmod +x /tini \
&& apt-get install jpeg-dev zlib-dev \
&& pip3 install --no-cache-dir --upgrade --requirement /requirements.txt \ && pip3 install --no-cache-dir --upgrade --requirement /requirements.txt \
&& apt-get --purge autoremove wget gcc g++ libxml2-dev libxslt-dev libz-dev -y \ && apt-get --purge autoremove wget gcc g++ libxml2-dev libxslt-dev libz-dev -y \
&& apt-get clean \ && apt-get clean \

@ -1 +1 @@
1.17.0-develop54 1.17.0-develop55

@ -260,7 +260,7 @@ class CollectionBuilder:
suppress = util.get_list(data[methods["suppress_overlays"]]) suppress = util.get_list(data[methods["suppress_overlays"]])
else: else:
logger.error(f"Overlay Error: suppress_overlays attribute is blank") logger.error(f"Overlay Error: suppress_overlays attribute is blank")
self.overlay = Overlay(config, library, self.mapping_name, overlay_data, suppress) self.overlay = Overlay(config, library, overlay_data, suppress)
self.sync_to_users = None self.sync_to_users = None
self.valid_users = [] self.valid_users = []

@ -145,7 +145,6 @@ class Library(ABC):
for file_type, overlay_file, temp_vars, asset_directory in self.overlay_path: for file_type, overlay_file, temp_vars, asset_directory in self.overlay_path:
try: try:
overlay_obj = OverlayFile(self.config, self, file_type, overlay_file, temp_vars, asset_directory) overlay_obj = OverlayFile(self.config, self, file_type, overlay_file, temp_vars, asset_directory)
self.overlay_names.extend([p for p in overlay_obj.overlays])
self.overlay_files.append(overlay_obj) self.overlay_files.append(overlay_obj)
self.queue_names.extend([q for q in overlay_obj.queues]) self.queue_names.extend([q for q in overlay_obj.queues])
except Failed as e: except Failed as e:

@ -1195,7 +1195,7 @@ class OverlayFile(DataFile):
logger.info("") logger.info("")
logger.info(f"Loading Overlay {file_type}: {path}") logger.info(f"Loading Overlay {file_type}: {path}")
data = self.load_file(self.type, self.path) data = self.load_file(self.type, self.path)
self.overlays = get_dict("overlays", data, library.overlay_names) self.overlays = get_dict("overlays", data)
self.templates = get_dict("templates", data) self.templates = get_dict("templates", data)
self.queues = get_dict("queues", data, library.queue_names) self.queues = get_dict("queues", data, library.queue_names)
self.external_templates(data) self.external_templates(data)

@ -902,10 +902,9 @@ def parse_cords(data, parent, required=False):
class Overlay: class Overlay:
def __init__(self, config, library, mapping_name, overlay_data, suppress): def __init__(self, config, library, overlay_data, suppress):
self.config = config self.config = config
self.library = library self.library = library
self.mapping_name = mapping_name
self.data = overlay_data self.data = overlay_data
self.suppress = suppress self.suppress = suppress
self.keys = [] self.keys = []
@ -932,7 +931,20 @@ class Overlay:
if not isinstance(self.data, dict): if not isinstance(self.data, dict):
self.data = {"name": str(self.data)} self.data = {"name": str(self.data)}
logger.warning(f"Overlay Warning: No overlay attribute using mapping name {self.data} as the overlay name") logger.warning(f"Overlay Warning: No overlay attribute using mapping name {self.data} as the overlay name")
self.name = str(self.data["name"]) if "name" in self.data and self.data["name"] else self.mapping_name if "name" not in self.data or not self.data["name"]:
raise Failed(f"Overlay Error: overlay must have the name attribute")
self.name = str(self.data["name"])
if self.name not in library.overlay_names:
library.overlay_names.append(self.name)
self.mapping_name = self.name
else:
name_count = 1
test_name = f"{self.name} ({name_count})"
while test_name in library.overlay_names:
name_count += 1
test_name = f"{self.name} ({name_count})"
library.overlay_names.append(test_name)
self.mapping_name = test_name
if "group" in self.data and self.data["group"]: if "group" in self.data and self.data["group"]:
self.group = str(self.data["group"]) self.group = str(self.data["group"])
@ -1195,7 +1207,7 @@ class Overlay:
return overlay_image, (main_x, main_y) return overlay_image, (main_x, main_y)
def get_overlay_compare(self): def get_overlay_compare(self):
output = f"{self.mapping_name}|{self.name}" output = f"{self.name}"
if self.group: if self.group:
output += f"{self.group}{self.weight}" output += f"{self.group}{self.weight}"
if self.has_coordinates(): if self.has_coordinates():

Loading…
Cancel
Save