Skip to content
Browse files

core.completer: Clean up excessive and unused code.

- `mark_dirs` is only called from one location and it is more simply
  expressed as a one-liner using the ternary operator.
- `single_dir_expand` is not called from anywhere in IPython.
  • Loading branch information...
1 parent c8874d7 commit bf4a4f42e9dff8163df574a6f7375ae22377aff7 @bfroehle committed Dec 18, 2011
Showing with 4 additions and 36 deletions.
  1. +4 −36 IPython/core/completer.py
View
40 IPython/core/completer.py
@@ -130,19 +130,6 @@ def protect_filename(s):
return "".join([(ch in PROTECTABLES and '\\' + ch or ch)
for ch in s])
-
-def mark_dirs(matches):
- """Mark directories in input list by appending '/' to their names."""
- out = []
- isdir = os.path.isdir
- for x in matches:
- if isdir(x):
- out.append(x+'/')
- else:
- out.append(x)
- return out
-
-
def expand_user(path):
"""Expand '~'-style usernames in strings.
@@ -191,28 +178,6 @@ def compress_user(path, tilde_expand, tilde_val):
else:
return path
-
-def single_dir_expand(matches):
- "Recursively expand match lists containing a single dir."
-
- if len(matches) == 1 and os.path.isdir(matches[0]):
- # Takes care of links to directories also. Use '/'
- # explicitly, even under Windows, so that name completions
- # don't end up escaped.
- d = matches[0]
- if d[-1] in ['/','\\']:
- d = d[:-1]
-
- subdirs = os.listdir(d)
- if subdirs:
- matches = [ (d + '/' + p) for p in subdirs]
- return single_dir_expand(matches)
- else:
- return matches
- else:
- return matches
-
-
class Bunch(object): pass
DELIMS = ' \t\n`!@#$^&*()=+[{]}\\|;:\'",<>?'
@@ -604,7 +569,10 @@ def file_matches(self, text):
protect_filename(f) for f in m0]
#io.rprint('mm', matches) # dbg
- return mark_dirs(matches)
+
+ # Mark directories in input list by appending '/' to their names.
+ matches = [x+'/' if os.path.isdir(x) else x for x in matches]
+ return matches
def magic_matches(self, text):
"""Match magics"""

0 comments on commit bf4a4f4

Please sign in to comment.
Something went wrong with that request. Please try again.