summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Thénault <sylvain.thenault@logilab.fr>2010-10-11 19:47:37 +0200
committerSylvain Thénault <sylvain.thenault@logilab.fr>2010-10-11 19:47:37 +0200
commit3a889f7b5f664cb7a53ebf09ce3fdd4ee05fa087 (patch)
tree9ba184ce781374ccf7077ac5a559d2a190fbdae3
parent2b5ec36d23de27f5dee5ef090150a74bbd865c5d (diff)
downloadastroid-git-3a889f7b5f664cb7a53ebf09ce3fdd4ee05fa087.tar.gz
support source argument to force consideration of file as a python source file
--HG-- branch : stable
-rw-r--r--manager.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/manager.py b/manager.py
index 746dd73a..db036f2c 100644
--- a/manager.py
+++ b/manager.py
@@ -123,15 +123,18 @@ class ASTNGManager(OptionsProviderMixIn):
directory = abspath(directory)
return Package(directory, modname, self)
- def astng_from_file(self, filepath, modname=None, fallback=True):
+ def astng_from_file(self, filepath, modname=None, fallback=True, source=False):
"""given a module name, return the astng object"""
try:
filepath = get_source_file(filepath, include_no_ext=True)
source = True
except NoSourceFile:
- source = False
+ pass
if modname is None:
- modname = '.'.join(modpath_from_file(filepath))
+ try:
+ modname = '.'.join(modpath_from_file(filepath))
+ except ImportError:
+ modname = filepath
if modname in self._cache:
return self._cache[modname]
if source:
@@ -141,7 +144,6 @@ class ASTNGManager(OptionsProviderMixIn):
except (SyntaxError, KeyboardInterrupt, SystemExit):
raise
except Exception, ex:
- raise
if __debug__:
print 'error while building astng for', filepath
import traceback