From 64eaf96eb862017209eedf0ba848dd973edcd1b1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 29 Sep 2016 10:34:41 +0100 Subject: [PATCH 1/5] Add rule --- thefuck/rules/remove_trailing_cedilla.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 thefuck/rules/remove_trailing_cedilla.py diff --git a/thefuck/rules/remove_trailing_cedilla.py b/thefuck/rules/remove_trailing_cedilla.py new file mode 100644 index 00000000..9439c06c --- /dev/null +++ b/thefuck/rules/remove_trailing_cedilla.py @@ -0,0 +1,6 @@ +def match(command): + return command.script.endswith('ç') + +def get_new_command(command): + return command.script[:-1] + From 92133f77d6b3bbfac88e11b8269f2c7a16d2a899 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 29 Sep 2016 10:44:17 +0100 Subject: [PATCH 2/5] Add test file --- README.md | 1 + tests/rules/test_remove_trailing_cedilla.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/rules/test_remove_trailing_cedilla.py diff --git a/README.md b/README.md index 254f2b2b..cdb0f132 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,7 @@ using the matched rule and runs it. Rules enabled by default are as follows: * `vagrant_up` – starts up the vagrant instance; * `whois` – fixes `whois` command; * `workon_doesnt_exists` – fixes `virtualenvwrapper` env name os suggests to create new. +* `remove_trailing_cedilla` – remove trailling cedillas `ç`, a common typo for european keyboard layouts; Enabled by default only on specific platforms: diff --git a/tests/rules/test_remove_trailing_cedilla.py b/tests/rules/test_remove_trailing_cedilla.py new file mode 100644 index 00000000..473f8d41 --- /dev/null +++ b/tests/rules/test_remove_trailing_cedilla.py @@ -0,0 +1,16 @@ +import pytest +from thefuck.rules.remove_trailing_cedilla import match, get_new_command +from tests.utils import Command + +@pytest.mark.parametrize('command', [ + Command(script='wrongç'), + Command(script='wrong with argsç')]) + +def test_match(command): + assert match(command) + +@pytest.mark.parametrize('command, new_command', [ + (Command('wrongç'), 'wrong'), + (Command('wrong with argsç'), 'wrong with args')]) +def test_get_new_command(command, new_command): + assert get_new_command(command) == new_command From 8938323229f65b021919b9778af598418c8e2eeb Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 29 Sep 2016 11:06:56 +0100 Subject: [PATCH 3/5] Fix encoding --- tests/rules/test_remove_trailing_cedilla.py | 2 ++ thefuck/rules/remove_trailing_cedilla.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/rules/test_remove_trailing_cedilla.py b/tests/rules/test_remove_trailing_cedilla.py index 473f8d41..481d4710 100644 --- a/tests/rules/test_remove_trailing_cedilla.py +++ b/tests/rules/test_remove_trailing_cedilla.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import pytest from thefuck.rules.remove_trailing_cedilla import match, get_new_command from tests.utils import Command diff --git a/thefuck/rules/remove_trailing_cedilla.py b/thefuck/rules/remove_trailing_cedilla.py index 9439c06c..15124fa4 100644 --- a/thefuck/rules/remove_trailing_cedilla.py +++ b/thefuck/rules/remove_trailing_cedilla.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + def match(command): return command.script.endswith('ç') From ad53023860b10f6d5886d212b804dcb32eec8430 Mon Sep 17 00:00:00 2001 From: Daniel Herzog Date: Thu, 29 Sep 2016 21:41:50 +0100 Subject: [PATCH 4/5] Fix encoding for Python 2.7 --- tests/rules/test_remove_trailing_cedilla.py | 13 +++++-------- thefuck/rules/remove_trailing_cedilla.py | 7 ++++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/rules/test_remove_trailing_cedilla.py b/tests/rules/test_remove_trailing_cedilla.py index 481d4710..377ff8fc 100644 --- a/tests/rules/test_remove_trailing_cedilla.py +++ b/tests/rules/test_remove_trailing_cedilla.py @@ -1,18 +1,15 @@ -# -*- coding: utf-8 -*- - import pytest -from thefuck.rules.remove_trailing_cedilla import match, get_new_command +from thefuck.rules.remove_trailing_cedilla import match, get_new_command, CEDILLA from tests.utils import Command @pytest.mark.parametrize('command', [ - Command(script='wrongç'), - Command(script='wrong with argsç')]) - + Command(script='wrong' + CEDILLA), + Command(script='wrong with args' + CEDILLA)]) def test_match(command): assert match(command) @pytest.mark.parametrize('command, new_command', [ - (Command('wrongç'), 'wrong'), - (Command('wrong with argsç'), 'wrong with args')]) + (Command('wrong' + CEDILLA), 'wrong'), + (Command('wrong with args' + CEDILLA), 'wrong with args')]) def test_get_new_command(command, new_command): assert get_new_command(command) == new_command diff --git a/thefuck/rules/remove_trailing_cedilla.py b/thefuck/rules/remove_trailing_cedilla.py index 15124fa4..31186448 100644 --- a/thefuck/rules/remove_trailing_cedilla.py +++ b/thefuck/rules/remove_trailing_cedilla.py @@ -1,8 +1,9 @@ -# -*- coding: utf-8 -*- +# encoding=utf8 + +CEDILLA = u"ç" def match(command): - return command.script.endswith('ç') + return command.script.endswith(CEDILLA) def get_new_command(command): return command.script[:-1] - From c3bcdd7deedd8ed79ed14467e0f4a8650622deca Mon Sep 17 00:00:00 2001 From: Daniel Herzog Date: Thu, 29 Sep 2016 21:43:02 +0100 Subject: [PATCH 5/5] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cdb0f132..14984fdc 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,7 @@ using the matched rule and runs it. Rules enabled by default are as follows: * `python_execute` – appends missing `.py` when executing Python files; * `quotation_marks` – fixes uneven usage of `'` and `"` when containing args'; * `react_native_command_unrecognized` – fixes unrecognized `react-native` commands; +* `remove_trailing_cedilla` – remove trailling cedillas `ç`, a common typo for european keyboard layouts; * `rm_dir` – adds `-rf` when you trying to remove directory; * `sed_unterminated_s` – adds missing '/' to `sed`'s `s` commands; * `sl_ls` – changes `sl` to `ls`; @@ -231,7 +232,6 @@ using the matched rule and runs it. Rules enabled by default are as follows: * `vagrant_up` – starts up the vagrant instance; * `whois` – fixes `whois` command; * `workon_doesnt_exists` – fixes `virtualenvwrapper` env name os suggests to create new. -* `remove_trailing_cedilla` – remove trailling cedillas `ç`, a common typo for european keyboard layouts; Enabled by default only on specific platforms: