Merge lp:~evfool/software-center/lp983831 into lp:software-center/5.2

Proposed by Robert Roth
Status: Merged
Merged at revision: 3028
Proposed branch: lp:~evfool/software-center/lp983831
Merge into: lp:software-center/5.2
Diff against target: 37 lines (+16/-0)
2 files modified
softwarecenter/utils.py (+2/-0)
test/test_description_norm.py (+14/-0)
To merge this branch: bzr merge lp:~evfool/software-center/lp983831
Reviewer Review Type Date Requested Status
Michael Vogt Approve
Review via email: mp+106754@code.launchpad.net

Description of the change

Normalizing package descriptions had an issue with merging the last line's first word and the previous line's last word in some cases. Fixed the behaviour and added a testcase to avoid regressing.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for your work on this branch! This looks great! I tweaked it a tiny bit to provide a:

+ def maybe_add_space(prefix):
+ if not (prefix.endswith("\n") or prefix.endswith(" ")):
+ return " "
+ else:
+ return ""

So that the logic is in a single place and we could use string.whitespace here too.
Please remerge and tell me what you think :) But it should be equivalent to your fix
(which was fine already, this is really nitpicking).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/utils.py'
2--- softwarecenter/utils.py 2012-05-21 22:08:44 +0000
3+++ softwarecenter/utils.py 2012-05-22 08:15:29 +0000
4@@ -171,6 +171,8 @@
5 if in_blist:
6 in_blist = False
7 norm_description += '\n'
8+ if not norm_description.endswith("\n"):
9+ norm_description += " "
10 norm_description += part + '\n'
11 else:
12 in_blist = False
13
14=== modified file 'test/test_description_norm.py'
15--- test/test_description_norm.py 2012-01-16 14:42:49 +0000
16+++ test/test_description_norm.py 2012-05-22 08:15:29 +0000
17@@ -12,6 +12,20 @@
18 class TestAppDescriptionNormalize(unittest.TestCase):
19 """ tests the description noramlization """
20
21+ def test_description_parser_regression_test_merged_words(self):
22+ # this is a regression test for the description parser
23+ # there is a bug that the newline is stripped and two words
24+ # are merged (LP: #983831)
25+ s = """A test package
26+
27+ The goal is to test that multi-line descriptions are handled correctly,
28+ especially with regards to sentences that span more than two lines and how
29+ spaces and line wrapping is handled.
30+"""
31+ description_text = normalize_package_description(s)
32+ self.assertEqual(
33+ description_text,
34+ """A test package\nThe goal is to test that multi-line descriptions are handled correctly, especially with regards to sentences that span more than two lines and how spaces and line wrapping is handled.""")
35 def test_description_parser_regression_test_moppet(self):
36 # this is a regression test for the description parser
37 # there is a bug that after GAME FEATURES the bullet list

Subscribers

People subscribed via source and target branches