We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
No output from scp command
While running scp in xonsh, the progress does not showed up:

https://asciinema.org/a/322p80uvb0pjyaic2e51iqmhq

I'm using version 3f45378


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `xonsh/commands_cache.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 """Module for caching command & alias names as well as for predicting whether
3 a command will be able to be run in the background.
4 
5 A background predictor is a function that accepect a single argument list
6 and returns whethere or not the process can be run in the background (returns
7 True) or must be run the foreground (returns False).
8 """
9 import os
10 import builtins
11 import argparse
12 import collections
13 import collections.abc as cabc
14 
15 from xonsh.platform import ON_WINDOWS, pathbasename
16 from xonsh.tools import executables_in
17 from xonsh.lazyasd import lazyobject
18 
19 
20 class CommandsCache(cabc.Mapping):
21     """A lazy cache representing the commands available on the file system.
22     The keys are the command names and the values a tuple of (loc, has_alias)
23     where loc is either a str pointing to the executable on the file system or
24     None (if no executable exists) and has_alias is a boolean flag for whether
25     the command has an alias.
26     """
27 
28     def __init__(self):
29         self._cmds_cache = {}
30         self._path_checksum = None
31         self._alias_checksum = None
32         self._path_mtime = -1
33         self.threadable_predictors = default_threadable_predictors()
34 
35     def __contains__(self, key):
36         _ = self.all_commands
37         return self.lazyin(key)
38 
39     def __iter__(self):
40         for cmd, (path, is_alias) in self.all_commands.items():
41             if ON_WINDOWS and path is not None:
42                 # All comand keys are stored in uppercase on Windows.
43                 # This ensures the original command name is returned.
44                 cmd = pathbasename(path)
45             yield cmd
46 
47     def __len__(self):
48         return len(self.all_commands)
49 
50     def __getitem__(self, key):
51         _ = self.all_commands
52         return self.lazyget(key)
53 
54     def is_empty(self):
55         """Returns whether the cache is populated or not."""
56         return len(self._cmds_cache) == 0
57 
58     @staticmethod
59     def get_possible_names(name):
60         """Generates the possible `PATHEXT` extension variants of a given executable
61          name on Windows as a list, conserving the ordering in `PATHEXT`.
62          Returns a list as `name` being the only item in it on other platforms."""
63         if ON_WINDOWS:
64             pathext = builtins.__xonsh_env__.get('PATHEXT')
65             name = name.upper()
66             return [
67                 name + ext
68                 for ext in ([''] + pathext)
69             ]
70         else:
71             return [name]
72 
73     @property
74     def all_commands(self):
75         paths = builtins.__xonsh_env__.get('PATH', [])
76         pathset = frozenset(x for x in paths if os.path.isdir(x))
77         # did PATH change?
78         path_hash = hash(pathset)
79         cache_valid = path_hash == self._path_checksum
80         self._path_checksum = path_hash
81         # did aliases change?
82         alss = getattr(builtins, 'aliases', set())
83         al_hash = hash(frozenset(alss))
84         cache_valid = cache_valid and al_hash == self._alias_checksum
85         self._alias_checksum = al_hash
86         # did the contents of any directory in PATH change?
87         max_mtime = 0
88         for path in pathset:
89             mtime = os.stat(path).st_mtime
90             if mtime > max_mtime:
91                 max_mtime = mtime
92         cache_valid = cache_valid and (max_mtime <= self._path_mtime)
93         self._path_mtime = max_mtime
94         if cache_valid:
95             return self._cmds_cache
96         allcmds = {}
97         for path in reversed(paths):
98             # iterate backwards so that entries at the front of PATH overwrite
99             # entries at the back.
100             for cmd in executables_in(path):
101                 key = cmd.upper() if ON_WINDOWS else cmd
102                 allcmds[key] = (os.path.join(path, cmd), cmd in alss)
103         for cmd in alss:
104             if cmd not in allcmds:
105                 key = cmd.upper() if ON_WINDOWS else cmd
106                 allcmds[key] = (cmd, True)
107         self._cmds_cache = allcmds
108         return allcmds
109 
110     def cached_name(self, name):
111         """Returns the name that would appear in the cache, if it was exists."""
112         if name is None:
113             return None
114         cached = pathbasename(name)
115         if ON_WINDOWS:
116             keys = self.get_possible_names(cached)
117             cached = next((k for k in keys if k in self._cmds_cache), None)
118         return cached
119 
120     def lazyin(self, key):
121         """Checks if the value is in the current cache without the potential to
122         update the cache. It just says whether the value is known *now*. This
123         may not reflect precisely what is on the $PATH.
124         """
125         return self.cached_name(key) in self._cmds_cache
126 
127     def lazyiter(self):
128         """Returns an iterator over the current cache contents without the
129         potential to update the cache. This may not reflect what is on the
130         $PATH.
131         """
132         return iter(self._cmds_cache)
133 
134     def lazylen(self):
135         """Returns the length of the current cache contents without the
136         potential to update the cache. This may not reflect precisely
137         what is on the $PATH.
138         """
139         return len(self._cmds_cache)
140 
141     def lazyget(self, key, default=None):
142         """A lazy value getter."""
143         return self._cmds_cache.get(self.cached_name(key), default)
144 
145     def locate_binary(self, name):
146         """Locates an executable on the file system using the cache."""
147         # make sure the cache is up to date by accessing the property
148         _ = self.all_commands
149         return self.lazy_locate_binary(name)
150 
151     def lazy_locate_binary(self, name):
152         """Locates an executable in the cache, without checking its validity."""
153         possibilities = self.get_possible_names(name)
154         if ON_WINDOWS:
155             # Windows users expect to be able to execute files in the same
156             # directory without `./`
157             local_bin = next((fn for fn in possibilities if os.path.isfile(fn)),
158                              None)
159             if local_bin:
160                 return os.path.abspath(local_bin)
161         cached = next((cmd for cmd in possibilities if cmd in self._cmds_cache),
162                       None)
163         if cached:
164             (path, is_alias) = self._cmds_cache[cached]
165             return path if not is_alias else None
166         elif os.path.isfile(name) and name != pathbasename(name):
167             return name
168 
169     def predict_threadable(self, cmd):
170         """Predicts whether a command list is able to be run on a background
171         thread, rather than the main thread.
172         """
173         name = self.cached_name(cmd[0])
174         if ON_WINDOWS:
175             # On all names (keys) are stored in upper case so instead
176             # we get the original cmd or alias name
177             path, _ = self.lazyget(name, (None, None))
178             if path is None:
179                 return True
180             else:
181                 name = pathbasename(path)
182         predictor = self.threadable_predictors[name]
183         return predictor(cmd[1:])
184 
185 #
186 # Background Predictors
187 #
188 
189 
190 def predict_true(args):
191     """Always say the process is threadable."""
192     return True
193 
194 
195 def predict_false(args):
196     """Never say the process is threadable."""
197     return False
198 
199 
200 @lazyobject
201 def SHELL_PREDICTOR_PARSER():
202     p = argparse.ArgumentParser('shell', add_help=False)
203     p.add_argument('-c', nargs='?', default=None)
204     p.add_argument('filename', nargs='?', default=None)
205     return p
206 
207 
208 def predict_shell(args):
209     """Precict the backgroundability of the normal shell interface, which
210     comes down to whether it is being run in subproc mode.
211     """
212     ns, _ = SHELL_PREDICTOR_PARSER.parse_known_args(args)
213     if ns.c is None and ns.filename is None:
214         pred = False
215     else:
216         pred = True
217     return pred
218 
219 
220 @lazyobject
221 def HELP_VER_PREDICTOR_PARSER():
222     p = argparse.ArgumentParser('cmd', add_help=False)
223     p.add_argument('-h', '--help', dest='help',
224                    action='store_true', default=None)
225     p.add_argument('-v', '-V', '--version', dest='version',
226                    action='store_true', default=None)
227     return p
228 
229 
230 def predict_help_ver(args):
231     """Precict the backgroundability of commands that have help & version
232     switches: -h, --help, -v, -V, --version. If either of these options is
233     present, the command is assumed to print to stdout normally and is therefore
234     threadable. Otherwise, the command is assumed to not be threadable.
235     This is useful for commands, like top, that normally enter alternate mode
236     but may not in certain circumstances.
237     """
238     ns, _ = HELP_VER_PREDICTOR_PARSER.parse_known_args(args)
239     pred = ns.help is not None or ns.version is not None
240     return pred
241 
242 
243 def default_threadable_predictors():
244     """Generates a new defaultdict for known threadable predictors.
245     The default is to predict true.
246     """
247     # alphabetical, for what it is worth.
248     predictors = {
249         'bash': predict_shell,
250         'csh': predict_shell,
251         'clear': predict_false,
252         'clear.exe': predict_false,
253         'cls': predict_false,
254         'cmd': predict_shell,
255         'fish': predict_shell,
256         'htop': predict_help_ver,
257         'ksh': predict_shell,
258         'less': predict_help_ver,
259         'man': predict_help_ver,
260         'more': predict_help_ver,
261         'sh': predict_shell,
262         'ssh': predict_false,
263         'startx': predict_false,
264         'sudo': predict_help_ver,
265         'tcsh': predict_shell,
266         'top': predict_help_ver,
267         'vi': predict_false,
268         'vim': predict_false,
269         'vimpager': predict_help_ver,
270         'xo': predict_help_ver,
271         'xonsh': predict_shell,
272         'zsh': predict_shell,
273     }
274     return collections.defaultdict(lambda: predict_true, predictors)
275
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/xonsh/commands_cache.py b/xonsh/commands_cache.py
--- a/xonsh/commands_cache.py
+++ b/xonsh/commands_cache.py
@@ -258,6 +258,7 @@
         'less': predict_help_ver,
         'man': predict_help_ver,
         'more': predict_help_ver,
+        'scp': predict_false,
         'sh': predict_shell,
         'ssh': predict_false,
         'startx': predict_false,

{"golden_diff": "diff --git a/xonsh/commands_cache.py b/xonsh/commands_cache.py\n--- a/xonsh/commands_cache.py\n+++ b/xonsh/commands_cache.py\n@@ -258,6 +258,7 @@\n         'less': predict_help_ver,\n         'man': predict_help_ver,\n         'more': predict_help_ver,\n+        'scp': predict_false,\n         'sh': predict_shell,\n         'ssh': predict_false,\n         'startx': predict_false,\n", "issue": "No output from scp command\nWhile running scp in xonsh, the progress does not showed up:\n\nhttps://asciinema.org/a/322p80uvb0pjyaic2e51iqmhq\n\nI'm using version 3f45378\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"Module for caching command & alias names as well as for predicting whether\na command will be able to be run in the background.\n\nA background predictor is a function that accepect a single argument list\nand returns whethere or not the process can be run in the background (returns\nTrue) or must be run the foreground (returns False).\n\"\"\"\nimport os\nimport builtins\nimport argparse\nimport collections\nimport collections.abc as cabc\n\nfrom xonsh.platform import ON_WINDOWS, pathbasename\nfrom xonsh.tools import executables_in\nfrom xonsh.lazyasd import lazyobject\n\n\nclass CommandsCache(cabc.Mapping):\n    \"\"\"A lazy cache representing the commands available on the file system.\n    The keys are the command names and the values a tuple of (loc, has_alias)\n    where loc is either a str pointing to the executable on the file system or\n    None (if no executable exists) and has_alias is a boolean flag for whether\n    the command has an alias.\n    \"\"\"\n\n    def __init__(self):\n        self._cmds_cache = {}\n        self._path_checksum = None\n        self._alias_checksum = None\n        self._path_mtime = -1\n        self.threadable_predictors = default_threadable_predictors()\n\n    def __contains__(self, key):\n        _ = self.all_commands\n        return self.lazyin(key)\n\n    def __iter__(self):\n        for cmd, (path, is_alias) in self.all_commands.items():\n            if ON_WINDOWS and path is not None:\n                # All comand keys are stored in uppercase on Windows.\n                # This ensures the original command name is returned.\n                cmd = pathbasename(path)\n            yield cmd\n\n    def __len__(self):\n        return len(self.all_commands)\n\n    def __getitem__(self, key):\n        _ = self.all_commands\n        return self.lazyget(key)\n\n    def is_empty(self):\n        \"\"\"Returns whether the cache is populated or not.\"\"\"\n        return len(self._cmds_cache) == 0\n\n    @staticmethod\n    def get_possible_names(name):\n        \"\"\"Generates the possible `PATHEXT` extension variants of a given executable\n         name on Windows as a list, conserving the ordering in `PATHEXT`.\n         Returns a list as `name` being the only item in it on other platforms.\"\"\"\n        if ON_WINDOWS:\n            pathext = builtins.__xonsh_env__.get('PATHEXT')\n            name = name.upper()\n            return [\n                name + ext\n                for ext in ([''] + pathext)\n            ]\n        else:\n            return [name]\n\n    @property\n    def all_commands(self):\n        paths = builtins.__xonsh_env__.get('PATH', [])\n        pathset = frozenset(x for x in paths if os.path.isdir(x))\n        # did PATH change?\n        path_hash = hash(pathset)\n        cache_valid = path_hash == self._path_checksum\n        self._path_checksum = path_hash\n        # did aliases change?\n        alss = getattr(builtins, 'aliases', set())\n        al_hash = hash(frozenset(alss))\n        cache_valid = cache_valid and al_hash == self._alias_checksum\n        self._alias_checksum = al_hash\n        # did the contents of any directory in PATH change?\n        max_mtime = 0\n        for path in pathset:\n            mtime = os.stat(path).st_mtime\n            if mtime > max_mtime:\n                max_mtime = mtime\n        cache_valid = cache_valid and (max_mtime <= self._path_mtime)\n        self._path_mtime = max_mtime\n        if cache_valid:\n            return self._cmds_cache\n        allcmds = {}\n        for path in reversed(paths):\n            # iterate backwards so that entries at the front of PATH overwrite\n            # entries at the back.\n            for cmd in executables_in(path):\n                key = cmd.upper() if ON_WINDOWS else cmd\n                allcmds[key] = (os.path.join(path, cmd), cmd in alss)\n        for cmd in alss:\n            if cmd not in allcmds:\n                key = cmd.upper() if ON_WINDOWS else cmd\n                allcmds[key] = (cmd, True)\n        self._cmds_cache = allcmds\n        return allcmds\n\n    def cached_name(self, name):\n        \"\"\"Returns the name that would appear in the cache, if it was exists.\"\"\"\n        if name is None:\n            return None\n        cached = pathbasename(name)\n        if ON_WINDOWS:\n            keys = self.get_possible_names(cached)\n            cached = next((k for k in keys if k in self._cmds_cache), None)\n        return cached\n\n    def lazyin(self, key):\n        \"\"\"Checks if the value is in the current cache without the potential to\n        update the cache. It just says whether the value is known *now*. This\n        may not reflect precisely what is on the $PATH.\n        \"\"\"\n        return self.cached_name(key) in self._cmds_cache\n\n    def lazyiter(self):\n        \"\"\"Returns an iterator over the current cache contents without the\n        potential to update the cache. This may not reflect what is on the\n        $PATH.\n        \"\"\"\n        return iter(self._cmds_cache)\n\n    def lazylen(self):\n        \"\"\"Returns the length of the current cache contents without the\n        potential to update the cache. This may not reflect precisely\n        what is on the $PATH.\n        \"\"\"\n        return len(self._cmds_cache)\n\n    def lazyget(self, key, default=None):\n        \"\"\"A lazy value getter.\"\"\"\n        return self._cmds_cache.get(self.cached_name(key), default)\n\n    def locate_binary(self, name):\n        \"\"\"Locates an executable on the file system using the cache.\"\"\"\n        # make sure the cache is up to date by accessing the property\n        _ = self.all_commands\n        return self.lazy_locate_binary(name)\n\n    def lazy_locate_binary(self, name):\n        \"\"\"Locates an executable in the cache, without checking its validity.\"\"\"\n        possibilities = self.get_possible_names(name)\n        if ON_WINDOWS:\n            # Windows users expect to be able to execute files in the same\n            # directory without `./`\n            local_bin = next((fn for fn in possibilities if os.path.isfile(fn)),\n                             None)\n            if local_bin:\n                return os.path.abspath(local_bin)\n        cached = next((cmd for cmd in possibilities if cmd in self._cmds_cache),\n                      None)\n        if cached:\n            (path, is_alias) = self._cmds_cache[cached]\n            return path if not is_alias else None\n        elif os.path.isfile(name) and name != pathbasename(name):\n            return name\n\n    def predict_threadable(self, cmd):\n        \"\"\"Predicts whether a command list is able to be run on a background\n        thread, rather than the main thread.\n        \"\"\"\n        name = self.cached_name(cmd[0])\n        if ON_WINDOWS:\n            # On all names (keys) are stored in upper case so instead\n            # we get the original cmd or alias name\n            path, _ = self.lazyget(name, (None, None))\n            if path is None:\n                return True\n            else:\n                name = pathbasename(path)\n        predictor = self.threadable_predictors[name]\n        return predictor(cmd[1:])\n\n#\n# Background Predictors\n#\n\n\ndef predict_true(args):\n    \"\"\"Always say the process is threadable.\"\"\"\n    return True\n\n\ndef predict_false(args):\n    \"\"\"Never say the process is threadable.\"\"\"\n    return False\n\n\n@lazyobject\ndef SHELL_PREDICTOR_PARSER():\n    p = argparse.ArgumentParser('shell', add_help=False)\n    p.add_argument('-c', nargs='?', default=None)\n    p.add_argument('filename', nargs='?', default=None)\n    return p\n\n\ndef predict_shell(args):\n    \"\"\"Precict the backgroundability of the normal shell interface, which\n    comes down to whether it is being run in subproc mode.\n    \"\"\"\n    ns, _ = SHELL_PREDICTOR_PARSER.parse_known_args(args)\n    if ns.c is None and ns.filename is None:\n        pred = False\n    else:\n        pred = True\n    return pred\n\n\n@lazyobject\ndef HELP_VER_PREDICTOR_PARSER():\n    p = argparse.ArgumentParser('cmd', add_help=False)\n    p.add_argument('-h', '--help', dest='help',\n                   action='store_true', default=None)\n    p.add_argument('-v', '-V', '--version', dest='version',\n                   action='store_true', default=None)\n    return p\n\n\ndef predict_help_ver(args):\n    \"\"\"Precict the backgroundability of commands that have help & version\n    switches: -h, --help, -v, -V, --version. If either of these options is\n    present, the command is assumed to print to stdout normally and is therefore\n    threadable. Otherwise, the command is assumed to not be threadable.\n    This is useful for commands, like top, that normally enter alternate mode\n    but may not in certain circumstances.\n    \"\"\"\n    ns, _ = HELP_VER_PREDICTOR_PARSER.parse_known_args(args)\n    pred = ns.help is not None or ns.version is not None\n    return pred\n\n\ndef default_threadable_predictors():\n    \"\"\"Generates a new defaultdict for known threadable predictors.\n    The default is to predict true.\n    \"\"\"\n    # alphabetical, for what it is worth.\n    predictors = {\n        'bash': predict_shell,\n        'csh': predict_shell,\n        'clear': predict_false,\n        'clear.exe': predict_false,\n        'cls': predict_false,\n        'cmd': predict_shell,\n        'fish': predict_shell,\n        'htop': predict_help_ver,\n        'ksh': predict_shell,\n        'less': predict_help_ver,\n        'man': predict_help_ver,\n        'more': predict_help_ver,\n        'sh': predict_shell,\n        'ssh': predict_false,\n        'startx': predict_false,\n        'sudo': predict_help_ver,\n        'tcsh': predict_shell,\n        'top': predict_help_ver,\n        'vi': predict_false,\n        'vim': predict_false,\n        'vimpager': predict_help_ver,\n        'xo': predict_help_ver,\n        'xonsh': predict_shell,\n        'zsh': predict_shell,\n    }\n    return collections.defaultdict(lambda: predict_true, predictors)\n", "path": "xonsh/commands_cache.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"Module for caching command & alias names as well as for predicting whether\na command will be able to be run in the background.\n\nA background predictor is a function that accepect a single argument list\nand returns whethere or not the process can be run in the background (returns\nTrue) or must be run the foreground (returns False).\n\"\"\"\nimport os\nimport builtins\nimport argparse\nimport collections\nimport collections.abc as cabc\n\nfrom xonsh.platform import ON_WINDOWS, pathbasename\nfrom xonsh.tools import executables_in\nfrom xonsh.lazyasd import lazyobject\n\n\nclass CommandsCache(cabc.Mapping):\n    \"\"\"A lazy cache representing the commands available on the file system.\n    The keys are the command names and the values a tuple of (loc, has_alias)\n    where loc is either a str pointing to the executable on the file system or\n    None (if no executable exists) and has_alias is a boolean flag for whether\n    the command has an alias.\n    \"\"\"\n\n    def __init__(self):\n        self._cmds_cache = {}\n        self._path_checksum = None\n        self._alias_checksum = None\n        self._path_mtime = -1\n        self.threadable_predictors = default_threadable_predictors()\n\n    def __contains__(self, key):\n        _ = self.all_commands\n        return self.lazyin(key)\n\n    def __iter__(self):\n        for cmd, (path, is_alias) in self.all_commands.items():\n            if ON_WINDOWS and path is not None:\n                # All comand keys are stored in uppercase on Windows.\n                # This ensures the original command name is returned.\n                cmd = pathbasename(path)\n            yield cmd\n\n    def __len__(self):\n        return len(self.all_commands)\n\n    def __getitem__(self, key):\n        _ = self.all_commands\n        return self.lazyget(key)\n\n    def is_empty(self):\n        \"\"\"Returns whether the cache is populated or not.\"\"\"\n        return len(self._cmds_cache) == 0\n\n    @staticmethod\n    def get_possible_names(name):\n        \"\"\"Generates the possible `PATHEXT` extension variants of a given executable\n         name on Windows as a list, conserving the ordering in `PATHEXT`.\n         Returns a list as `name` being the only item in it on other platforms.\"\"\"\n        if ON_WINDOWS:\n            pathext = builtins.__xonsh_env__.get('PATHEXT')\n            name = name.upper()\n            return [\n                name + ext\n                for ext in ([''] + pathext)\n            ]\n        else:\n            return [name]\n\n    @property\n    def all_commands(self):\n        paths = builtins.__xonsh_env__.get('PATH', [])\n        pathset = frozenset(x for x in paths if os.path.isdir(x))\n        # did PATH change?\n        path_hash = hash(pathset)\n        cache_valid = path_hash == self._path_checksum\n        self._path_checksum = path_hash\n        # did aliases change?\n        alss = getattr(builtins, 'aliases', set())\n        al_hash = hash(frozenset(alss))\n        cache_valid = cache_valid and al_hash == self._alias_checksum\n        self._alias_checksum = al_hash\n        # did the contents of any directory in PATH change?\n        max_mtime = 0\n        for path in pathset:\n            mtime = os.stat(path).st_mtime\n            if mtime > max_mtime:\n                max_mtime = mtime\n        cache_valid = cache_valid and (max_mtime <= self._path_mtime)\n        self._path_mtime = max_mtime\n        if cache_valid:\n            return self._cmds_cache\n        allcmds = {}\n        for path in reversed(paths):\n            # iterate backwards so that entries at the front of PATH overwrite\n            # entries at the back.\n            for cmd in executables_in(path):\n                key = cmd.upper() if ON_WINDOWS else cmd\n                allcmds[key] = (os.path.join(path, cmd), cmd in alss)\n        for cmd in alss:\n            if cmd not in allcmds:\n                key = cmd.upper() if ON_WINDOWS else cmd\n                allcmds[key] = (cmd, True)\n        self._cmds_cache = allcmds\n        return allcmds\n\n    def cached_name(self, name):\n        \"\"\"Returns the name that would appear in the cache, if it was exists.\"\"\"\n        if name is None:\n            return None\n        cached = pathbasename(name)\n        if ON_WINDOWS:\n            keys = self.get_possible_names(cached)\n            cached = next((k for k in keys if k in self._cmds_cache), None)\n        return cached\n\n    def lazyin(self, key):\n        \"\"\"Checks if the value is in the current cache without the potential to\n        update the cache. It just says whether the value is known *now*. This\n        may not reflect precisely what is on the $PATH.\n        \"\"\"\n        return self.cached_name(key) in self._cmds_cache\n\n    def lazyiter(self):\n        \"\"\"Returns an iterator over the current cache contents without the\n        potential to update the cache. This may not reflect what is on the\n        $PATH.\n        \"\"\"\n        return iter(self._cmds_cache)\n\n    def lazylen(self):\n        \"\"\"Returns the length of the current cache contents without the\n        potential to update the cache. This may not reflect precisely\n        what is on the $PATH.\n        \"\"\"\n        return len(self._cmds_cache)\n\n    def lazyget(self, key, default=None):\n        \"\"\"A lazy value getter.\"\"\"\n        return self._cmds_cache.get(self.cached_name(key), default)\n\n    def locate_binary(self, name):\n        \"\"\"Locates an executable on the file system using the cache.\"\"\"\n        # make sure the cache is up to date by accessing the property\n        _ = self.all_commands\n        return self.lazy_locate_binary(name)\n\n    def lazy_locate_binary(self, name):\n        \"\"\"Locates an executable in the cache, without checking its validity.\"\"\"\n        possibilities = self.get_possible_names(name)\n        if ON_WINDOWS:\n            # Windows users expect to be able to execute files in the same\n            # directory without `./`\n            local_bin = next((fn for fn in possibilities if os.path.isfile(fn)),\n                             None)\n            if local_bin:\n                return os.path.abspath(local_bin)\n        cached = next((cmd for cmd in possibilities if cmd in self._cmds_cache),\n                      None)\n        if cached:\n            (path, is_alias) = self._cmds_cache[cached]\n            return path if not is_alias else None\n        elif os.path.isfile(name) and name != pathbasename(name):\n            return name\n\n    def predict_threadable(self, cmd):\n        \"\"\"Predicts whether a command list is able to be run on a background\n        thread, rather than the main thread.\n        \"\"\"\n        name = self.cached_name(cmd[0])\n        if ON_WINDOWS:\n            # On all names (keys) are stored in upper case so instead\n            # we get the original cmd or alias name\n            path, _ = self.lazyget(name, (None, None))\n            if path is None:\n                return True\n            else:\n                name = pathbasename(path)\n        predictor = self.threadable_predictors[name]\n        return predictor(cmd[1:])\n\n#\n# Background Predictors\n#\n\n\ndef predict_true(args):\n    \"\"\"Always say the process is threadable.\"\"\"\n    return True\n\n\ndef predict_false(args):\n    \"\"\"Never say the process is threadable.\"\"\"\n    return False\n\n\n@lazyobject\ndef SHELL_PREDICTOR_PARSER():\n    p = argparse.ArgumentParser('shell', add_help=False)\n    p.add_argument('-c', nargs='?', default=None)\n    p.add_argument('filename', nargs='?', default=None)\n    return p\n\n\ndef predict_shell(args):\n    \"\"\"Precict the backgroundability of the normal shell interface, which\n    comes down to whether it is being run in subproc mode.\n    \"\"\"\n    ns, _ = SHELL_PREDICTOR_PARSER.parse_known_args(args)\n    if ns.c is None and ns.filename is None:\n        pred = False\n    else:\n        pred = True\n    return pred\n\n\n@lazyobject\ndef HELP_VER_PREDICTOR_PARSER():\n    p = argparse.ArgumentParser('cmd', add_help=False)\n    p.add_argument('-h', '--help', dest='help',\n                   action='store_true', default=None)\n    p.add_argument('-v', '-V', '--version', dest='version',\n                   action='store_true', default=None)\n    return p\n\n\ndef predict_help_ver(args):\n    \"\"\"Precict the backgroundability of commands that have help & version\n    switches: -h, --help, -v, -V, --version. If either of these options is\n    present, the command is assumed to print to stdout normally and is therefore\n    threadable. Otherwise, the command is assumed to not be threadable.\n    This is useful for commands, like top, that normally enter alternate mode\n    but may not in certain circumstances.\n    \"\"\"\n    ns, _ = HELP_VER_PREDICTOR_PARSER.parse_known_args(args)\n    pred = ns.help is not None or ns.version is not None\n    return pred\n\n\ndef default_threadable_predictors():\n    \"\"\"Generates a new defaultdict for known threadable predictors.\n    The default is to predict true.\n    \"\"\"\n    # alphabetical, for what it is worth.\n    predictors = {\n        'bash': predict_shell,\n        'csh': predict_shell,\n        'clear': predict_false,\n        'clear.exe': predict_false,\n        'cls': predict_false,\n        'cmd': predict_shell,\n        'fish': predict_shell,\n        'htop': predict_help_ver,\n        'ksh': predict_shell,\n        'less': predict_help_ver,\n        'man': predict_help_ver,\n        'more': predict_help_ver,\n        'scp': predict_false,\n        'sh': predict_shell,\n        'ssh': predict_false,\n        'startx': predict_false,\n        'sudo': predict_help_ver,\n        'tcsh': predict_shell,\n        'top': predict_help_ver,\n        'vi': predict_false,\n        'vim': predict_false,\n        'vimpager': predict_help_ver,\n        'xo': predict_help_ver,\n        'xonsh': predict_shell,\n        'zsh': predict_shell,\n    }\n    return collections.defaultdict(lambda: predict_true, predictors)\n", "path": "xonsh/commands_cache.py"}]}