def gcs_get_file(bucketname,<EOL>filename,<EOL>local_file,<EOL>altexts=None,<EOL>client=None,<EOL>service_account_json=None,<EOL>raiseonfail=False):
if not client:<EOL><INDENT>if (service_account_json is not None and<EOL>os.path.exists(service_account_json)):<EOL><INDENT>client = storage.Client.from_service_account_json(<EOL>service_account_json<EOL>)<EOL><DEDENT>else:<EOL><INDENT>client = storage.Client()<EOL><DEDENT><DEDENT>try:<EOL><INDENT>bucket = client.get_bucket(bucketname)<EOL>blob = bucket.get_blob(filename)<EOL>blob.download_to_filename(local_file)<EOL>return local_file<EOL><DEDENT>except Exception as e:<EOL><INDENT>for alt_extension in altexts:<EOL><INDENT>split_ext = os.path.splitext(filename)<EOL>check_file = split_ext[<NUM_LIT:0>] + alt_extension<EOL>try:<EOL><INDENT>bucket = client.get_bucket(bucket)<EOL>blob = bucket.get_blob(check_file)<EOL>blob.download_to_filename(<EOL>local_file.replace(split_ext[-<NUM_LIT:1>],<EOL>alt_extension)<EOL>)<EOL>return local_file.replace(split_ext[-<NUM_LIT:1>],<EOL>alt_extension)<EOL><DEDENT>except Exception as e:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>' % (bucket, filename))<EOL>if raiseonfail:<EOL><INDENT>raise<EOL><DEDENT>return None<EOL><DEDENT>
This gets a single file from a Google Cloud Storage bucket.

    Parameters
    ----------

    bucketname : str
        The name of the GCS bucket to download the file from.

    filename : str
        The full name of the file to download, including all prefixes.

    local_file : str
        Path to where the downloaded file will be stored.

    altexts : None or list of str
        If not None, this is a list of alternate extensions to try for the file
        other than the one provided in `filename`. For example, to get anything
        that's an .sqlite where .sqlite.gz is expected, use altexts=[''] to
        strip the .gz.

    client : google.cloud.storage.Client instance
        The instance of the Client to use to perform the download operation. If
        this is None, a new Client will be used. If this is None and
        `service_account_json` points to a downloaded JSON file with GCS
        credentials, a new Client with the provided credentials will be used. If
        this is not None, the existing Client instance will be used.

    service_account_json : str
        Path to a downloaded GCS credentials JSON file.

    raiseonfail : bool
        If True, will re-raise whatever Exception caused the operation to fail
        and break out immediately.

    Returns
    -------

    str
        Path to the downloaded filename or None if the download was
        unsuccessful.