def resolve_topics(known, topics, soft=True): """ Given a list of topic names, which could contain "*" return res, resolved2asked, asked2resolved """ res = [] for t in topics: matches = list(get_wildcard_matches(t, known)) if not matches: if soft: warnings.warn('make this better') print('warning, no match for %r' % t) res.append(t) continue else: raise_x_not_found('topic', t, known) if len(matches) >= 2: msg = 'Too many matches for %s: %s' % (t, matches) raise ValueError(msg) res.append(matches[0]) asked2resolved = {} resolved2asked = {} for a, t in zip(topics, res): resolved2asked[t] = a asked2resolved[a] = t return res, resolved2asked, asked2resolved
def make_all_dds(config, which, outdir): if not os.path.exists(outdir): os.makedirs(outdir) for id_symdds in which: if not id_symdds in config.symdds: raise_x_not_found('symdds', id_symdds, config.symdds) for id_symdds in which: make_dds(config, id_symdds, outdir)
def index_from_label(self, label): """ Get the index of the action with a given label. """ for i, a in enumerate(self.actions): if a.label == label: return i raise_x_not_found('label', label, [a.label for a in self.actions])