Code review comment for lp:~barry/launchpad/rnr-techdebt

Revision history for this message
Barry Warsaw (barry) wrote :

Hi Curtis, thanks for the review.

On Feb 05, 2010, at 01:34 PM, Curtis Hovey wrote:

>I really appreciate your attention to this issue. I am happy you asked me
>to review this because I am familiar with the i18n Answers issues
>in the test suite. Your diff must pass this test to be safe to commit.
>
> iconv -t ascii ~/Desktop/barry.diff > /dev/null
>
>Launchpad code is not i18n enabled, Answers and my editor is! I see
>the Arabic portions of the diff right to left. That is very exciting
>to see, but made scanning impossible, and when I look at the doctest...well
>wow, I cannot read that. I asked Björn read it and his editor refused to
>display the file.

Yes, I got too clever because I use a real editor <wink> where all those funny
characters look so beautiful.

>You can use .encode .decode to make the words ascii, or use asciismash()
>from somewhere in our code. I used both of these when I had to print the
>words out. I got tired of that so I just showed the representation.
>You can also use ellipsis if you need to hide an awkward part.

ascii_smash() comes from canonical.encoding and it seems to do a reasonable
job of making iconv happy, while still retaining enough of the original text
for Spanish. I'll have to take ascii_smash()'s word for the Arabic
conversion.

(Aside: I just had to attach a screen shot showing claws-mail's beautiful
handling of the Arabic diff, which right-to-lefts the diff lines. Not sure if
the attachment will come through on the merge-proposal or not. ;)

>You will see a lot of duplication in these tests. I was young and naive
>when I wrote them. You can consider deleting any duplication you see when
>you fix the encoding issues. There is a small chance that there is a model
>or view test that is the definitive test for many of these stories (At least
>most of the answers tests are stories)

I didn't see much duplication among the doctests I touch. I was mostly just
reading through them to get a sense for where I can hack in the R&R stuff. I
didn't touch all the .txt files though (didn't any French for instance). I'll
keep on the lookout for any additional duplication as I work on the R&R stuff.

Here's an incremental diff.

=== modified file 'lib/lp/answers/doc/person.txt'
--- lib/lp/answers/doc/person.txt 2010-02-04 08:24:18 +0000
+++ lib/lp/answers/doc/person.txt 2010-02-05 21:12:48 +0000
@@ -168,12 +168,14 @@

 But Carlos has one.

+ # Because not everyone uses a real editor <wink>
+ >>> from canonical.encoding import ascii_smash
     >>> carlos_raw = personset.getByName('carlos')
     >>> carlos = IQuestionsPerson(carlos_raw)
     >>> for question in carlos.searchQuestions(
     ... language=(english, spanish)):
- ... print question.title, question.language.code
- Problema al recompilar kernel con soporte smp (doble-núcleo) es
+ ... print ascii_smash(question.title), question.language.code
+ Problema al recompilar kernel con soporte smp (doble-nucleo) es

 Questions needing attention

=== modified file 'lib/lp/answers/doc/questionsets.txt'
--- lib/lp/answers/doc/questionsets.txt 2010-02-04 07:27:57 +0000
+++ lib/lp/answers/doc/questionsets.txt 2010-02-05 21:21:15 +0000
@@ -47,17 +47,17 @@
 The search_text parameter will return questions matching the query using the
 regular full text algorithm.

+ # Because not everyone uses a real editor <wink>
+ >>> from canonical.encoding import ascii_smash
     >>> for question in question_set.searchQuestions(search_text='firefox'):
- ... print question.title, question.target.displayname
- Problemas de Impressão no Firefox Mozilla Firefox
+ ... print ascii_smash(question.title), question.target.displayname
+ Problemas de Impressao no Firefox Mozilla Firefox
     Firefox loses focus and gets stuck Mozilla Firefox
     Firefox cannot render Bank Site Mozilla Firefox
     mailto: problem in webpage mozilla-firefox in ubuntu
     Newly installed plug-in doesn't seem to be used Mozilla Firefox
     Problem showing the SVG demo on W3C site Mozilla Firefox
