diff --git a/builtin.py b/builtin.py index a87f1285..56ff2edc 100644 --- a/builtin.py +++ b/builtin.py @@ -13,6 +13,8 @@ class Parser(object): It can be instantiated with either a path or a name of the module. The path is important for third party modules. + TODO maybe remove some code and merge it with `modules`? + :param name: The name of the module. :param path: The path of the module. :param sys_path: The sys.path, which is can be customizable. @@ -67,7 +69,12 @@ class Parser(object): """ get the parser lazy """ if not self._parser: try: - self._parser = Parser.cache[self.name, self.path].parser + timestamp, parser = Parser.cache[self.name, self.path] + if timestamp == os.path.getmtime(self.path): + debug.dbg('hit builtin cache') + self._parser = parser + else: + raise KeyError except KeyError: code = self._generate_code(self.module) try: @@ -77,7 +84,11 @@ class Parser(object): #open('builtin_fail', 'w').write(code) raise else: - Parser.cache[self.name, self.path] = self + if self.path: + p_time = os.path.getmtime(self.path) + else: + p_time = None + Parser.cache[self.name, self.path] = p_time, self._parser return self._parser def _generate_code(self, scope, depth=0): diff --git a/ftest.py b/ftest.py index 2f53778e..7f44c378 100755 --- a/ftest.py +++ b/ftest.py @@ -16,5 +16,7 @@ code = f.read() for i in range(1): completions = functions.complete(code, 150, 200, path) -#print '\n', ', '.join(sorted(str(c) for c in completions)) +print '\n', ', '.join(sorted(str(c) for c in completions)) +#print [n.name for n in completions] +#print [n.name.get_parent_until() for n in completions] print '#', len(completions) diff --git a/parsetest.py b/parsetest.py index 6061519e..1c3fb8d8 100644 --- a/parsetest.py +++ b/parsetest.py @@ -147,4 +147,4 @@ c = b().c3() 1.0.fromhex(); import flask ; flsk = flask.Flask + flask.Request; abc = [1,2+3]; abc[0]. import pylab -pylab. +pylab.one