Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_update_extend():
for first, second in zip(_ITEMSETS, _ITEMSETS[1:] + [[]]):
omd1 = OMD(first)
omd2 = OMD(second)
ref = dict(first)
orig_keys = set(omd1)
ref.update(second)
omd1.update_extend(omd2)
for k in omd2:
assert len(omd1.getlist(k)) >= len(omd2.getlist(k))
assert omd1.todict() == ref
assert orig_keys <= set(omd1)
def test_update():
for first, second in zip(_ITEMSETS, _ITEMSETS[1:]):
omd1 = OMD(first)
omd2 = OMD(second)
ref1 = dict(first)
ref2 = dict(second)
omd1.update(omd2)
ref1.update(ref2)
assert omd1.todict() == ref1
omd1_repr = repr(omd1)
omd1.update(omd1)
assert omd1_repr == repr(omd1)
def enter(path, key, value):
if isinstance(value, dict):
return OMD(), sorted(value.items())
return default_enter(path, key, value)
def test_types():
import collections
omd = OMD()
assert isinstance(omd, dict)
assert isinstance(omd, collections.MutableMapping)
def update_projects(self, projects):
to_update = OMD([(slugify(p.name), p) for p in projects])
new_list = []
for proj in self.project_list:
if proj.name_slug not in to_update:
new_list.append(proj)
continue
new_list.append(to_update.pop(proj.name_slug))
new_list.extend(to_update.values())
self.project_list = new_list
def _get_pkg_info(plist, project, repo_dir):
# snap: search for snapcraft.yaml
# appimage: find -iname "appimage" -type d
# flatpak: find -iname "flatpak" -type d # maybe exclude test dirs, e.g., what ansible has
# docker: find -name "Dockerfile"
ret = {}
container_stacks = OMD()
for path in iter_find_files(repo_dir, CONTAINER_FILES, include_dirs=True):
container_stacks.add(os.path.splitext(os.path.basename(path))[0].lower(), path)
#if container_stacks:
# print(container_stacks.todict())
has_docker = bool(container_stacks.pop('dockerfile', None))
container_stack = first(container_stacks.keys(), None) or ('docker' if has_docker else '')
ret['container'] = container_stack
# TODO: split into mac/windows/linux? for linux I'll need to look
# at deb/rpm, and I'm not sure the best strategy there. rpm maybe
# .spec files? might have to check inside as other tools
# (pyinstaller) uses .spec, too.
# freezers -> pyInstaller, cx_Freeze, py2exe, py2app, pynsist
# (bbFreeze phased out, osnap/constructor not yet adopted, harder
# to search for). conda and omnibus also not adopted.
#if container_stacks:
# print(container_stacks.todict())
has_docker = bool(container_stacks.pop('dockerfile', None))
container_stack = first(container_stacks.keys(), None) or ('docker' if has_docker else '')
ret['container'] = container_stack
# TODO: split into mac/windows/linux? for linux I'll need to look
# at deb/rpm, and I'm not sure the best strategy there. rpm maybe
# .spec files? might have to check inside as other tools
# (pyinstaller) uses .spec, too.
# freezers -> pyInstaller, cx_Freeze, py2exe, py2app, pynsist
# (bbFreeze phased out, osnap/constructor not yet adopted, harder
# to search for). conda and omnibus also not adopted.
freezer_res_map = OMD()
for freezer_name in FREEZERS:
search_output = search_files(freezer_name, '*', repo_dir)
if search_output:
freezer_res_map.add(freezer_name, len(search_output.splitlines()))
if freezer_res_map:
top, top_res = sorted(freezer_res_map.items(), key=lambda x: x[1])[-1]
ret['freezer'] = top
return ret
def __init__(self, project_list, tagsonomy):
self.project_list = []
self.tagsonomy = tagsonomy
self.tag_registry = OMD()
for tag_group in ('topic', 'platform'): # TODO: framework, license
for tag in self.tagsonomy[tag_group]:
self.register_tag(tag_group, tag)
errors = []
for project in project_list:
new_tags = tuple(soft_sorted(project.get('tags', []), first=self.tag_registry.keys()))
project['tags'] = new_tags
try:
project_obj = Project.from_dict(project)
except ApatiteError as ae:
errors.append(ae)
continue
self.project_list.append(project_obj)
#if container_stacks:
# print(container_stacks.todict())
has_docker = bool(container_stacks.pop('dockerfile', None))
container_stack = first(container_stacks.keys(), None) or ('docker' if has_docker else '')
ret['container'] = container_stack
# TODO: split into mac/windows/linux? for linux I'll need to look
# at deb/rpm, and I'm not sure the best strategy there. rpm maybe
# .spec files? might have to check inside as other tools
# (pyinstaller) uses .spec, too.
# freezers -> pyInstaller, cx_Freeze, py2exe, py2app, pynsist
# (bbFreeze phased out, osnap/constructor not yet adopted, harder
# to search for). conda and omnibus also not adopted.
freezer_res_map = OMD()
for freezer_name in FREEZERS:
search_output = search_files(freezer_name, '*', repo_dir)
if search_output:
freezer_res_map.add(freezer_name, len(search_output.splitlines()))
if freezer_res_map:
top, top_res = sorted(freezer_res_map.items(), key=lambda x: x[1])[-1]
ret['freezer'] = top
return ret
def get_all_secret_names(self):
"return a map of secret names to names of domains that contain that secret"
res = OMD()
for domain_name, domain in self._domains.items():
secrets_dict = domain._secrets
for secret_name in secrets_dict:
res.add(secret_name, domain_name)
return res.todict(True)