summaryrefslogtreecommitdiff
path: root/src/common.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2012-02-15 20:10:00 +0100
committerFlorent Le Coz <louiz@louiz.org>2012-02-15 20:10:00 +0100
commit695a7ebebaf6a277420dcb42cd96d92d77df0379 (patch)
tree8c9da1e5bf988356ad110f42113949aab94a5866 /src/common.py
parent0606c2b351ac87f110e1240d2f4ba1b94b275930 (diff)
parentb89cd8fd8322bf8aa23130398a0a70defcba708d (diff)
downloadpoezio-695a7ebebaf6a277420dcb42cd96d92d77df0379.tar.gz
poezio-695a7ebebaf6a277420dcb42cd96d92d77df0379.tar.bz2
poezio-695a7ebebaf6a277420dcb42cd96d92d77df0379.tar.xz
poezio-695a7ebebaf6a277420dcb42cd96d92d77df0379.zip
Merge branch 'master' of https://git.louiz.org/poezio
Diffstat (limited to 'src/common.py')
-rw-r--r--src/common.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/common.py b/src/common.py
index 2da7835b..26b5dd0f 100644
--- a/src/common.py
+++ b/src/common.py
@@ -235,13 +235,16 @@ def parse_secs_to_str(duration=0):
result += '%ss' % secs if secs else ''
return result
-def parse_command_args_to_alias(args, strto):
+def parse_command_args_to_alias(arg, strto):
"""
Parse command parameters.
Numbers can be from 0 to 9.
- >>> parse_command_args_to_alias(['sdf', 'koin'], '%0 %1')
- "sdf koin"
+ >>> parse_command_args_to_alias('sdf koin', '%1 %0')
+ "koin sdf"
"""
+ if '%' not in strto:
+ return strto + arg
+ args = shell_split(arg)
l = len(args)
dest = ''
var_num = False
@@ -250,7 +253,7 @@ def parse_command_args_to_alias(args, strto):
if not var_num:
dest += i
elif i in string.digits:
- if int(i) < l:
+ if 0 <= int(i) < l:
dest += args[int(i)]
var_num = False
elif i == '%':