help='Regex pattern for blueprint name', dest='pattern')
optparser.add_option('-D', '--dump', action='store_true', default=False,
help='Dump database', dest='dump')
+ optparser.add_option('-m', '--moin', metavar='URL',
+ help='moin URL for additional work items (can be given multiple times)',
+ action='append', dest='moin', default=[])
optparser.add_option('-t', '--text', action='store_true', default=False,
help='Print work item summary in text format', dest='text')
optparser.add_option('-c', '--csv', action='store_true', default=False,
return result
-def get_workitems(blueprint_url):
+def get_blueprint_workitems(blueprint_url):
'''Collect work items from a particular blueprint URL.
This will return a list of ('item', 'status') pairs.
return result
+def get_moin_workitems(url):
+ '''Collect work items from a moin wiki URL.
+
+ Every line starting with "|| " is treated as a work item.
+
+ Return a list of ('item', 'status') pairs.
+ '''
+ result = []
+ for line in urllib.urlopen(url):
+ if line.startswith('|| '):
+ fields = line.strip().split('||')
+ assert not fields[0] # should be empty
+ desc = fields[1].strip()
+ for f in fields[2:]:
+ if 'DONE' in f:
+ result.append((desc, 'done'))
+ break
+ elif 'POSTPONED' in f:
+ result.append((desc, 'done'))
+ break
+ else:
+ result.append((desc, 'todo'))
+
+ return result
+
def dump(db):
'''Dump database contents.'''
for bp in blueprints:
#print 'Checking', bp
bpname = bp.split('/')[-1]
- work_items = get_workitems(bp)
+ work_items = get_blueprint_workitems(bp)
if not work_items:
print >> sys.stderr, 'WARNING: %s has no work items' % bpname
for (item, status) in work_items:
add_work_item(db, bpname, item, status)
- db.commit()
def workitems_over_time(db):
'''Calculate work item development over time.
entry.get('postponed', 0))
d += datetime.timedelta(days=1)
+def import_moin(db, urls):
+ '''Collect blueprint work items from a moin wiki.'''
+
+ for url in urls:
+ for (d, s) in get_moin_workitems(url):
+ add_work_item(db, url, d, s)
+
#
# main
#
csv(db, opts.from_date, opts.to_date)
else:
import_lp(db, opts.pattern, opts.release)
+ import_moin(db, opts.moin)
+ db.commit()