Skip to content

Commit

Permalink
Make custom_keys, time_keys optional. Fixes #14, first reported in #13.
Browse files Browse the repository at this point in the history
  • Loading branch information
firebus committed Nov 5, 2013
1 parent 6436838 commit bad727c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
40 changes: 22 additions & 18 deletions bin/jira.py
Expand Up @@ -88,26 +88,30 @@
row[k] = v[0].text

for k in time_keys:
v = elem.xpath(k)
if len(v) == 1:
row[k] = v[0].get("seconds")
# If time_keys is empty, then the split above results in ['']
if k:
v = elem.xpath(k)
if len(v) == 1:
row[k] = v[0].get("seconds")

for k in custom_keys:
v = elem.xpath('customfields/customfield/customfieldvalues/customfieldvalue[../../customfieldname/text() = "%s"]' % k)
if len(v) > 1:
row[k] = [val.text for val in v]
if '__mv_' + k not in header:
header.append('__mv_' + k)
elif len(v) == 1:
row[k] = v[0].text

v = elem.xpath('customfields/customfield/customfieldvalues/label[../../customfieldname/text() = "%s"]' % k)
if len(v) > 1:
row[k] = [val.text for val in v]
if '__mv_' + k not in header:
header.append('__mv_' + k)
elif len(v) == 1:
row[k] = v[0].text
# If custom_keys is empty, then the split above results in ['']
if k:
v = elem.xpath('customfields/customfield/customfieldvalues/customfieldvalue[../../customfieldname/text() = "%s"]' % k)
if len(v) > 1:
row[k] = [val.text for val in v]
if '__mv_' + k not in header:
header.append('__mv_' + k)
elif len(v) == 1:
row[k] = v[0].text

v = elem.xpath('customfields/customfield/customfieldvalues/label[../../customfieldname/text() = "%s"]' % k)
if len(v) > 1:
row[k] = [val.text for val in v]
if '__mv_' + k not in header:
header.append('__mv_' + k)
elif len(v) == 1:
row[k] = v[0].text

# Add a _time field by converting updated into a timestamp. This is helpful if you're piping results to collect.
# if 'updated' in keys:
Expand Down
7 changes: 4 additions & 3 deletions default/jira.conf
Expand Up @@ -2,9 +2,10 @@
default_project = WTF
tempMax = 1000

# Built-in fields to display. Updated is required if you want a _time field.
# Built-in fields to display. Required
# updated is required if you want a _time field.
keys = link,project,key,summary,type,priority,status,resolution,assignee,reporter,created,updated,resolved,fixVersion,components
# Fields containing times to display.
# Fields containing times to display. Optional.
time_keys =
# Custom fields to display.
# Custom fields to display. Optional.
custom_keys =

0 comments on commit bad727c

Please sign in to comment.