GTG

Merge lp:~james-w/gtg/better-hamster into lp:~gtg/gtg/old-trunk

Proposed by James Westby
Status: Merged
Merge reported by: Kevin Mehall
Merged at revision: not available
Proposed branch: lp:~james-w/gtg/better-hamster
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 66 lines (+29/-19)
1 file modified
GTG/plugins/hamster/hamster.py (+29/-19)
To merge this branch: bzr merge lp:~james-w/gtg/better-hamster
Reviewer Review Type Date Requested Status
Kevin Mehall (community) Approve
Luca Invernizzi (community) Abstain
Review via email: mp+18997@code.launchpad.net
To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Hi,

Here are some improvements for the hamster plugin:

  - Set the title of the fact to the be the title of the task
  - Use the category if the task has already been recorded.
  - Otherwise pick a category that is the same as one of the tag names.
  - Set tags on the created fact.
  - Remove tags from the description to avoid duplication in the hamster UI.
  - Avoid problems with the poor serialisation interface by removing any
    commas in the description.

There's a nasty interaction hiding with the @tags in the title and
the way you specify categories, but I think that needs to be fixed
on the hamster side.

Thanks,

James

lp:~james-w/gtg/better-hamster updated
583. By James Westby

Fix the use of sets.

Revision history for this message
Luca Invernizzi (invernizzi) wrote :

Hi James,
Review will be done by Kevin, the author of the hamster plugin.

review: Abstain
Revision history for this message
Kevin Mehall (kevin-mehall) wrote :

Thanks for your fixes!

I've been planning to add a preferences dialog that allows configuring how the attributes of GTG tasks map to the fields of Hamster facts. Many users have requested different behaviors than the current implementation (which is based on my workflow, but isn't necessarily the best for everyone). I'll make sure to use your code to make your preferred workflow possible.

review: Approve
Revision history for this message
Kevin Mehall (kevin-mehall) wrote :

I committed this in r592. To get the same functionality as your branch, you will want to open the Hamster plugin preferences dialog and select the options:
  Activity: GTG task title
  Category: Default to GTG tag if activity is unsorted
  Description: GTG task contents
  Tags: All GTG tags

To work around the issue with @tags in the title, I made it remove all @ and , characters from the activity name string.

If it doesn't work as expected, please let me know or propose a new merge.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GTG/plugins/hamster/hamster.py'
2--- GTG/plugins/hamster/hamster.py 2009-12-28 14:08:19 +0000
3+++ GTG/plugins/hamster/hamster.py 2010-02-10 12:11:10 +0000
4@@ -32,33 +32,43 @@
5 self.taskbutton = None
6 self.separator = gtk.SeparatorToolItem()
7 self.task_separator = None
8-
9+
10 #### Interaction with Hamster
11 def sendTask(self, task):
12 """Send a gtg task to hamster-applet"""
13 if task is None: return
14 title=task.get_title()
15- tags=task.get_tags_name()
16-
17- hamster_activities=set([unicode(x[0]) for x in self.hamster.GetActivities()])
18- tags=[t.lstrip('@').lower() for t in tags]
19- activity_candidates=hamster_activities.intersection(set(tags))
20-
21- if len(activity_candidates)>=1:
22- activity=list(activity_candidates)[0]
23- #TODO: if >1, how to choose best one?
24- elif len(tags):
25- #TODO: is there anything more reasonable that can be done?
26- activity=tags[0]
27- else:
28- activity = "Other"
29-
30- hamster_id=self.hamster.AddFact('%s,%s'%(activity, title), 0, 0)
31-
32+ tags=set([tag[1:] for tag in task.get_tags_name()])
33+ category = ""
34+
35+ # Get the category used if this task has been used before
36+ hamster_activities=dict([(unicode(x[0]), unicode(x[1])) for x in self.hamster.GetActivities()])
37+ if (title in hamster_activities
38+ or title.replace(",", "") in hamster_activities):
39+ category = "@%s" % hamster_activities[title]
40+ elif len(tags) > 0:
41+ # See if any of the tags match existing categories
42+ categories = dict([(unicode(x).lower(), unicode(x)) for x in self.hamster.GetCategories()])
43+ intersection = set(categories.keys()).intersection(set([x.lower() for x in tags]))
44+ if len(intersection) > 0:
45+ category = "@%s" % categories[intersection.pop()]
46+
47+ formatted_tags = ""
48+ for tag in tags:
49+ formatted_tags += " #%s" % tag
50+
51+ excerpt = task.get_excerpt()
52+ for tag in tags:
53+ excerpt = excerpt.replace("@%s" % tag, "")
54+
55+ fact_string = '%s%s,%s%s' % (title.replace(",", ""), category,
56+ excerpt, formatted_tags)
57+ hamster_id=self.hamster.AddFact(fact_string, 0, 0)
58+
59 ids=self.get_hamster_ids(task)
60 ids.append(str(hamster_id))
61 self.set_hamster_ids(task, ids)
62-
63+
64 def get_records(self, task):
65 """Get a list of hamster facts for a task"""
66 ids = self.get_hamster_ids(task)

Subscribers

People subscribed via source and target branches

to status/vote changes: