INNER CODE UNIT · Python

pinned_source

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

def pinned_source(overrides, key):
  """The source file name an override pins this (title, type) to, if any."""
  prefer = overrides.get(key, {}).get('prefer')
  return f'{prefer}.json' if prefer else None

def load_sources(sources):
  """Load and merge all template JSON files from sources/local/ and sources/external/."""
  rank = source_priority(sources)
  templates = []
  local_dir = os.path.join(SOURCES_DIR, 'local')
  external_dir = os.path.join(SOURCES_DIR, 'external')
  for is_local, d in [(True, local_dir), (False, external_dir)]:
    if not os.path.isdir(d):
      continue
    for file in sorted(os.listdir(d)):
      file_path = os.path.join(d, file)
      if not (os.path.isfile(file_path) and file.endswith('.json')):
        continue

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…