compares the index and the working directory
347488
def diff_files
        hsh = {}
        @base.git.diff_files.split("\n").each do |line|
          (info, file) = line.split("\t")
          (mode_src, mode_dest, sha_src, sha_dest, type) = info.split
          hsh[file] = {:path => file, :mode_file => mode_src.to_s[1, 7], :mode_index => mode_dest,
                        :sha_file => sha_src, :sha_index => sha_dest, :type => type}
        end
        hsh
      end
1215007
def isdir(self, dirname):
        """"""
        client = boto3.client("s3")
        bucket, path = self.bucket_and_path(dirname)
        if not path.endswith("/"):
            path += "/"  # This will now only retrieve subdir content
        r = client.list_objects(Bucket=bucket, Prefix=path, Delimiter="/")
        if r.get("Contents") or r.get("CommonPrefixes"):
            return True
        return False
1069370
def work_in(dirname=None):
    
    curdir = os.getcwd()
    try:
        if dirname is not None:
            os.chdir(dirname)
        yield
    finally:
        os.chdir(curdir)
198707
def is_directory_index(resource):
    
    remote_regexp = re.compile(r"^https?://(.+)/?$", re.I)
    result = remote_regexp.match(resource)

    if result is not None:
        juicer.utils.Log.log_debug("%s matches directory index regexp" % resource)
        return True
    else:
        juicer.utils.Log.log_debug("%s doesn't match directory index regexp" % resource)
        return False
354075
def is_workdir(cls, path):
        
        try:
            cls(path=path).load()
        except MalformedWorkdir:
            return False

        return True
1197157
def indexes_equal(a: Index, b: Index) -> bool:
    
    return str(a) == str(b)
1152435
function(options){
        if (!options) {
            options = {
                cwd: workingDirectory
            };

            return options;
        } else {
            workingDirectory = options.cwd;
            return options;
        }
    }
723165
private boolean searchHarDir(FileStatus stat) 
      throws IOException {
    if (!stat.isDir()) {
      return false;
    }
    String pattern = stat.getPath().toString() + "/*" + RaidNode.HAR_SUFFIX 
        + "*";
    FileStatus[] stats = globStatus(new Path(pattern));
    if (stats != null && stats.length > 0) {
      return true;
    }
      
    stats = fs.listStatus(stat.getPath());
   
    // search deeper.
    for (FileStatus status : stats) {
      if (searchHarDir(status)) {
        return true;
      }
    }
    return false;
  }
194491
def _check_directory(name,
                     user=None,
                     group=None,
                     recurse=False,
                     mode=None,
                     file_mode=None,
                     clean=False,
                     require=False,
                     exclude_pat=None,
                     max_depth=None,
                     follow_symlinks=False,
                     children_only=False):
    '''
    
    '''
    changes = {}
    if recurse or clean:
        assert max_depth is None or not clean
        # walk path only once and store the result
        walk_l = list(_depth_limited_walk(name, max_depth))
        # root: (dirs, files) structure, compatible for python2.6
        walk_d = {}
        for i in walk_l:
            walk_d[i[0]] = (i[1], i[2])

    # Preserve rootdir_mode before going into recurse
    rootdir_mode = mode
    if recurse:
        try:
            recurse_set = _get_recurse_set(recurse)
        except (TypeError, ValueError) as exc:
            return False, '{0}'.format(exc), changes
        if 'user' not in recurse_set:
            user = None
        if 'group' not in recurse_set:
            group = None
        if 'mode' not in recurse_set:
            mode = None
        check_files = 'ignore_files' not in recurse_set
        check_dirs = 'ignore_dirs' not in recurse_set
        for root, dirs, files in walk_l:
            if check_files:
                for fname in files:
                    fchange = {}
                    mode = file_mode if mode is not None else None
                    path = os.path.join(root, fname)
                    stats = __salt__['file.stats'](
                        path, None, follow_symlinks
                    )
                    if user is not None and user != stats.get('user'):
                        fchange['user'] = user
                    if group is not None and group != stats.get('group'):
                        fchange['group'] = group
                    if mode is not None and mode != stats.get('mode'):
                        fchange['mode'] = mode
                    if fchange:
                        changes[path] = fchange
            if check_dirs:
                for name_ in dirs:
                    path = os.path.join(root, name_)
                    fchange = _check_dir_meta(path, user, group, mode, follow_symlinks)
                    if fchange:
                        changes[path] = fchange

    # Recurse skips root (we always do dirs, not root), so always check root:
    if not children_only:
        fchange = _check_dir_meta(name, user, group, rootdir_mode, follow_symlinks)
        if fchange:
            changes[name] = fchange

    if clean:
        keep = _gen_keep_files(name, require, walk_d)

        def _check_changes(fname):
            path = os.path.join(root, fname)
            if path in keep:
                return {}
            else:
                if not salt.utils.stringutils.check_include_exclude(
                        os.path.relpath(path, name), None, exclude_pat):
                    return {}
                else:
                    return {path: {'removed': 'Removed due to clean'}}

        for root, dirs, files in walk_l:
            for fname in files:
                changes.update(_check_changes(fname))
            for name_ in dirs:
                changes.update(_check_changes(name_))

    if not os.path.isdir(name):
        changes[name] = {'directory': 'new'}
    if changes:
        comments = ['The following files will be changed:\n']
        for fn_ in changes:
            for key, val in six.iteritems(changes[fn_]):
                comments.append('{0}: {1} - {2}\n'.format(fn_, key, val))
        return None, ''.join(comments), changes
    return True, 'The directory {0} is in the correct state'.format(name), changes
