Trac 1.0.1 produces a timestamp that excludes the timezone designator (i.e.
+/-hh:mm) in the CSV file. Skipping the call to astimezone() in this case seems
to work:
~~~~~
:::python
if d.tzinfo is not None:
d = d.astimezone(pytz.UTC)
~~~~~
Unrelated to this ticket, but another issue with Trac 1.0.1, is the [byte-order
mark in the beginning of the CSV
file](http://trac.edgewall.org/changeset/10226). In my case, this caused extra
bytes to be included as part of the 'id' key of a dictionary in remap_fields().
I was able to export my data after updating that function to this:
~~~~~
:::python
def remap_fields(self, dict):
"Remap fields to adhere to standard taxonomy."
out = {}
for k, v in dict.iteritems():
key = self.match_pattern(r'\W*(\w+)\W*', k)
out[self.FIELD_MAP.get(key, key)] = v
out['id'] = int(out['id'])
if 'private' in out:
out['private'] = bool(int(out['private']))
return out
~~~~~
Attachment: allura_ticket_7177_yyachim-1.patch (1.2 kB;
application/octet-stream)
---
** [tickets:#7177] Trac ticket error: astimezone() cannot be applied to a naive
datetime**
**Status:** open
**Labels:** trac import
**Created:** Fri Feb 14, 2014 03:31 PM UTC by Dave Brondsema
**Last Updated:** Fri Feb 14, 2014 03:55 PM UTC
**Owner:** nobody
Errored on a CSV file like this from a Trac 1.0.1 instance:
__group__,ticket,summary,component,status,type,priority,owner,modified,_time,_reporter
prep,48,Create
Stuff,Application,new,build,major,nobody,2014-02-09T05:16:55-05:00,16:14:18-05:00,John
Doe
Trace:
~~~~
Traceback (most recent call last):
File "/var/local/allura/ForgeImporters/forgeimporters/base.py", line 131, in
import_tool
mount_point=mount_point, mount_label=mount_label, **kw)
File "/var/local/allura/ForgeImporters/forgeimporters/trac/tickets.py", line
119, in import_tool
json.dumps(export(trac_url), cls=DateJSONEncoder),
File "/var/local/allura/Allura/allura/scripts/trac_export.py", line 304, in
export
verbose=verbose, do_attachments=do_attachments)
File "/var/local/allura/Allura/allura/scripts/trac_export.py", line 99, in
__init__
self.ticket_queue = self.next_ticket_ids()
File "/var/local/allura/Allura/allura/scripts/trac_export.py", line 263, in
next_ticket_ids
r[1]), 'date_updated': self.trac2z_date(r[2])}
File "/var/local/allura/Allura/allura/scripts/trac_export.py", line 127, in
trac2z_date
d = d.astimezone(pytz.UTC)
ValueError: astimezone() cannot be applied to a naive datetime
~~~~
---
Sent from sourceforge.net because [email protected] is subscribed
to https://sourceforge.net/p/allura/tickets/
To unsubscribe from further messages, a project admin can change settings at
https://sourceforge.net/p/allura/admin/tickets/options. Or, if this is a
mailing list, you can unsubscribe from the mailing list.