Beispiel #1
0
 def parser(self):
     """ get the parser lazy """
     if not self._parser:
         try:
             timestamp, parser = self.cache[self.path or self.name]
             if not self.path or os.path.getmtime(self.path) <= timestamp:
                 self._parser = parser
             else:
                 # In case there is already a module cached and this module
                 # has to be reparsed, we also need to invalidate the import
                 # caches.
                 imports.invalidate_star_import_cache(parser.module)
                 raise KeyError()
         except KeyError:
             self._load_module()
     return self._parser
Beispiel #2
0
 def parser(self):
     """ get the parser lazy """
     if not self._parser:
         try:
             timestamp, parser = self.cache[self.path or self.name]
             if not self.path or os.path.getmtime(self.path) <= timestamp:
                 self._parser = parser
             else:
                 # In case there is already a module cached and this module
                 # has to be reparsed, we also need to invalidate the import
                 # caches.
                 imports.invalidate_star_import_cache(parser.module)
                 raise KeyError()
         except KeyError:
             self._load_module()
     return self._parser
Beispiel #3
0
    def parser(self):
        """ get the parser lazy """
        if not self._parser:
            try:
                ts, parser = builtin.CachedModule.cache[self.path]
                imports.invalidate_star_import_cache(parser.module)

                del builtin.CachedModule.cache[self.path]
            except KeyError:
                pass
            # Call the parser already here, because it will be used anyways.
            # Also, the position is here important (which will not be used by
            # default), therefore fill the cache here.
            self._parser = parsing.PyFuzzyParser(self.source, self.path,
                                                 self.position)
            if self.path is not None:
                builtin.CachedModule.cache[self.path] = time.time(), \
                                                        self._parser
        return self._parser
Beispiel #4
0
    def parser(self):
        """ get the parser lazy """
        if not self._parser:
            try:
                ts, parser = builtin.CachedModule.cache[self.path]
                imports.invalidate_star_import_cache(parser.module)

                del builtin.CachedModule.cache[self.path]
            except KeyError:
                pass
            # Call the parser already here, because it will be used anyways.
            # Also, the position is here important (which will not be used by
            # default), therefore fill the cache here.
            self._parser = fast_parser.FastParser(self.source, self.path,
                                                        self.position)
            if self.path is not None:
                builtin.CachedModule.cache[self.path] = time.time(), \
                                                        self._parser
        return self._parser