chg: Saner veris taxonomy generation
parent
fd2a67a9e0
commit
8fde7a0d55
|
@ -26,10 +26,11 @@ def lookupPredicate(predicate=False):
|
||||||
|
|
||||||
def lookupValues(predicate=False):
|
def lookupValues(predicate=False):
|
||||||
if not predicate:
|
if not predicate:
|
||||||
return False
|
return {}
|
||||||
for p in output['values']:
|
for p in output['values']:
|
||||||
if p['predicate'] == predicate:
|
if p['predicate'] == predicate:
|
||||||
return True
|
return p
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def machineTag(namespace=False, predicate=False, value=None, expanded=None):
|
def machineTag(namespace=False, predicate=False, value=None, expanded=None):
|
||||||
|
@ -43,14 +44,18 @@ def machineTag(namespace=False, predicate=False, value=None, expanded=None):
|
||||||
x = {}
|
x = {}
|
||||||
x['value'] = predicate
|
x['value'] = predicate
|
||||||
output['predicates'].append(x)
|
output['predicates'].append(x)
|
||||||
y = {}
|
|
||||||
y['predicate'] = predicate
|
|
||||||
y['entry'] = []
|
|
||||||
z = {}
|
z = {}
|
||||||
z['value'] = value
|
z['value'] = value
|
||||||
z['expanded'] = expanded
|
z['expanded'] = expanded
|
||||||
y['entry'].append(z)
|
predicate_entries = lookupValues(predicate)
|
||||||
output['values'].append(y)
|
if predicate_entries:
|
||||||
|
predicate_entries['entry'].append(z)
|
||||||
|
else:
|
||||||
|
y = {}
|
||||||
|
y['predicate'] = predicate
|
||||||
|
y['entry'] = []
|
||||||
|
y['entry'].append(z)
|
||||||
|
output['values'].append(y)
|
||||||
return ('{0}:{1}=\"{2}\"'.format(namespace, predicate, value))
|
return ('{0}:{1}=\"{2}\"'.format(namespace, predicate, value))
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +71,7 @@ def flatten(root, prefix_keys=True):
|
||||||
if id(d) in seen:
|
if id(d) in seen:
|
||||||
continue
|
continue
|
||||||
seen.add(id(d))
|
seen.add(id(d))
|
||||||
for k, v in d.items():
|
for k, v in sorted(d.items()):
|
||||||
new_path = path + [k]
|
new_path = path + [k]
|
||||||
prefix = ':'.join(new_path) if prefix_keys else k
|
prefix = ':'.join(new_path) if prefix_keys else k
|
||||||
if hasattr(v, 'items'):
|
if hasattr(v, 'items'):
|
||||||
|
|
23083
veris/machinetag.json
23083
veris/machinetag.json
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue