]> scripts.mit.edu Git - wizard.git/blob - wizard/command/summary/_summary.py
Refactor get*() to .() with property decorator.
[wizard.git] / wizard / command / summary / _summary.py
1 import logging
2
3 from wizard import deploy
4
5 def parse_install_lines(show, options, yield_errors = False):
6     if not show: show = deploy.applications
7     show = frozenset(show)
8     for line in deploy.getInstallLines(options.versions_path):
9         # construction
10         try:
11             d = deploy.Deployment.parse(line)
12             name = d.application.name
13         except deploy.NoSuchApplication as e:
14             if yield_errors:
15                 yield e
16             continue
17         except deploy.Error:
18             # we consider this a worse error
19             logging.warning("Error with '%s'" % line.rstrip())
20             continue
21         # filter
22         if name + "-" + str(d.version) in show or name in show:
23             pass
24         else:
25             continue
26         # yield
27         yield d
28
29 class Counter(object):
30     def __init__(self):
31         self.dict = {}
32     def count(self, value):
33         self.dict.setdefault(value, 0)
34         self.dict[value] += 1
35     def __getitem__(self, key):
36         return self.dict[key]
37     def __iter__(self):
38         return self.dict.__iter__()
39