Create Source of Truth file to compare.
16551
def _create_sot_file(self):
        """"""

        # Bug on on NX-OS 6.2.16 where overwriting sot_file would take exceptionally long time
        # (over 12 minutes); so just delete the sot_file
        try:
            self._delete_file(filename="sot_file")
        except Exception:
            pass
        commands = [
            "terminal dont-ask",
            "checkpoint file sot_file",
            "no terminal dont-ask",
        ]
        self._send_command_list(commands)
41588
def is_valid_file(parser, arg):
    """"""
    arg = os.path.abspath(arg)
    if not os.path.exists(arg):
        parser.error("The file %s does not exist!" % arg)
    else:
        return arg
1045521
def source(self):
        """"""
        with gui.FlexForm(self.title, auto_size_text=True, default_element_size=(40, 1)) as form:
            layout = [
                [gui.Text('Zip Backup utility', size=(30, 1), font=("Helvetica", 30), text_color='blue')],
                [gui.Text('Create a zip backup of a file or directory.', size=(50, 1), font=("Helvetica", 18),
                          text_color='black')],
                [gui.Text('-' * 200)],

                # Source
                [gui.Text('Select source folder', size=(20, 1), font=("Helvetica", 25), auto_size_text=False),
                 gui.InputText('', key='source', font=("Helvetica", 20)),
                 gui.FolderBrowse()],

                [gui.Submit(), gui.Cancel()]]

            button, values = form.LayoutAndRead(layout)
            if button == 'Submit':
                return values['source']
            else:
                exit()
762417
private void checkFileDataSource(FileDataSourceBase<?> fileSource) {
		String path = fileSource.getFilePath();
		if (path == null) {
			throw new InvalidProgramException("File path of FileDataSource is null.");
		}
		if (path.length() == 0) {
			throw new InvalidProgramException("File path of FileDataSource is empty string.");
		}
		
		try {
			Path p = new Path(path);
			String scheme = p.toUri().getScheme();
			
			if (scheme == null) {
				throw new InvalidProgramException("File path \"" + path + "\" of FileDataSource has no file system scheme (like 'file:// or hdfs://').");
			}
		} catch (Exception e) {
			throw new InvalidProgramException("File path \"" + path + "\" of FileDataSource is an invalid path: " + e.getMessage());
		}
	}
448234
static void createFileFromResourceCheckSizeDiff(String resource, Resource file) throws IOException {
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	IOUtil.copy(InfoImpl.class.getResourceAsStream(resource), baos, true, false);
	byte[] barr = baos.toByteArray();

	if (file.exists()) {
	    long trgSize = file.length();
	    long srcSize = barr.length;
	    if (srcSize == trgSize) return;

	    SystemOut.printDate(SystemUtil.getPrintWriter(SystemUtil.OUT), "update file:" + file);
	    SystemOut.printDate(SystemUtil.getPrintWriter(SystemUtil.OUT), " - source:" + srcSize);
	    SystemOut.printDate(SystemUtil.getPrintWriter(SystemUtil.OUT), " - target:" + trgSize);

	}
	else file.createNewFile();

	// SystemOut.printDate("write file:"+file);
	IOUtil.copy(new ByteArrayInputStream(barr), file, true);
    }
814335
def create_same_as_file(self):
        

        def find_preferred_uri(uri_list):
            index = None
            for i, uri in enumerate(uri_list):
                if uri.startswith("<http://id.loc.gov/authorities/subjects/"):
                        index = i
                        print(uri)
                        break
            if not index:
                for i, uri in enumerate(uri_list):
                    if uri.startswith(\
                            "<http://id.loc.gov/authorities/childrensSubjects/"):
                        index = i
                        print(uri)
                        break
            if not index:
                index = 0
            return (uri_list.pop(index), uri_list)


        with open(os.path.join(CFG.LOCAL_DATA_PATH, self.local_filename),
                  "w") as file_obj:
            file_obj.write(NSM.prefix("turtle"))
            for item in self.uri_list:
                uris = item['uris']['value'].split(",")
                new_list = find_preferred_uri(uris)
                uris = uris[1:]
                for uir in new_list[1]:
                    file_obj.write("%s kds:mergeWith %s .\n" % (uir,
                                                                new_list[0]))
