INNER CODE UNIT · Python
score
lissy93/portainer-templates · lib/combine.py:47
score = len(t) # number of top-level keys
score += len(t.get('env', []))
score += len(t.get('volumes', []))
score += len(t.get('ports', []))
return score
def template_rank(t, pinned=None):
"""Sort key for choosing between duplicates, higher wins: pinned source, then source
priority, then completeness."""
return (t['_source'] == pinned, -t['_priority'], template_score(t))
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)."""