mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +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:
|
if len(val) < 2:
|
||||||
continue
|
continue
|
||||||
val = sorted(val)
|
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:
|
for loc in val:
|
||||||
s += ' {} {} {}\n'.format(*loc)
|
s += ' {}:{} ({})\n'.format(*loc)
|
||||||
if len(s) > 0:
|
if len(s) > 0:
|
||||||
print(s, end='', flush=True, file=sys.stderr)
|
print(s, end='', flush=True, file=sys.stderr)
|
||||||
|
|
||||||
def entry(self, name, lineno):
|
def entry(self, name, lineno):
|
||||||
|
if name.startswith('__'):
|
||||||
|
return
|
||||||
topnode = self.topnode
|
topnode = self.topnode
|
||||||
e = (self.pkg + '.' + self.module, lineno, topnode)
|
e = (self.pkg + '.' + self.module, lineno, topnode)
|
||||||
if name in self.cache:
|
if name in self.cache:
|
||||||
if topnode in impnodes and all([topnode == x[2]
|
if topnode in self.impnodes and \
|
||||||
for x in self.cache[name]]):
|
all([topnode == x[2] for x in self.cache[name]]):
|
||||||
return
|
return
|
||||||
self.cache[name].add(e)
|
self.cache[name].add(e)
|
||||||
else:
|
else:
|
||||||
|
@ -121,6 +123,9 @@ class GlobalNames(object):
|
||||||
self.entry(name, lineno)
|
self.entry(name, lineno)
|
||||||
|
|
||||||
def _add_importfrom(self, node):
|
def _add_importfrom(self, node):
|
||||||
|
pkg, _, _ = node.module.rpartition('.')
|
||||||
|
if pkg == self.pkg:
|
||||||
|
return
|
||||||
lineno = node.lineno
|
lineno = node.lineno
|
||||||
for target in node.names:
|
for target in node.names:
|
||||||
if target.asname is None:
|
if target.asname is None:
|
||||||
|
@ -149,8 +154,6 @@ class GlobalNames(object):
|
||||||
def _add_if(self, node):
|
def _add_if(self, node):
|
||||||
for child in node.body:
|
for child in node.body:
|
||||||
self.add(child, istopnode=True)
|
self.add(child, istopnode=True)
|
||||||
for child in node.orelse:
|
|
||||||
self.add(child, istopnode=True)
|
|
||||||
|
|
||||||
def _add_try(self, node):
|
def _add_try(self, node):
|
||||||
for child in node.body:
|
for child in node.body:
|
||||||
|
@ -167,7 +170,7 @@ def make_node(name, pkg, allowed, glbnames):
|
||||||
extdeps = set()
|
extdeps = set()
|
||||||
glbnames.module = name
|
glbnames.module = name
|
||||||
for a in tree.body:
|
for a in tree.body:
|
||||||
glbnames.add(a)
|
glbnames.add(a, istopnode=True)
|
||||||
if isinstance(a, Import):
|
if isinstance(a, Import):
|
||||||
for n in a.names:
|
for n in a.names:
|
||||||
p, dot, m = n.name.rpartition('.')
|
p, dot, m = n.name.rpartition('.')
|
||||||
|
|
|
@ -1,6 +1,42 @@
|
||||||
import builtins
|
import builtins
|
||||||
|
|
||||||
# amalgamate exclude
|
# 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
|
# amalgamate end
|
||||||
|
|
||||||
builtins.__xonsh_completers__ = completers
|
builtins.__xonsh_completers__ = completers
|
||||||
|
|
Loading…
Add table
Reference in a new issue