Skip to content

Commit 72ee717

Browse files
committed
Turn safe_glob into a function
1 parent f8b5962 commit 72ee717

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

bpython/autocomplete.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,14 @@ def format(self, word: str) -> str:
343343
return after_last_dot(word)
344344

345345

346+
def _safe_glob(pathname: str) -> Iterator[str]:
347+
return glob.iglob(glob.escape(pathname) + "*")
348+
349+
346350
class FilenameCompletion(BaseCompletionType):
347351
def __init__(self, mode: AutocompleteModes = AutocompleteModes.SIMPLE):
348352
super().__init__(False, mode)
349353

350-
def safe_glob(self, pathname: str) -> Iterator[str]:
351-
return glob.iglob(glob.escape(pathname) + "*")
352-
353354
def matches(
354355
self, cursor_offset: int, line: str, **kwargs: Any
355356
) -> Optional[Set]:
@@ -359,7 +360,7 @@ def matches(
359360
matches = set()
360361
username = cs.word.split(os.path.sep, 1)[0]
361362
user_dir = os.path.expanduser(username)
362-
for filename in self.safe_glob(os.path.expanduser(cs.word)):
363+
for filename in _safe_glob(os.path.expanduser(cs.word)):
363364
if os.path.isdir(filename):
364365
filename += os.path.sep
365366
if cs.word.startswith("~"):

0 commit comments

Comments
 (0)