diff --git a/cottoncandy/browser.py b/cottoncandy/browser.py index 8774fac..a50c6b2 100644 --- a/cottoncandy/browser.py +++ b/cottoncandy/browser.py @@ -3,6 +3,7 @@ import os from utils import (clean_object_name, + has_start_digit, has_magic, has_real_magic, has_trivial_magic, @@ -21,6 +22,7 @@ + # globals ############################## @@ -127,8 +129,12 @@ def __init__(self, path, interface): for sdir in subdirs: if sdir: # modify name for tab-completion purposes - fl, ext = os.path.splitext(sdir) - kk = fl+'_'+ext[1:].upper() if ext else sdir + sdir_copy = sdir[:] + # clean numbers + sdir_copy = 'NUM_%s'%sdir_copy if has_start_digit(sdir) else sdir_copy + # clean extension + fl, ext = os.path.splitext(sdir_copy) + kk = fl+'_DOT_'+ext[1:] if ext else sdir_copy self._subdirs[kk] = sdir def _ls(self): diff --git a/cottoncandy/utils.py b/cottoncandy/utils.py index 873346c..ffcbc53 100644 --- a/cottoncandy/utils.py +++ b/cottoncandy/utils.py @@ -140,6 +140,10 @@ def remove_root(string_): # path handling ############################## +check_digits = re.compile('[0-9]') + +def has_start_digit(s): + return check_digits.match(s) is not None def has_magic(s): '''Check string to see if it has any glob magic