|
a/migrate-3rdparty/trac_export.py |
|
b/migrate-3rdparty/trac_export.py |
|
... |
|
... |
20 |
def parse_options():
|
20 |
def parse_options():
|
21 |
optparser = OptionParser(usage=''' %prog <Trac URL>
|
21 |
optparser = OptionParser(usage=''' %prog <Trac URL>
|
22 |
|
22 |
|
23 |
Export ticket data from a Trac instance''')
|
23 |
Export ticket data from a Trac instance''')
|
24 |
optparser.add_option('-o', '--out-file', dest='out_filename', help='Write to file (default stdout)')
|
24 |
optparser.add_option('-o', '--out-file', dest='out_filename', help='Write to file (default stdout)')
|
25 |
optparser.add_option('--no-attachments', dest='do_attachments', action='store_false', defaulr=True, help='Export attachment info')
|
25 |
optparser.add_option('--no-attachments', dest='do_attachments', action='store_false', default=True, help='Export attachment info')
|
26 |
optparser.add_option('--only-tickets', dest='only_tickets', action='store_true', help='Export only ticket list')
|
26 |
optparser.add_option('--only-tickets', dest='only_tickets', action='store_true', help='Export only ticket list')
|
27 |
optparser.add_option('--start', dest='start_id', type='int', default=1, help='Start with given ticket numer (or next accessible)')
|
27 |
optparser.add_option('--start', dest='start_id', type='int', default=1, help='Start with given ticket numer (or next accessible)')
|
28 |
optparser.add_option('--limit', dest='limit', type='int', default=None, help='Limit number of tickets')
|
28 |
optparser.add_option('--limit', dest='limit', type='int', default=None, help='Limit number of tickets')
|
29 |
optparser.add_option('-v', '--verbose', dest='verbose', action='store_true', help='Verbose operation')
|
29 |
optparser.add_option('-v', '--verbose', dest='verbose', action='store_true', help='Verbose operation')
|
30 |
options, args = optparser.parse_args()
|
30 |
options, args = optparser.parse_args()
|
|
... |
|
... |
152 |
timestamp_s = attach.find('a', {'class': 'timeline'})['title']
|
152 |
timestamp_s = attach.find('a', {'class': 'timeline'})['title']
|
153 |
d['date'] = self.trac2z_date(self.match_pattern(TIMESTAMP_PATTERN, timestamp_s))
|
153 |
d['date'] = self.trac2z_date(self.match_pattern(TIMESTAMP_PATTERN, timestamp_s))
|
154 |
d['by'] = attach.find(text=re.compile('added by')).nextSibling.renderContents()
|
154 |
d['by'] = attach.find(text=re.compile('added by')).nextSibling.renderContents()
|
155 |
d['description'] = ''
|
155 |
d['description'] = ''
|
156 |
# Skip whitespace
|
156 |
# Skip whitespace
|
157 |
while type(attach.nextSibling) is NavigableString:
|
157 |
while attach.nextSibling and type(attach.nextSibling) is NavigableString:
|
158 |
attach = attach.nextSibling
|
158 |
attach = attach.nextSibling
|
159 |
# if there's a description, there will be a <dd> element, other immediately next <dt>
|
159 |
# if there's a description, there will be a <dd> element, other immediately next <dt>
|
160 |
if attach.nextSibling.name == 'dd':
|
160 |
if attach.nextSibling and attach.nextSibling.name == 'dd':
|
161 |
desc_el = attach.nextSibling
|
161 |
desc_el = attach.nextSibling
|
162 |
if desc_el:
|
162 |
if desc_el:
|
163 |
# TODO: Convert to Allura link syntax as needed
|
163 |
# TODO: Convert to Allura link syntax as needed
|
164 |
d['description'] = ''.join(desc_el.findAll(text=True)).strip()
|
164 |
d['description'] = ''.join(desc_el.findAll(text=True)).strip()
|
165 |
list.append(d)
|
165 |
list.append(d)
|