mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
more fixes
This commit is contained in:
parent
81b0a09939
commit
053bdd2b33
2 changed files with 46 additions and 7 deletions
|
@ -68,18 +68,20 @@ class GlobalNames(object):
|
|||
if len(val) < 2:
|
||||
continue
|
||||
val = sorted(val)
|
||||
s += key + ' defined in multiple locations:\n'
|
||||
s += 'WARNING: {0!r} defined in multiple locations:\n'.format(key)
|
||||
for loc in val:
|
||||
s += ' {} {} {}\n'.format(*loc)
|
||||
s += ' {}:{} ({})\n'.format(*loc)
|
||||
if len(s) > 0:
|
||||
print(s, end='', flush=True, file=sys.stderr)
|
||||
|
||||
def entry(self, name, lineno):
|
||||
if name.startswith('__'):
|
||||
return
|
||||
topnode = self.topnode
|
||||
e = (self.pkg + '.' + self.module, lineno, topnode)
|
||||
if name in self.cache:
|
||||
if topnode in impnodes and all([topnode == x[2]
|
||||
for x in self.cache[name]]):
|
||||
if topnode in self.impnodes and \
|
||||
all([topnode == x[2] for x in self.cache[name]]):
|
||||
return
|
||||
self.cache[name].add(e)
|
||||
else:
|
||||
|
@ -121,6 +123,9 @@ class GlobalNames(object):
|
|||
self.entry(name, lineno)
|
||||
|
||||
def _add_importfrom(self, node):
|
||||
pkg, _, _ = node.module.rpartition('.')
|
||||
if pkg == self.pkg:
|
||||
return
|
||||
lineno = node.lineno
|
||||
for target in node.names:
|
||||
if target.asname is None:
|
||||
|
@ -149,8 +154,6 @@ class GlobalNames(object):
|
|||
def _add_if(self, node):
|
||||
for child in node.body:
|
||||
self.add(child, istopnode=True)
|
||||
for child in node.orelse:
|
||||
self.add(child, istopnode=True)
|
||||
|
||||
def _add_try(self, node):
|
||||
for child in node.body:
|
||||
|
@ -167,7 +170,7 @@ def make_node(name, pkg, allowed, glbnames):
|
|||
extdeps = set()
|
||||
glbnames.module = name
|
||||
for a in tree.body:
|
||||
glbnames.add(a)
|
||||
glbnames.add(a, istopnode=True)
|
||||
if isinstance(a, Import):
|
||||
for n in a.names:
|
||||
p, dot, m = n.name.rpartition('.')
|
||||
|
|
|
@ -1,6 +1,42 @@
|
|||
import builtins
|
||||
|
||||
# amalgamate exclude
|
||||
import os as _os
|
||||
if _os.getenv('XONSH_DEBUG', ''):
|
||||
pass
|
||||
else:
|
||||
import sys as _sys
|
||||
try:
|
||||
from xonsh.completers import __amalgam__
|
||||
bash = __amalgam__
|
||||
_sys.modules['xonsh.completers.bash'] = __amalgam__
|
||||
completer = __amalgam__
|
||||
_sys.modules['xonsh.completers.completer'] = __amalgam__
|
||||
pip = __amalgam__
|
||||
_sys.modules['xonsh.completers.pip'] = __amalgam__
|
||||
tools = __amalgam__
|
||||
_sys.modules['xonsh.completers.tools'] = __amalgam__
|
||||
_aliases = __amalgam__
|
||||
_sys.modules['xonsh.completers._aliases'] = __amalgam__
|
||||
commands = __amalgam__
|
||||
_sys.modules['xonsh.completers.commands'] = __amalgam__
|
||||
man = __amalgam__
|
||||
_sys.modules['xonsh.completers.man'] = __amalgam__
|
||||
path = __amalgam__
|
||||
_sys.modules['xonsh.completers.path'] = __amalgam__
|
||||
python = __amalgam__
|
||||
_sys.modules['xonsh.completers.python'] = __amalgam__
|
||||
base = __amalgam__
|
||||
_sys.modules['xonsh.completers.base'] = __amalgam__
|
||||
dirs = __amalgam__
|
||||
_sys.modules['xonsh.completers.dirs'] = __amalgam__
|
||||
init = __amalgam__
|
||||
_sys.modules['xonsh.completers.init'] = __amalgam__
|
||||
del __amalgam__
|
||||
except ImportError:
|
||||
pass
|
||||
del _sys
|
||||
del _os
|
||||
# amalgamate end
|
||||
|
||||
builtins.__xonsh_completers__ = completers
|
||||
|
|
Loading…
Add table
Reference in a new issue