- عكس التغييرات غير المحفوظة للمستن؟ Ubuntu
-
-
+ AINKAFSEEN ALEFLAMTEHGHAINYEHYEHREHALEFTEH ... Ubuntu

 Status
@@ -93,8 +93,8 @@
     >>> from lp.services.worlddata.interfaces.language import ILanguageSet
     >>> spanish = getUtility(ILanguageSet)['es']
     >>> for t in question_set.searchQuestions(language=spanish):
- ... print t.title
- Problema al recompilar kernel con soporte smp (doble-núcleo)
+ ... print ascii_smash(t.title)
+ Problema al recompilar kernel con soporte smp (doble-nucleo)

 Combinations
@@ -106,14 +106,14 @@
     >>> for question in question_set.searchQuestions(
     ... search_text='firefox',
     ... status=(QuestionStatus.OPEN, QuestionStatus.INVALID)):
- ... print question.title, question.status.title, (
+ ... print ascii_smash(question.title), question.status.title, (
     ... question.target.displayname)
- Problemas de Impressão no Firefox Open Mozilla Firefox
+ Problemas de Impressao no Firefox Open Mozilla Firefox
     Firefox is slow and consumes too much RAM Invalid mozilla-firefox in ubuntu
- Firefox loses focus and gets stuck Open Mozilla Firefox
- Firefox cannot render Bank Site Open Mozilla Firefox
- Problem showing the SVG demo on W3C site Open Mozilla Firefox
- عكس التغييرات غير المحفوظة للمستن؟ Open Ubuntu
+ Firefox loses focus and gets stuck Open Mozilla Firefox
+ Firefox cannot render Bank Site Open Mozilla Firefox
+ Problem showing the SVG demo on W3C site Open Mozilla Firefox
+ AINKAFSEEN ALEFLAMTEHGHAINYEHYEHREHALEFTEH ... Ubuntu

 Sort order
@@ -126,27 +126,27 @@
     >>> from lp.answers.interfaces.questionenums import QuestionSort
     >>> for question in question_set.searchQuestions(
     ... search_text='firefox', sort=QuestionSort.OLDEST_FIRST):
- ... print question.id, question.title, (
+ ... print question.id, ascii_smash(question.title), (
     ... question.target.displayname)
- 14 عكس التغييرات غير المحفوظة للمستن؟ Ubuntu
- 1 Firefox cannot render Bank Site Mozilla Firefox
- 2 Problem showing the SVG demo on W3C site Mozilla Firefox
- 4 Firefox loses focus and gets stuck Mozilla Firefox
- 6 Newly installed plug-in doesn't seem to be used Mozilla Firefox
+ 14 AINKAFSEEN ALEFLAMTEHGHAINYEHYEHREHALEFTEH ... Ubuntu
+ 1 Firefox cannot render Bank Site Mozilla Firefox
+ 2 Problem showing the SVG demo on W3C site Mozilla Firefox
+ 4 Firefox loses focus and gets stuck Mozilla Firefox
+ 6 Newly installed plug-in doesn't seem to be used Mozilla Firefox
     9 mailto: problem in webpage mozilla-firefox in ubuntu
- 13 Problemas de Impressão no Firefox Mozilla Firefox
+ 13 Problemas de Impressao no Firefox Mozilla Firefox

 When no text search is done, the default sort order is by newest first.

     >>> for question in question_set.searchQuestions(
     ... status=QuestionStatus.OPEN)[:5]:
- ... print question.id, question.title, (
+ ... print question.id, ascii_smash(question.title), (
     ... question.target.displayname)
- 13 Problemas de Impressão no Firefox Mozilla Firefox
- 12 Problema al recompilar kernel con soporte smp (doble-núcleo) Ubuntu
- 11 Continue playing after shutdown Ubuntu
- 5 Installation failed Ubuntu
- 4 Firefox loses focus and gets stuck Mozilla Firefox
+ 13 Problemas de Impressao no Firefox Mozilla Firefox
+ 12 Problema al recompilar kernel con soporte smp (doble-nucleo) Ubuntu
+ 11 Continue playing after shutdown Ubuntu
+ 5 Installation failed Ubuntu
+ 4 Firefox loses focus and gets stuck Mozilla Firefox

 Question languages

« Back to merge proposal