Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit bf4a4f42e9dff8163df574a6f7375ae22377aff7 1 parent c8874d7
Bradley M. Froehle authored

Showing 1 changed file with 4 additions and 36 deletions. Show diff stats Hide diff stats

  1. +4 36 IPython/core/completer.py
40 IPython/core/completer.py
@@ -130,19 +130,6 @@ def protect_filename(s):
130 130 return "".join([(ch in PROTECTABLES and '\\' + ch or ch)
131 131 for ch in s])
132 132
133   -
134   -def mark_dirs(matches):
135   - """Mark directories in input list by appending '/' to their names."""
136   - out = []
137   - isdir = os.path.isdir
138   - for x in matches:
139   - if isdir(x):
140   - out.append(x+'/')
141   - else:
142   - out.append(x)
143   - return out
144   -
145   -
146 133 def expand_user(path):
147 134 """Expand '~'-style usernames in strings.
148 135
@@ -191,28 +178,6 @@ def compress_user(path, tilde_expand, tilde_val):
191 178 else:
192 179 return path
193 180
194   -
195   -def single_dir_expand(matches):
196   - "Recursively expand match lists containing a single dir."
197   -
198   - if len(matches) == 1 and os.path.isdir(matches[0]):
199   - # Takes care of links to directories also. Use '/'
200   - # explicitly, even under Windows, so that name completions
201   - # don't end up escaped.
202   - d = matches[0]
203   - if d[-1] in ['/','\\']:
204   - d = d[:-1]
205   -
206   - subdirs = os.listdir(d)
207   - if subdirs:
208   - matches = [ (d + '/' + p) for p in subdirs]
209   - return single_dir_expand(matches)
210   - else:
211   - return matches
212   - else:
213   - return matches
214   -
215   -
216 181 class Bunch(object): pass
217 182
218 183 DELIMS = ' \t\n`!@#$^&*()=+[{]}\\|;:\'",<>?'
@@ -604,7 +569,10 @@ def file_matches(self, text):
604 569 protect_filename(f) for f in m0]
605 570
606 571 #io.rprint('mm', matches) # dbg
607   - return mark_dirs(matches)
  572 +
  573 + # Mark directories in input list by appending '/' to their names.
  574 + matches = [x+'/' if os.path.isdir(x) else x for x in matches]
  575 + return matches
608 576
609 577 def magic_matches(self, text):
610 578 """Match magics"""

0 comments on commit bf4a4f4

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