Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def make_targets(rules, config, application, **kw):
TARGETS = []
all_versions = get_versions(config[application])
for r in rules:
p = {}
if not r.name.startswith(application.replace("-", "_")):
continue
for label, out in r.output.items():
if "{end}" in str(out):
p['end'] = config[application][r.name].get("_end", kw['end'])
if "{version}" in str(out):
versions = get_versions(config[application][r.name], all_versions)
p['version'] = versions
TMP = expand(out, **p)
TARGETS = TARGETS + list(TMP)
return TARGETS
rule.missing_config.update(annotation.expand_variables(rule.full_name))
export_annotations[i] = (annotation, export_name)
plain_name, attr = annotation.split()
if not attr:
plain_annotations.add(plain_name)
else:
possible_plain_annotations.add(plain_name)
# Add plain annotations where needed
for a in possible_plain_annotations.difference(plain_annotations):
export_annotations.append((annotation_type(a), None))
for annotation, export_name in export_annotations:
if param.default.is_input:
if param_type == ExportAnnotationsAllDocs:
rule.inputs.extend(
expand(escape_wildcards(paths.annotation_dir / get_annotation_path(annotation.name)),
doc=get_source_files(storage.source_files)))
else:
rule.inputs.append(paths.annotation_dir / get_annotation_path(annotation.name))
rule.parameters[param_name].append((annotation, export_name))
# Corpus
elif param.annotation == Corpus:
rule.parameters[param_name] = Corpus(sparv_config.get("metadata.id"))
# Language
elif param.annotation == Language:
rule.parameters[param_name] = Language(sparv_config.get("metadata.language"))
# Document
elif param.annotation == Document:
rule.docs.append(param_name)
# AllDocuments (all source documents)
elif param_type == AllDocuments:
rule.parameters[param_name] = AllDocuments(get_source_files(storage.source_files))
def update(d, u, c):
for k, v in u.items():
if isinstance(v, collections.Mapping):
r = update(d.get(k, {}), v, c)
d[k] = r
else:
if isinstance(fill, pd.DataFrame):
d[k] = list(set(expand(u[k], zip, **fill.to_dict('list'))))
else:
d[k] = list(set(expand(u[k], c, **fill)))
if not d[k]:
d[k] = [u[k]]
return d
d = {}
def render_r1_r2(pattern):
return expand(pattern, sample='{sample}', n=[1,2])
def update(d, u, c):
for k, v in u.items():
if isinstance(v, collections.Mapping):
r = update(d.get(k, {}), v, c)
d[k] = r
else:
if isinstance(fill, pd.DataFrame):
d[k] = list(set(expand(u[k], zip, **fill.to_dict('list'))))
else:
d[k] = list(set(expand(u[k], c, **fill)))
if not d[k]:
d[k] = [u[k]]
return d
d = {}
else:
param_value = param.default
param_type, param_list, param_optional = registry.get_type_hint_type(param.annotation)
# Output
if issubclass(param_type, BaseOutput):
if not isinstance(param_value, BaseOutput):
if not param_value:
return False
param_value = param_type(param_value)
missing_configs = param_value.expand_variables(rule.full_name)
rule.missing_config.update(missing_configs)
ann_path = get_annotation_path(param_value, data=param_type.data, common=param_type.common)
if param_type.all_docs:
rule.outputs.extend(map(Path, expand(escape_wildcards(paths.annotation_dir / ann_path),
doc=get_source_files(storage.source_files))))
elif param_type.common:
rule.outputs.append(paths.annotation_dir / ann_path)
if rule.installer:
storage.install_outputs[rule.target_name].append(paths.annotation_dir / ann_path)
else:
rule.outputs.append(get_annotation_path(param_value, data=param_type.data))
rule.parameters[param_name] = param_value
if "{" in param_value:
rule.wildcard_annotations.append(param_name)
storage.all_annotations.setdefault(rule.module_name, {}).setdefault(rule.f_name,
{"description": rule.description,
"annotations": []})
storage.all_annotations[rule.module_name][rule.f_name]["annotations"].append((param_value,
param_value.description))
# ModelOutput
def func(wc):
try:
wc.sample
except AttributeError:
raise ValueError(
'Need "{{sample}}" in pattern '
'"{pattern}"'.format(pattern=pattern))
n = [1]
if is_paired_end(sampletable, wc.sample) and not r1_only:
n = [1, 2]
res = expand(pattern, sample=wc.sample, n=n)
return res
return func