INNER CODE UNIT · Python
source_priority
lissy93/portainer-templates · lib/combine.py:58
def source_priority(sources):
"""File name -> dedup priority, lower wins: app sources first, then sources.csv order"""
ordered = [s for s in sources if s.is_app] + [s for s in sources if not s.is_app]
return {s.filename: i for i, s in enumerate(ordered, start=1)}
def load_overrides():
"""Per-template fixes from overrides.json, keyed by (normalized title, type)."""
path = os.path.join(BASE_DIR, 'overrides.json')
if not os.path.isfile(path):
return {}
with open(path) as f:
try:
entries = json.load(f).get('overrides', [])
except json.decoder.JSONDecodeError as err:
log.error(f'Refusing to build: overrides.json is not valid JSON ({err})')
sys.exit(1)
return {(normalize_string(e['title']), e.get('type', 1)): e for e in entries
if isinstance(e, dict) and isinstance(e.get('title'), str) and e['title'].strip()}