def _AddToCache( self, path, includes, mtime = None ):
   if not mtime:
     mtime = GetModificationTime( path )
   # mtime of 0 is "a magic value" to represent inaccessible directory mtime.
   if mtime:
     with self._cache_lock:
       self._cache[ path ] = { 'mtime': mtime, 'includes': includes }
  def _GetCached( self, path, is_framework ):
    includes = None
    with self._cache_lock:
      cache_entry = self._cache.get( path )
    if cache_entry:
      mtime = GetModificationTime( path )
      if mtime > cache_entry[ 'mtime' ]:
        includes = self._ListIncludes( path, is_framework )
        self._AddToCache( path, includes, mtime )
      else:
        includes = cache_entry[ 'includes' ]

    return includes
Ejemplo n.º 3
0
    def GetCandidatesForDirectory(self, directory):
        mtime = GetModificationTime(directory)

        try:
            candidates = self._candidates_for_directory[directory]
            if mtime and mtime <= candidates['mtime']:
                return candidates['candidates']
        except KeyError:
            pass

        candidates = _GeneratePathCompletionCandidates(directory)
        if mtime:
            self._candidates_for_directory[directory] = {
                'candidates': candidates,
                'mtime': mtime
            }
        return candidates
Ejemplo n.º 4
0
    def GetCompiledHeadRegexForDirectory(self, directory):
        mtime = GetModificationTime(directory)

        try:
            head_regex = self._head_path_for_directory[directory]
            if mtime and mtime <= head_regex['mtime']:
                return head_regex['regex']
        except KeyError:
            pass

        current_paths = ListDirectory(directory)
        current_paths_pattern = '|'.join(
            [re.escape(path) for path in current_paths])
        head_pattern = ('(' + self._head_path_pattern + '|' +
                        current_paths_pattern + ')$')
        head_regex = re.compile(head_pattern, re.VERBOSE)
        if mtime:
            self._head_path_for_directory[directory] = {
                'regex': head_regex,
                'mtime': mtime
            }
        return head_regex