Skip to content

Commit

Permalink
WIP: clean browsing object names (issue #7)
Browse files Browse the repository at this point in the history
  • Loading branch information
anwarnunez committed Jun 11, 2016
1 parent 15a528c commit e5cf759
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cottoncandy/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

from utils import (clean_object_name,
has_start_digit,
has_magic,
has_real_magic,
has_trivial_magic,
Expand All @@ -21,6 +22,7 @@




# globals
##############################

Expand Down Expand Up @@ -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):
Expand Down
4 changes: 4 additions & 0 deletions cottoncandy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e5cf759

Please sign in to comment.