comparison env/lib/python3.7/site-packages/gxformat2/_labels.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
1 """Utilities for handling unlabelled objects when translating workflow formats."""
2
3
4 class Labels(object):
5 """Track labels assigned and generate anonymous ones."""
6
7 def __init__(self):
8 """Initialize labels that have been encountered or generated."""
9 self.seen_labels = set()
10 self.anonymous_labels = 0
11
12 def ensure_new_output_label(self, label):
13 """Ensure supplied label has value or generate an anonymous one."""
14 if label is None:
15 self.anonymous_labels += 1
16 label = "_anonymous_output_%d" % self.anonymous_labels
17 assert label not in self.seen_labels
18 self.seen_labels.add(label)
19 return label
20
21 @staticmethod
22 def is_anonymous_output_label(label):
23 """Predicate determining if supplied label was generated for anonymous output."""
24 # label likely can't be null according to the schema definition - but we've got a test
25 # in Galaxy that doesn't define a label in order to great a .ga file without output
26 # labels (which is completely normal).
27 return not label or label.startswith("_anonymous_output_")