import logging from wizard import deploy def parse_install_lines(show, options, yield_errors = False): if not show: show = deploy.applications show = frozenset(show) for line in deploy.getInstallLines(options.versions_path): # construction try: d = deploy.Deployment.parse(line) name = d.application.name except deploy.NoSuchApplication as e: if yield_errors: yield e continue except deploy.Error: # we consider this a worse error logging.warning("Error with '%s'" % line.rstrip()) continue # filter if name + "-" + str(d.version) in show or name in show: pass else: continue # yield yield d class Counter(object): def __init__(self): self.dict = {} def count(self, value): self.dict.setdefault(value, 0) self.dict[value] += 1 def __getitem__(self, key): return self.dict[key] def __iter__(self): return self.dict.__iter__()