OXIESEC PANEL
- Current Dir:
/
/
opt
/
gsutil
/
third_party
/
argcomplete
/
argcomplete
Server IP: 2a02:4780:11:1594:0:ef5:22d7:a
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
12/11/2024 09:39:44 AM
rwxr-xr-x
📄
__init__.py
693 bytes
10/07/2024 04:00:12 AM
rw-r--r--
📁
__pycache__
-
02/11/2025 08:19:49 AM
rwxr-xr-x
📄
_check_console_script.py
2.36 KB
10/07/2024 04:00:12 AM
rw-r--r--
📄
_check_module.py
2.55 KB
10/07/2024 04:00:12 AM
rw-r--r--
📁
bash_completion.d
-
10/07/2024 04:00:12 AM
rwxr-xr-x
📄
completers.py
3.89 KB
10/07/2024 04:00:12 AM
rw-r--r--
📄
exceptions.py
112 bytes
10/07/2024 04:00:12 AM
rw-r--r--
📄
finders.py
27.59 KB
10/07/2024 04:00:12 AM
rw-r--r--
📄
io.py
866 bytes
10/07/2024 04:00:12 AM
rw-r--r--
📄
lexers.py
2.08 KB
10/07/2024 04:00:12 AM
rw-r--r--
📁
packages
-
02/11/2025 08:19:49 AM
rwxr-xr-x
📄
py.typed
0 bytes
10/07/2024 04:00:12 AM
rw-r--r--
📁
scripts
-
10/07/2024 04:00:12 AM
rwxr-xr-x
📄
shell_integration.py
7.6 KB
10/07/2024 04:00:12 AM
rw-r--r--
Editing: completers.py
Close
# Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors. # Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info. import argparse import os import subprocess def _call(*args, **kwargs): # TODO: replace "universal_newlines" with "text" once 3.6 support is dropped kwargs["universal_newlines"] = True try: return subprocess.check_output(*args, **kwargs).splitlines() except subprocess.CalledProcessError: return [] class BaseCompleter: """ This is the base class that all argcomplete completers should subclass. """ def __call__( self, *, prefix: str, action: argparse.Action, parser: argparse.ArgumentParser, parsed_args: argparse.Namespace ) -> None: raise NotImplementedError("This method should be implemented by a subclass.") class ChoicesCompleter(BaseCompleter): def __init__(self, choices): self.choices = choices def _convert(self, choice): if not isinstance(choice, str): choice = str(choice) return choice def __call__(self, **kwargs): return (self._convert(c) for c in self.choices) EnvironCompleter = ChoicesCompleter(os.environ) class FilesCompleter(BaseCompleter): """ File completer class, optionally takes a list of allowed extensions """ def __init__(self, allowednames=(), directories=True): # Fix if someone passes in a string instead of a list if isinstance(allowednames, (str, bytes)): allowednames = [allowednames] self.allowednames = [x.lstrip("*").lstrip(".") for x in allowednames] self.directories = directories def __call__(self, prefix, **kwargs): completion = [] if self.allowednames: if self.directories: files = _call(["bash", "-c", "compgen -A directory -- '{p}'".format(p=prefix)]) completion += [f + "/" for f in files] for x in self.allowednames: completion += _call(["bash", "-c", "compgen -A file -X '!*.{0}' -- '{p}'".format(x, p=prefix)]) else: completion += _call(["bash", "-c", "compgen -A file -- '{p}'".format(p=prefix)]) anticomp = _call(["bash", "-c", "compgen -A directory -- '{p}'".format(p=prefix)]) completion = list(set(completion) - set(anticomp)) if self.directories: completion += [f + "/" for f in anticomp] return completion class _FilteredFilesCompleter(BaseCompleter): def __init__(self, predicate): """ Create the completer A predicate accepts as its only argument a candidate path and either accepts it or rejects it. """ assert predicate, "Expected a callable predicate" self.predicate = predicate def __call__(self, prefix, **kwargs): """ Provide completions on prefix """ target_dir = os.path.dirname(prefix) try: names = os.listdir(target_dir or ".") except Exception: return # empty iterator incomplete_part = os.path.basename(prefix) # Iterate on target_dir entries and filter on given predicate for name in names: if not name.startswith(incomplete_part): continue candidate = os.path.join(target_dir, name) if not self.predicate(candidate): continue yield candidate + "/" if os.path.isdir(candidate) else candidate class DirectoriesCompleter(_FilteredFilesCompleter): def __init__(self): _FilteredFilesCompleter.__init__(self, predicate=os.path.isdir) class SuppressCompleter(BaseCompleter): """ A completer used to suppress the completion of specific arguments """ def __init__(self): pass def suppress(self): """ Decide if the completion should be suppressed """ return True