From 053bdd2b339916df2c37723b35c68a602443daec Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Tue, 19 Jul 2016 00:09:23 -0400 Subject: [PATCH] more fixes --- amalgamate.py | 17 ++++++++++------- xonsh/completers/__init__.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/amalgamate.py b/amalgamate.py index 16c99f463..317873797 100755 --- a/amalgamate.py +++ b/amalgamate.py @@ -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('.') diff --git a/xonsh/completers/__init__.py b/xonsh/completers/__init__.py index a090b5651..feed54f16 100644 --- a/xonsh/completers/__init__.py +++ b/xonsh/completers/__init__.py @@ -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