INNER CODE UNIT · Python

is_uri

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

def is_uri(value):
  return isinstance(value, str) and FORMAT_CHECKER.conforms(value, 'uri')

STACKFILE_URL_PATTERNS = [
  (r'https://raw\.githubusercontent\.com/([^/]+/[^/]+)/[^/]+/(.+)', 'github.com'),
  (r'https://github\.com/([^/]+/[^/]+)/(?:blob|raw)/[^/]+/(.+)', 'github.com'),
  (r'https://gitlab\.com/(.+?)/-/(?:blob|raw)/[^/]+/(.+)', 'gitlab.com'),
]

def normalize_template(t):
  t.setdefault('type', 1)

  # Merge singular 'category' into 'categories'
  categories = t.get('categories', [])
  if isinstance(categories, str):
    categories = [categories]
  elif not isinstance(categories, list):
    categories = []

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…