GTG

Merge lp:~parinporecha/gtg/love_patches into lp:~gtg/gtg/old-trunk

Proposed by Parin Porecha
Status: Merged
Merged at revision: 1273
Proposed branch: lp:~parinporecha/gtg/love_patches
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 83 lines (+15/-9)
4 files modified
CHANGELOG (+2/-0)
GTG/core/task.py (+2/-1)
GTG/tests/test_tools_tags.py (+10/-7)
GTG/tools/tags.py (+1/-1)
To merge this branch: bzr merge lp:~parinporecha/gtg/love_patches
Reviewer Review Type Date Requested Status
Izidor Matušov Approve
Review via email: mp+142915@code.launchpad.net

Description of the change

This is a patch for the Bug #1095390 ( Quick Add bar incorrectly parses tags ).
It was caused due to different regexes used in quick add bar and editor.
I have replaced the quick add bar regex with the editor one.
Now, the tags containing '-' and ':' will be detected whole :)

To post a comment you must log in.
Revision history for this message
Izidor Matušov (izidor) wrote :

Please, use the extract_tags_from_text method instead of having the same RE twice. It will improve maintainablity for future.

review: Needs Fixing (code)
lp:~parinporecha/gtg/love_patches updated
1272. By Izidor Matušov

Correct handling of liblarch API 1.0

Revision history for this message
Parin Porecha (parinporecha) wrote :

Hey izidor,

I have made the changes you requested :)

> Please, use the extract_tags_from_text method instead of having the same RE
> twice. It will improve maintainablity for future.

Revision history for this message
Izidor Matušov (izidor) wrote :

Please, add couple unit test cases. (This is one of few parts of GTG that can be easily tested) :)

review: Needs Fixing (code)
lp:~parinporecha/gtg/love_patches updated
1273. By Izidor Matušov

Fix for bug #1095390: Quick Add bar incorrectly parses tags, by Parin Porecha

Revision history for this message
Izidor Matušov (izidor) wrote :

Thanks for your patch!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGELOG'
2--- CHANGELOG 2013-01-10 15:51:33 +0000
3+++ CHANGELOG 2013-01-13 18:34:21 +0000
4@@ -8,6 +8,8 @@
5 * Fix for bug #1039651: Urgency coloring of parent tasks in collapsed view, by Parin Porecha
6 * Fix for bug #1032745: Calendar widget is padded to always be visible on the screen
7 * Russian localization of help by DmDr
8+ * Fix for bug #1096622: Damaged image in the help, by Parin Porecha
9+ * Fix for bug #1095390: Quick Add bar incorrectly parses tags, by Parin Porecha
10
11 2012-11-06 Getting Things GNOME! 0.3
12 * Hide tasks with due date someday, #931376
13
14=== modified file 'GTG/core/task.py'
15--- GTG/core/task.py 2012-11-27 16:53:42 +0000
16+++ GTG/core/task.py 2013-01-13 18:34:21 +0000
17@@ -31,6 +31,7 @@
18 from GTG.tools.dates import Date
19 from GTG.tools.logger import Log
20 from liblarch import TreeNode
21+from GTG.tools.tags import extract_tags_from_text
22
23
24 class Task(TreeNode):
25@@ -148,7 +149,7 @@
26 defer_date = Date.no_date()
27 if text:
28 # Get tags in the title
29- for match in re.findall(r'(?:^|[\s])(@\w+)', text, re.UNICODE):
30+ for match in extract_tags_from_text(text):
31 tags.append(match)
32 # Get attributes
33 regexp = r'([\s]*)([\w-]+):\s*([^\s]+)'
34
35=== modified file 'GTG/tests/test_tools_tags.py'
36--- GTG/tests/test_tools_tags.py 2012-11-25 19:19:44 +0000
37+++ GTG/tests/test_tools_tags.py 2013-01-13 18:34:21 +0000
38@@ -35,8 +35,8 @@
39 self.assertEqual(tags("some text ended with @endtag"), ["@endtag"])
40
41 def test_hypen_in_tag(self):
42- self.assertEqual(tags("@tag, @my-tag, bla bla @do-this-today"),
43- ["@tag", "@my-tag", "@do-this-today"])
44+ self.assertEqual(tags("@tag, @my-tag, bla bla @do-this-today, it has @con--tinuous---hypen-s-"),
45+ ["@tag", "@my-tag", "@do-this-today", "@con--tinuous---hypen-s"])
46
47 self.assertEqual(tags("@hypen-at-end- some other text"),
48 ["@hypen-at-end"])
49@@ -44,13 +44,16 @@
50
51 def test_dot(self):
52 self.assertEqual(tags("text @gtg-0.3"), ["@gtg-0.3"])
53- self.assertEqual(tags("@tag., @my.tag, bla bla @do.this.today"),
54- ["@tag", "@my.tag", "@do.this.today"])
55+ self.assertEqual(tags("@tag., @my.tag, bla bla @do.this.today, also contains @hy-pen-.s"),
56+ ["@tag", "@my.tag", "@do.this.today", "@hy-pen-.s"])
57
58 def test_slash(self):
59- self.assertEqual(tags("@tag/, @my/tag, bla bla @do/this/today/"),
60- ["@tag", "@my/tag", "@do/this/today"])
61-
62+ self.assertEqual(tags("@tag/, @my/tag, bla bla @do/this/today/, @hy-p-/ens with @slash/es/"),
63+ ["@tag", "@my/tag", "@do/this/today", "@hy-p-/ens", "@slash/es"])
64+
65+ def test_colon(self):
66+ self.assertEqual(tags("@tag:, @my:tag, bla bla @do:this:today:, @co:l-on/s-, @:dot/s:, with @com,mas"),
67+ ["@tag", "@my:tag", "@do:this:today", "@co:l-on/s", "@:dot/s", "@com"])
68
69 def test_suite():
70 return unittest.TestLoader().loadTestsFromName(__name__)
71
72=== modified file 'GTG/tools/tags.py'
73--- GTG/tools/tags.py 2012-11-25 19:19:44 +0000
74+++ GTG/tools/tags.py 2013-01-13 18:34:21 +0000
75@@ -22,7 +22,7 @@
76
77 def extract_tags_from_text(text):
78 """ Given a string, returns a list of the @tags contained in that """
79- return re.findall(r'(?:^|[\s])(@[\w\/\.\-]*\w)', text)
80+ return re.findall(r'(?:^|[\s])(@[\w\/\.\-\:]*\w)', text)
81
82
83 def parse_tag_list(text):

Subscribers

People subscribed via source and target branches

to status/vote changes: