<commit_before>"""This module provides the gcs_mirror_url macro."""

# Set to True to force the macro to only return the mirror URL.
_TEST_GCS_MIRROR = False

# Must be kept in sync with the suffixes supported by gcs_mirror (e.g.
# https://skia.googlesource.com/skia/+/8ad66c2340713234df6b249e793415233337a103/bazel/gcs_mirror/gcs_mirror.go#140).
_SUPPORTED_SUFFIXES = [".tar.gz", ".tgz", ".tar.xz", ".deb", ".zip"]

_GCS_MIRROR_PREFIX = "https://storage.googleapis.com/skia-world-readable/bazel"

def gcs_mirror_url(url, sha256):
    """Takes the URL of an external resource and computes its GCS mirror URL.

    We store backup copies of external resources in the skia-world-readable GCS bucket. This macro
    returns a list with two elements: the original URL, and the mirrored URL.

    Files are expected to be in the mirror location named after their sha256 hash. The files should
    still have their file extension, as some of the Starlark functions sniff the file extension
    (e.g. download_and_extract). See //bazel/gcs_mirror for an automated way to update this mirror.

    To mirror a new URL, please use the `gcs_mirror` utility found at
    https://skia.googlesource.com/skia/+/8ad66c2340713234df6b249e793415233337a103/bazel/gcs_mirror/gcs_mirror.go.

    Args:
        url: URL of the mirrored resource.
        sha256: SHA256 hash of the mirrored resource.
    Returns:
        A list of the form [original URL, mirror URL].
    """
    extension = ""
    for suffix in _SUPPORTED_SUFFIXES:
        if url.endswith(suffix):
            extension = suffix
            break
    if extension == "":
        fail("URL %s has an unsupported suffix." % url)

    mirror_url = "%s/%s.%s" % (_GCS_MIRROR_PREFIX, sha256, extension)
    return [mirror_url] if _TEST_GCS_MIRROR else [url, mirror_url]
<commit_msg>[bazel] Fix GCS mirror typo<commit_after>"""This module provides the gcs_mirror_url macro."""

# Set to True to force the macro to only return the mirror URL.
_TEST_GCS_MIRROR = False

# Must be kept in sync with the suffixes supported by gcs_mirror (e.g.
# https://skia.googlesource.com/skia/+/8ad66c2340713234df6b249e793415233337a103/bazel/gcs_mirror/gcs_mirror.go#140).
_SUPPORTED_SUFFIXES = [".tar.gz", ".tgz", ".tar.xz", ".deb", ".zip"]

_GCS_MIRROR_PREFIX = "https://storage.googleapis.com/skia-world-readable/bazel"

def gcs_mirror_url(url, sha256):
    """Takes the URL of an external resource and computes its GCS mirror URL.

    We store backup copies of external resources in the skia-world-readable GCS bucket. This macro
    returns a list with two elements: the original URL, and the mirrored URL.

    Files are expected to be in the mirror location named after their sha256 hash. The files should
    still have their file extension, as some of the Starlark functions sniff the file extension
    (e.g. download_and_extract). See //bazel/gcs_mirror for an automated way to update this mirror.

    To mirror a new URL, please use the `gcs_mirror` utility found at
    https://skia.googlesource.com/skia/+/8ad66c2340713234df6b249e793415233337a103/bazel/gcs_mirror/gcs_mirror.go.

    Args:
        url: URL of the mirrored resource.
        sha256: SHA256 hash of the mirrored resource.
    Returns:
        A list of the form [original URL, mirror URL].
    """
    extension = ""
    for suffix in _SUPPORTED_SUFFIXES:
        if url.endswith(suffix):
            extension = suffix
            break
    if extension == "":
        fail("URL %s has an unsupported suffix." % url)

    mirror_url = "%s/%s%s" % (_GCS_MIRROR_PREFIX, sha256, extension)
    return [mirror_url] if _TEST_GCS_MIRROR else [url, mirror_url]

{'fraction_non_alphanumeric': 0.08991527739819623, 'fraction_numerical': 0.04482098934135009, 'mean_word_length': 3.420289855072464, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6917898', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1192, 'n_words': 398}