Skip to content


How to load ditz issues into python

Ditz is a fantastic distributed bug tracking system written in Ruby.

Here’s some code that you can use to load some ditz issues into a python interpreter. You need to install my pitz project first though.


>>> from pitz.junkyard.ditzloader import *
>>> from glob import glob
>>> issue_file_path = glob('../.ditz/issue-*.yaml')[0]
>>> import yaml
>>> issue = yaml.load(open(issue_file_path))
>>> issue.title
'Distribute reports by email'
>>> print issue.desc
Somehow allow people to sign up for report subscriptions.


So when new reports come out, they get updated.  Maybe I can use
<b>RSS</b> feeds to hold the reports.
>>> print issue.log_events
[[datetime.datetime(2008, 9, 2, 17, 47, 44, 549355), 'Matthew Wilson <mw@staffknex.com>', 'created', ''], [datetime.datetime(2008, 9, 2, 19, 18, 3, 286902), 'Matthew Wilson <mw@staffknex.com>', 'assigned to release 3.5.1 from unassigned', ''], [datetime.datetime(2008, 9, 4, 18, 27, 19, 571991), 'Matthew Wilson <mw@staffknex.com>', 'unassigned from release 3.5.1', '']]

That above just showed how to read the ditz issue. I’m having trouble updating the issue and then saving it in a format that ditz can still read. Updating the ditz issue and saving it out again is easy:


>>> issue.title = 'Distribute reports by email or RSS'
>>> open(issue_file_path, 'w').write(yaml.dump(issue))

But when I try to load it with ditz, I get this error:


$ ditz show 1209b
/home/matt/checkouts/ditz/lib/ditz/model-objects.rb:124:in `sort_by': comparison of String with Time failed (ArgumentError)
        from /home/matt/checkouts/ditz/lib/ditz/model-objects.rb:124:in `assign_issue_names!'
        from /home/matt/checkouts/ditz/lib/ditz/model-objects.rb:51:in `issues='
        from /home/matt/checkouts/ditz/lib/ditz/file-storage.rb:21:in `load'
        from /home/matt/checkouts/ditz/bin/ditz:165

I compared my dumped file to the original ruby file and found that python wrote dates out like this:


>>> print yaml.dump(issue.creation_time)
2008-09-02 17:47:43.268059

But in the ruby yaml files, the dates look like this:


$ grep creation_time ../../../.ditz/issue-1209b17b64335383a710ccadf10b74c3401dbcb2.yaml 
creation_time: 2008-09-02 17:47:43.268059 Z

That trailing Z seems important.

Also, python and ruby seem to write out lists differently. Here’s how python dumped a list of lists:


>>> print yaml.dump(issue.log_events)
- [!!timestamp '2008-09-02 17:47:44.549355', Matthew Wilson <mw@staffknex.com>, created,
  '']
- [!!timestamp '2008-09-02 19:18:03.286902', Matthew Wilson <mw@staffknex.com>, assigned
    to release 3.5.1 from unassigned, '']
- [!!timestamp '2008-09-04 18:27:19.571991', Matthew Wilson <mw@staffknex.com>, unassigned
    from release 3.5.1, '']

But the same data dumped by ruby looks like:


log_events:
- - 2008-09-02 17:47:44.549355 Z
  - Matthew Wilson <mw@staffknex.com>
  - created
  - ""
- - 2008-09-02 19:18:03.286902 Z
  - Matthew Wilson <mw@staffknex.com>
  - assigned to release 3.5.1 from unassigned
  - ""
- - 2008-09-04 18:27:19.571991 Z
  - Matthew Wilson <mw@staffknex.com>
  - unassigned from release 3.5.1
  - ""

So, there’s clearly some more work for me (or you, this is an open-source project) to do.

Posted in Programming, Python, pitz.

Viewing 5 Comments

 
close Reblog this comment
blog comments powered by Disqus