Merge lp:~ivo-kracht/launchpad/bug-425934 into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Abel Deuring on 2012-06-20 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 15458 |
| Proposed branch: | lp:~ivo-kracht/launchpad/bug-425934 |
| Merge into: | lp:launchpad |
| Diff against target: |
246 lines (+83/-20) 7 files modified
lib/lp/bugs/mail/commands.py (+2/-0) lib/lp/bugs/mail/handler.py (+4/-3) lib/lp/code/mail/codehandler.py (+1/-1) lib/lp/services/mail/commands.py (+7/-2) lib/lp/services/mail/helpers.py (+9/-2) lib/lp/services/mail/tests/test_commands.py (+34/-1) lib/lp/services/mail/tests/test_helpers.py (+26/-11) |
| To merge this branch: | bzr merge lp:~ivo-kracht/launchpad/bug-425934 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Raphaël Badin (community) | 2012-06-20 | Approve on 2012-06-20 | |
| Francesco Banconi (community) | code* | Approve on 2012-06-20 | |
| Ivo Kracht (community) | Resubmit on 2012-06-20 | ||
| Benji York (community) | code | 2012-06-18 | Approve on 2012-06-18 |
|
Review via email:
|
|||
Commit Message
Fix for bug-425934 - email commands are now case insensitive.
Description of the Change
I changed one line in the helper.py so that it converts all uppercase characters to lowercase characters. Incoming commands and args are now case insensitive. Converting everything to lowercase in the parse.commands function may be a little bit rough but should not create any problems. The only potential problem i can see is when project names and/or usernames are passed to the function but as far as I can see they have to be lowercase anyway.
Pre-imp call with adeuring
tests:
./bin/test services -vvt test_helpers
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
| Ivo Kracht (ivo-kracht) wrote : | # |
An EC2 test failed because some email command have to be uppercase (summary, cve) so I had to except those from being converted to lowercase. I did that by adding a new value called lowercase_args that can be set to False if a command should be case sensitive. Also i changed the names function into parsingParameters and wrote a unit test for its new task.
Pre-imp call with adeuring
tests:
lib/lp/
lib/lp/
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
| Francesco Banconi (frankban) wrote : | # |
Another great contribution Ivo, thank you.
Suggestions follow.
#8
+ lowercase_args = False
Just an idea, and just a naming doubt: it seems that what we want to express here is the concept of a command with case insensitive args, and that converting them to lowercase is just an implementation detail. Maybe you could use a `case_insensiti
#97 and #104
if len(words) > 0:
Isn't it more "pythonic" to just check `if words:`?
#106
+ if command_
+ words = words.lower()
+ words = words.split(' ')
This is really a personal opinion, and maybe I am wrong, but I think the code could be more readable if written as::
case_
if case_insensitiv
words = words.lower()
commands.
| Raphaël Badin (rvb) wrote : | # |
Looks good.
[0]
I agree with Francesco's suggestions. Well, all suggestions but one: I think you should keep "if len(words) > 0:" because it's more specific than using "if words". For the same reason, if you want to test if "something" is None, we would rather write explicitly "if something is not None:" rather than "if something:".
[1]
147 + self.assertEqual(
148 + {'one': True,
149 + 'two': False,
150 + },
151 + SampleCommandCo
This is really a detail but I think you could write this as
self.
{'one': True, 'two': False},
It would (artificially) reduce the SLOC and I think it's more readable. But again, it's really a detail so feel to change it or not.

This branch looks good.
It might be slightly better to move the comment about commands having to be indented to just before the "if" because the "lower" line doesn't have anything to do with indentation. You could optionally also add a comment about the fact that we ignore capitalisation in commands just before the "lower" line.