[Kimchi-devel] [PATCH v3 1/2] bugfix: Fix regexp in "kimchi.utils.get_next_clone_name"
Crístian Viana
vianac at linux.vnet.ibm.com
Thu Dec 11 18:07:01 UTC 2014
The regular expression used in the function
"kimchi.utils.get_next_clone_name" has an extra '-' which
isn't needed.
The following commands, executed from an interactive Python shell,
demonstrate the bug:
>>> from kimchi.utils import get_next_clone_name
>>> get_next_clone_name(['foo'], 'index', '.html')
u'index-clone-1.html'
>>> get_next_clone_name(['foo', 'index-clone-1.html'], 'index', '.html')
u'index-clone-1.html'
Even though the name 'index-clone-1.html' is provided as an existing
name, the function still returns a duplicate value.
Fix the regular expression by removing an unnecessary character.
The following commands demonstrate the bug fix:
>>> from kimchi.utils import get_next_clone_name
>>> get_next_clone_name(['foo'], 'index', '.html')
u'index-clone-1.html'
>>> get_next_clone_name(['foo', 'index-clone-1.html'], 'index', '.html')
u'index-clone-2.html'
>>> get_next_clone_name(['foo', 'index-clone-1.html', 'index-clone-2.html'], 'index', '.html')
u'index-clone-3.html'
Signed-off-by: Crístian Viana <vianac at linux.vnet.ibm.com>
---
src/kimchi/utils.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py
index 989e370..3af701c 100644
--- a/src/kimchi/utils.py
+++ b/src/kimchi/utils.py
@@ -335,7 +335,7 @@ def get_next_clone_name(all_names, basename, name_suffix=''):
re_expr = u'%s-clone-(?P<%s>\d+)' % (basename, re_group_num)
if name_suffix != '':
- re_expr = u'%s-%s' % (re_expr, name_suffix)
+ re_expr = u'%s%s' % (re_expr, name_suffix)
max_num = 0
re_compiled = re.compile(re_expr)
--
1.9.3
More information about the Kimchi-devel
mailing list