How to use the jsondiff.GMDiffer function in jsondiff

To help you get started, we’ve selected a few jsondiff examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aosp-mirror / platform_external_skia / tools / svndiff.py View on Github external
def _CallJsonDiff(old_json_path, new_json_path,
                  old_flattened_dir, new_flattened_dir,
                  filename_prefix):
    """Using jsondiff.py, write the images that differ between two GM
    expectations summary files (old and new) into old_flattened_dir and
    new_flattened_dir.

    filename_prefix: prefix to prepend to filenames of all images we write
        into the flattened directories
    """
    json_differ = jsondiff.GMDiffer()
    diff_dict = json_differ.GenerateDiffDict(oldfile=old_json_path,
                                             newfile=new_json_path)
    print 'Downloading %d before-and-after image pairs...' % len(diff_dict)
    for (imagename, results) in diff_dict.iteritems():
        # TODO(epoger): Currently, this assumes that all images have been
        # checksummed using gm_json.JSONKEY_HASHTYPE_BITMAP_64BITMD5

        old_checksum = results['old']
        if old_checksum:
            old_image_url = _CreateGSUrl(
                imagename=imagename,
                hash_type=gm_json.JSONKEY_HASHTYPE_BITMAP_64BITMD5,
                hash_digest=old_checksum)
            _DownloadUrlToFile(
                source_url=old_image_url,
                dest_path=os.path.join(old_flattened_dir,
github google / skia / tools / svndiff.py View on Github external
def _CallJsonDiff(old_json_path, new_json_path,
                  old_flattened_dir, new_flattened_dir,
                  filename_prefix):
    """Using jsondiff.py, write the images that differ between two GM
    expectations summary files (old and new) into old_flattened_dir and
    new_flattened_dir.

    filename_prefix: prefix to prepend to filenames of all images we write
        into the flattened directories
    """
    json_differ = jsondiff.GMDiffer()
    diff_dict = json_differ.GenerateDiffDict(oldfile=old_json_path,
                                             newfile=new_json_path)
    print 'Downloading %d before-and-after image pairs...' % len(diff_dict)
    for (imagename, results) in diff_dict.iteritems():
        # TODO(epoger): Currently, this assumes that all images have been
        # checksummed using gm_json.JSONKEY_HASHTYPE_BITMAP_64BITMD5

        old_checksum = results['old']
        if old_checksum:
            old_image_url = _CreateGSUrl(
                imagename=imagename,
                hash_type=gm_json.JSONKEY_HASHTYPE_BITMAP_64BITMD5,
                hash_digest=old_checksum)
            _DownloadUrlToFile(
                source_url=old_image_url,
                dest_path=os.path.join(old_flattened_dir,
github google / skia / tools / skpdiff / skpdiff_server.py View on Github external
def _get_expectations(self):
        """Fills self._expectations with GMInstance objects for each test whose
        expectation is different between the following two files:
         - the local filesystem's updated results file
         - git's head version of the expected results file
        """
        differ = jsondiff.GMDiffer()
        self._expectations = []
        for root, dirs, files in os.walk(self._expectations_dir):
            for expectation_file in files:
                # There are many files in the expectations directory. We only
                # care about expected results.
                if expectation_file != self._expected_name:
                    continue

                # Get the name of the results file, and be sure there is an
                # updated result to compare against. If there is not, there is
                # no point in diffing this device.
                expected_file_path = os.path.join(root, self._expected_name)
                updated_file_path = os.path.join(root, self._updated_name)
                if not os.path.isfile(updated_file_path):
                    continue