Compare two whisper databases. Each file must have the same archive configuration
541459
def diff(path_from, path_to, ignore_empty = False):
  
  fh_from = open(path_from, 'rb')
  fh_to = open(path_to, 'rb')
  diffs = file_diff(fh_from, fh_to, ignore_empty)
  fh_to.close()
  fh_from.close()
  return diffs
545454
def match(self, files):
        """"""
        if not files:
            return set()

        if (self.matched_inherit.all_files()
                or self.matched_and_subdir.all_files()
                or self.matched_no_subdir.all_files()):
            # Optimization: one of the matched patterns matches everything
            # So simply return it
            return set(files)

        unmatched = set(files)
        matched = set()
        for pattern_set in self._matching_pattern_sets():
            pattern_set.match_files(matched, unmatched)
            if not unmatched:
                # Optimization: If we have matched all files already
                # simply return at this point - nothing else to do
                break

        return matched
814596
def _sanity_check_files(item, files):
    
    msg = None
    file_types = set([("bam" if x.endswith(".bam") else "fastq") for x in files if x])
    if len(file_types) > 1:
        msg = "Found multiple file types (BAM and fastq)"
    file_type = file_types.pop()
    if file_type == "bam":
        if len(files) != 1:
            msg = "Expect a single BAM file input as input"
    elif file_type == "fastq":
        if len(files) not in [1, 2] and item["analysis"].lower() != "scrna-seq":
            pair_types = set([len(xs) for xs in fastq.combine_pairs(files)])
            if len(pair_types) != 1 or pair_types.pop() not in [1, 2]:
                msg = "Expect either 1 (single end) or 2 (paired end) fastq inputs"
        if len(files) == 2 and files[0] == files[1]:
            msg = "Expect both fastq files to not be the same"
    if msg:
        raise ValueError("%s for %s: %s" % (msg, item.get("description", ""), files))
1755
def _create(self):
        """"""
        if not os.path.exists(settings.SALMON_WHISPER_DB_PATH):
            os.makedirs(settings.SALMON_WHISPER_DB_PATH)
        archives = [whisper.parseRetentionDef(retentionDef)
                    for retentionDef in settings.ARCHIVES.split(",")]
        whisper.create(self.path, archives,
                       xFilesFactor=settings.XFILEFACTOR,
                       aggregationMethod=settings.AGGREGATION_METHOD)
1290636
def match_files(self, matched, unmatched):
        """"""
        this_match = set(self.file_filter(unmatched))
        matched |= this_match
        unmatched -= this_match
509377
def is_same(dir1, dir2):
    
    compared = dircmp(dir1, dir2, IGNORED_FILES)  # ignore the OS X file
    if compared.left_only or compared.right_only or compared.diff_files or compared.funny_files:
        return False
    for subdir in compared.common_dirs:
        if not is_same(os.path.join(dir1, subdir), os.path.join(dir2, subdir)):
            return False
    return True
1303839
def get_single_outfile (directory, archive, extension=""):
    """"""
    outfile = os.path.join(directory, stripext(archive))
    if os.path.exists(outfile + extension):
        # prevent overwriting existing files
        i = 1
        newfile = "%s%d" % (outfile, i)
        while os.path.exists(newfile + extension):
            newfile = "%s%d" % (outfile, i)
            i += 1
        outfile = newfile
    return outfile + extension
1358287
def _repack_archive (archive1, archive2, verbosity=0, interactive=True):
    """"""
    format1, compression1 = get_archive_format(archive1)
    format2, compression2 = get_archive_format(archive2)
    if format1 == format2 and compression1 == compression2:
        # same format and compression allows to copy the file
        util.link_or_copy(archive1, archive2, verbosity=verbosity)
        return
    tmpdir = util.tmpdir()
    try:
        kwargs = dict(verbosity=verbosity, outdir=tmpdir)
        same_format = (format1 == format2 and compression1 and compression2)
        if same_format:
            # only decompress since the format is the same
            kwargs['format'] = compression1
        path = _extract_archive(archive1, **kwargs)
        archive = os.path.abspath(archive2)
        files = tuple(os.listdir(path))
        olddir = os.getcwd()
        os.chdir(path)
        try:
            kwargs = dict(verbosity=verbosity, interactive=interactive)
            if same_format:
                # only compress since the format is the same
                kwargs['format'] = compression2
            _create_archive(archive, files, **kwargs)
        finally:
            os.chdir(olddir)
    finally:
        shutil.rmtree(tmpdir, onerror=rmtree_log_error)