1101352
private void checkIndex() throws IOException {
        boolean isUpToDate = true;
        if (!isUpToDate()) {
            closeFile();
            isUpToDate = false;
        }

        if (zipRandomFile != null || isUpToDate) {
            lastReferenceTimeStamp = System.currentTimeMillis();
            return;
        }

        hasPopulatedData = true;

        if (readIndex()) {
            lastReferenceTimeStamp = System.currentTimeMillis();
            return;
        }

        directories = Collections.<RelativeDirectory, DirectoryEntry>emptyMap();
        allDirs = Collections.<RelativeDirectory>emptySet();

        try {
            openFile();
            long totalLength = zipRandomFile.length();
            ZipDirectory directory = new ZipDirectory(zipRandomFile, 0L, totalLength, this);
            directory.buildIndex();
        } finally {
            if (zipRandomFile != null) {
                closeFile();
            }
        }

        lastReferenceTimeStamp = System.currentTimeMillis();
    }
461766
def fast_compare(self, dir_path):
        
        if self.latest_backup is None:
            # No old backup run was found
            return

        if self.latest_mtime_ns is None:
            # No timestamp from old backup run was found
            return

        # There was a completed old backup run
        # Check if we can made a 'fast compare'
        mtime_ns = dir_path.stat.st_mtime_ns
        if mtime_ns > self.latest_mtime_ns:
            # The current source file is newer than
            # the latest file from last completed backup
            log.info("Fast compare: source file is newer than latest backuped file.")
            return

        # Look into database and compare mtime and size

        try:
            old_backup_entry = BackupEntry.objects.get(
                backup_run=self.latest_backup,
                directory__directory=self.path_helper.sub_path,
                filename__filename=self.path_helper.filename,
                no_link_source=False,
            )
        except BackupEntry.DoesNotExist:
            log.debug("No old backup entry found")
            return

        content_info = old_backup_entry.content_info

        file_size = content_info.file_size
        if file_size != dir_path.stat.st_size:
            log.info("Fast compare: File size is different: %i != %i" % (file_size, dir_path.stat.st_size))
            return

        old_backup_filepath = old_backup_entry.get_backup_path()
        try:
            old_file_mtime_ns = old_backup_filepath.stat().st_mtime_ns
        except FileNotFoundError as err:
            log.error("Old backup file not found: %s" % err)
            old_backup_entry.no_link_source = True
            old_backup_entry.save()
            return

        if old_file_mtime_ns != old_backup_entry.file_mtime_ns:
            log.error("ERROR: mtime from database is different to the file!")
            log.error(" * File: %s" % old_backup_filepath)
            log.error(" * Database mtime: %s" % old_backup_entry.file_mtime_ns)
            log.error(" * File mtime: %s" % old_file_mtime_ns)

        if old_file_mtime_ns != dir_path.stat.st_mtime_ns:
            log.info("Fast compare mtime is different between:")
            log.info(" * %s" % old_backup_entry)
            log.info(" * %s" % dir_path)
            log.info(" * mtime: %i != %i" % (old_file_mtime_ns, dir_path.stat.st_mtime_ns))
            return

        # We found a old entry with same size and mtime
        return old_backup_entry
655701
def dir_has_index?(relative_path)
      relative_path << "/" unless relative_path.end_with? "/"
      regex = %r!^#{Regexp.escape(relative_path)}#{INDEX_REGEX}!i
      (site.pages + site.static_files).any? { |file| file.url =~ regex }
    end
1209230
private void indexDirectory(String id, fr.pilato.elasticsearch.crawler.fs.beans.Path path) throws Exception {
        esIndex(fsSettings.getElasticsearch().getIndexFolder(),
                id,
                PathParser.toJson(path),
                null);
    }
37430
def prevent_dir_name_collisions
      
      # Find directories beginning with test directory name
      #
      dirs = Dir.glob("#{@options[:path]}/*").select { |d|
        File.directory?(d) && d.match(/#{@options[:dir]}($|-\d+$)/)
      }.size

      # If matching directories are found, increment the dir name
      # e.g. "test-site-2"
      #
      if dirs > 0
        @options[:dir] << "-#{dirs += 1}"
      end
    end
586786
def full_diff
      base = compare_base_obj || head
      base.diff(repo.index).merge!(repo.diff_workdir(head))
    end
371736
def do_for_dir(inws, begin):
    '''
    
    '''
    inws = os.path.abspath(inws)
    for wroot, wdirs, wfiles in os.walk(inws):
        for wfile in wfiles:
            if wfile.endswith('.html'):
                if 'autogen' in wroot:
                    continue
                check_html(os.path.abspath(os.path.join(wroot, wfile)), begin)
282095
def check(self, diff):
        """"""
        path = diff.b_path
        assert any(
            path.endswith(ext)
            for ext in importlib.machinery.SOURCE_SUFFIXES
        )