1170164
def same_content(ref_source, test_source, allow_removed_final_blank_line):
    """"""
    if ref_source == test_source:
        return True

    if not allow_removed_final_blank_line:
        return False

    # Is ref identical to test, plus one blank line?
    ref_source = ref_source.splitlines()
    test_source = test_source.splitlines()

    if not ref_source:
        return False

    if ref_source[:-1] != test_source:
        return False

    return _BLANK_LINE.match(ref_source[-1])
548654
def source_files(self):
        """"""
        if 'srcs' in self.params and self.params['srcs'] is not None:
            return util.flatten(self.params['srcs'])
1165517
public static boolean compareFilesByContent(final File sourceFile, final File fileToCompare)
	{
		return CompareFileExtensions
			.compareFiles(sourceFile, fileToCompare, true, true, true, true, true, false)
			.getContentEquality();
	}
1138100
public static IFileContentResultBean compareFileContentByLines(final File sourceFile,
		final File fileToCompare)
	{
		final IFileContentResultBean fileContentResultBean = new FileContentResultBean(sourceFile,
			fileToCompare);
		completeCompare(fileContentResultBean);
		final boolean simpleEquality = validateEquality(fileContentResultBean);
		boolean contentEquality = true;
		// Compare the content...
		if (simpleEquality)
		{
			try (

				BufferedReader sourceReader = (BufferedReader)StreamExtensions
					.getReader(sourceFile);
				BufferedReader compareReader = (BufferedReader)StreamExtensions
					.getReader(fileToCompare);)
			{
				String sourceLine;
				String compareLine;

				while ((sourceLine = sourceReader.readLine()) != null)
				{
					compareLine = compareReader.readLine();
					if (compareLine == null || !sourceLine.equals(compareLine))
					{
						contentEquality = false;
						break;
					}
				}
			}
			catch (final FileNotFoundException e)
			{
				contentEquality = false;
			}
			catch (final IOException e)
			{
				contentEquality = false;
			}
		}
		fileContentResultBean.setContentEquality(contentEquality);
		return fileContentResultBean;
	}
1104701
def LoadCheckFromFile(file_path, check_id, overwrite_if_exists=True):
  """"""
  configs = LoadConfigsFromFile(file_path)
  conf = configs.get(check_id)
  check = Check(**conf)
  check.Validate()
  CheckRegistry.RegisterCheck(
      check,
      source="file:%s" % file_path,
      overwrite_if_exists=overwrite_if_exists)
  logging.debug("Loaded check %s from %s", check.check_id, file_path)
  return check
781222
def from_file(cls, source):
        """"""
        if hasattr(source, 'read'):
            relations = cls.from_string(source.read())
        else:
            with open(source) as f:
                relations = cls.from_string(f.read())
        return relations
1146128
def compare_disks(disk0, disk1, configuration):
    """"""
    with DiskComparator(disk0, disk1) as comparator:
        results = comparator.compare(
            size=configuration.get('get_file_size', False),
            identify=configuration.get('identify_files', False),
            concurrent=configuration.get('use_concurrency', False))

        if configuration.get('extract_files', False):
            extract = results['created_files'] + results['modified_files']
            files = comparator.extract(1, extract,
                                       path=configuration['results_folder'])

            results.update(files)

        if configuration.get('compare_registries', False):
            results['registry'] = comparator.compare_registry(
                concurrent=configuration.get('use_concurrency', False))

    return results
142115
def getabsfile(object):
    """"""
    return os.path.normcase(
        os.path.abspath(getsourcefile(object) or getfile(object)))
389913
public static boolean compareFilesByName(final File sourceFile, final File fileToCompare)
	{
		return CompareFileExtensions
			.compareFiles(sourceFile, fileToCompare, true, true, true, true, false, true)
			.getNameEquality();
	}
514229
def exists_locally(cls, path):
    """"""
    # If INFO file doesn't exist, consider resource does NOT exist, as it would
    # prevent guessing the `extract_method`.
    return (tf.io.gfile.exists(path) and
            tf.io.gfile.exists(_get_info_path(path)))
174361
def file(ctx, data_dir, data_file):
    """"""
    if not ctx.file:
        ctx.data_file = data_file

    if not ctx.data_dir:
        ctx.data_dir = data_dir

    ctx.type = 'file'