INNER CODE UNIT · Python

template_rank

lissy93/portainer-templates · lib/combine.py:53

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)."""
  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', [])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…