744028
def compare(self, snapshot):
		
		builds = snapshot.builds()

		diff_snapshot = DistributionSnapshot(self.distribution(), self.go_version)

		for package in list(set(self._builds.keys()) - set(builds.keys())):
			diff_snapshot.setRpms(package, self._builds[package]["build"], self._builds[package]["build_ts"], self._builds[package]["rpms"])

		for package in list(set(self._builds.keys()) & set(builds.keys())):
			if self._builds[package]["build"] != builds[package]["build"]:
				diff_snapshot.setRpms(package, self._builds[package]["build"], self._builds[package]["build_ts"], self._builds[package]["rpms"])

		# Assuming no package get ever removed (even if retired)
		return diff_snapshot
696008
def archive_history_item(item, destination, no_color):
    
    log_src, description = split_history_item(item.strip())

    # Get relative path for log:
    # {provider}/{image}/{instance}/{timestamp}.log
    log_dest = os.path.sep.join(log_src.rsplit(os.path.sep, 4)[1:])

    # Get results src and destination based on log paths.
    results_src = log_src.rsplit('.', 1)[0] + '.results'
    results_dest = log_dest.rsplit('.', 1)[0] + '.results'

    destination_path = os.path.join(destination, log_dest)
    log_dir = os.path.dirname(destination_path)

    try:
        if not os.path.isdir(log_dir):
            os.makedirs(log_dir)

        # Copy results and log files to archive directory.
        shutil.copyfile(log_src, destination_path)
        shutil.copyfile(results_src, os.path.join(destination, results_dest))
    except Exception as error:
        echo_style(
            'Unable to archive history item: %s' % error,
            no_color,
            fg='red'
        )
        sys.exit(1)
    else:
        # Only update the archive results log if no error occur.
        update_history_log(
            os.path.join(destination, '.history'),
            description=description,
            test_log=log_dest
        )
455385
def db_exists(cls, impl, working_dir):
        
        path = config.get_snapshots_filename(impl, working_dir)
        return os.path.exists(path)
1323302
def _compare_by_version(path1, path2):
    
    if path1.source == path2.source:
        if path1.source_version_num > path2.source_version_num:
            return path1
        else:
            return path2
    return None
1124348
def diff(vault_client, opt):
    """"""
    if opt.thaw_from:
        opt.secrets = tempfile.mkdtemp('aomi-thaw')
        auto_thaw(vault_client, opt)

    ctx = Context.load(get_secretfile(opt), opt) \
                 .fetch(vault_client)

    for backend in ctx.mounts():
        diff_a_thing(backend, opt)

    for resource in ctx.resources():
        diff_a_thing(resource, opt)

    if opt.thaw_from:
        rmtree(opt.secrets)
371362
public int compare(FileStatus fileStatus1, FileStatus fileStatus2) {

    // Do the obligatory null checks.
    if ((fileStatus1 == null) && (fileStatus2 == null)) {
      return 0;
    }
    if (fileStatus1 == null) {
      return -1;
    }
    if (fileStatus2 == null) {
      return 1;
    }

    long modificationTime1 = fileStatus1.getModificationTime();
    long modificationTime2 = fileStatus2.getModificationTime();

    return (modificationTime1 < modificationTime2 ? -1
        : (modificationTime1 == modificationTime2 ? 0 : 1));
  }
1032235
def diff(
        cobertura_file1, cobertura_file2,
        color, format, output, source1, source2,
        source_prefix1, source_prefix2, source):
    """"""
    cobertura1 = Cobertura(
        cobertura_file1,
        source=source1,
        source_prefix=source_prefix1
    )
    cobertura2 = Cobertura(
        cobertura_file2,
        source=source2,
        source_prefix=source_prefix2
    )

    Reporter = delta_reporters[format]
    reporter_args = [cobertura1, cobertura2]
    reporter_kwargs = {'show_source': source}

    isatty = True if output is None else output.isatty()

    if format == 'text':
        color = isatty if color is None else color is True
        reporter_kwargs['color'] = color

    reporter = Reporter(*reporter_args, **reporter_kwargs)
    report = reporter.generate()

    if not isinstance(report, bytes):
        report = report.encode('utf-8')

    click.echo(report, file=output, nl=isatty, color=color)

    exit_code = get_exit_code(reporter.differ, source)
    raise SystemExit(exit_code)
499885
def check_archive_filelist (filenames):
    """"""
    if not filenames:
        raise PatoolError("cannot create archive with empty filelist")
    for filename in filenames:
        check_existing_filename(filename, onlyfiles=False)
606743
def _compare(info1, info2):
    # type: (Info, Info) -> bool
    
    # Check filesize has changed
    if info1.size != info2.size:
        return True
    # Check modified dates
    date1 = info1.modified
    date2 = info2.modified
    return date1 is None or date2 is None or date1 > date2