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
=== modified file 'CHANGELOG'
--- CHANGELOG 2013-01-10 15:51:33 +0000
+++ CHANGELOG 2013-01-13 18:34:21 +0000
@@ -8,6 +8,8 @@
8 * Fix for bug #1039651: Urgency coloring of parent tasks in collapsed view, by Parin Porecha8 * Fix for bug #1039651: Urgency coloring of parent tasks in collapsed view, by Parin Porecha
9 * Fix for bug #1032745: Calendar widget is padded to always be visible on the screen9 * Fix for bug #1032745: Calendar widget is padded to always be visible on the screen
10 * Russian localization of help by DmDr10 * Russian localization of help by DmDr
11 * Fix for bug #1096622: Damaged image in the help, by Parin Porecha
12 * Fix for bug #1095390: Quick Add bar incorrectly parses tags, by Parin Porecha
1113
122012-11-06 Getting Things GNOME! 0.3142012-11-06 Getting Things GNOME! 0.3
13 * Hide tasks with due date someday, #93137615 * Hide tasks with due date someday, #931376
1416
=== modified file 'GTG/core/task.py'
--- GTG/core/task.py 2012-11-27 16:53:42 +0000
+++ GTG/core/task.py 2013-01-13 18:34:21 +0000
@@ -31,6 +31,7 @@
31from GTG.tools.dates import Date31from GTG.tools.dates import Date
32from GTG.tools.logger import Log32from GTG.tools.logger import Log
33from liblarch import TreeNode33from liblarch import TreeNode
34from GTG.tools.tags import extract_tags_from_text
3435
3536
36class Task(TreeNode):37class Task(TreeNode):
@@ -148,7 +149,7 @@
148 defer_date = Date.no_date()149 defer_date = Date.no_date()
149 if text:150 if text:
150 # Get tags in the title151 # Get tags in the title
151 for match in re.findall(r'(?:^|[\s])(@\w+)', text, re.UNICODE):152 for match in extract_tags_from_text(text):
152 tags.append(match)153 tags.append(match)
153 # Get attributes154 # Get attributes
154 regexp = r'([\s]*)([\w-]+):\s*([^\s]+)'155 regexp = r'([\s]*)([\w-]+):\s*([^\s]+)'
155156
=== modified file 'GTG/tests/test_tools_tags.py'
--- GTG/tests/test_tools_tags.py 2012-11-25 19:19:44 +0000
+++ GTG/tests/test_tools_tags.py 2013-01-13 18:34:21 +0000
@@ -35,8 +35,8 @@
35 self.assertEqual(tags("some text ended with @endtag"), ["@endtag"])35 self.assertEqual(tags("some text ended with @endtag"), ["@endtag"])
3636
37 def test_hypen_in_tag(self):37 def test_hypen_in_tag(self):
38 self.assertEqual(tags("@tag, @my-tag, bla bla @do-this-today"),38 self.assertEqual(tags("@tag, @my-tag, bla bla @do-this-today, it has @con--tinuous---hypen-s-"),
39 ["@tag", "@my-tag", "@do-this-today"])39 ["@tag", "@my-tag", "@do-this-today", "@con--tinuous---hypen-s"])
4040
41 self.assertEqual(tags("@hypen-at-end- some other text"),41 self.assertEqual(tags("@hypen-at-end- some other text"),
42 ["@hypen-at-end"])42 ["@hypen-at-end"])
@@ -44,13 +44,16 @@
4444
45 def test_dot(self):45 def test_dot(self):
46 self.assertEqual(tags("text @gtg-0.3"), ["@gtg-0.3"])46 self.assertEqual(tags("text @gtg-0.3"), ["@gtg-0.3"])
47 self.assertEqual(tags("@tag., @my.tag, bla bla @do.this.today"),47 self.assertEqual(tags("@tag., @my.tag, bla bla @do.this.today, also contains @hy-pen-.s"),
48 ["@tag", "@my.tag", "@do.this.today"])48 ["@tag", "@my.tag", "@do.this.today", "@hy-pen-.s"])
4949
50 def test_slash(self):50 def test_slash(self):
51 self.assertEqual(tags("@tag/, @my/tag, bla bla @do/this/today/"),51 self.assertEqual(tags("@tag/, @my/tag, bla bla @do/this/today/, @hy-p-/ens with @slash/es/"),
52 ["@tag", "@my/tag", "@do/this/today"])52 ["@tag", "@my/tag", "@do/this/today", "@hy-p-/ens", "@slash/es"])
5353
54 def test_colon(self):
55 self.assertEqual(tags("@tag:, @my:tag, bla bla @do:this:today:, @co:l-on/s-, @:dot/s:, with @com,mas"),
56 ["@tag", "@my:tag", "@do:this:today", "@co:l-on/s", "@:dot/s", "@com"])
5457
55def test_suite():58def test_suite():
56 return unittest.TestLoader().loadTestsFromName(__name__)59 return unittest.TestLoader().loadTestsFromName(__name__)
5760
=== modified file 'GTG/tools/tags.py'
--- GTG/tools/tags.py 2012-11-25 19:19:44 +0000
+++ GTG/tools/tags.py 2013-01-13 18:34:21 +0000
@@ -22,7 +22,7 @@
2222
23def extract_tags_from_text(text):23def extract_tags_from_text(text):
24 """ Given a string, returns a list of the @tags contained in that """24 """ Given a string, returns a list of the @tags contained in that """
25 return re.findall(r'(?:^|[\s])(@[\w\/\.\-]*\w)', text)25 return re.findall(r'(?:^|[\s])(@[\w\/\.\-\:]*\w)', text)
2626
2727
28def parse_tag_list(text):28def parse_tag_list(text):

Subscribers

People subscribed via source and target branches

to status/vote changes: