94ced730d354975b0f99de35835cd4472d1b3e75,dlp/inspect_content.py,,inspect_bigquery,#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#,506

Before Change


    subscriber = google.cloud.pubsub.SubscriberClient()
    subscription_path = subscriber.subscription_path(
        project, subscription_id)
    subscription = subscriber.subscribe(subscription_path)

    // Set up a callback to acknowledge a message. This closes around an event
    // so that it can signal that it is done and the main thread can continue.
    job_done = threading.Event()

    def callback(message):
        try:
            if (message.attributes["DlpJobName"] == operation.name):
                // This is the message we"re looking for, so acknowledge it.
                message.ack()

                // Now that the job is done, fetch the results and print them.
                job = dlp.get_dlp_job(operation.name)
                if job.inspect_details.result.info_type_stats:
                    for finding in job.inspect_details.result.info_type_stats:
                        print("Info type: {}; Count: {}".format(
                            finding.info_type.name, finding.count))
                else:
                    print("No findings.")

                // Signal to the main thread that we can exit.
                job_done.set()
            else:
                // This is not the message we"re looking for.
                message.drop()
        except Exception as e:
            // Because this is executing in a thread, an exception won"t be
            // noted unless we print it manually.
            print(e)
            raise

    // Register the callback and wait on the event.
    subscription.open(callback)
    finished = job_done.wait(timeout=timeout)
    if not finished:
        print("No event received before the timeout. Please verify that the "
              "subscription provided is subscribed to the topic provided.")

After Change


            raise

    // Register the callback and wait on the event.
    subscriber.subscribe(subscription_path, callback=callback)
    finished = job_done.wait(timeout=timeout)
    if not finished:
        print("No event received before the timeout. Please verify that the "
              "subscription provided is subscribed to the topic provided.")
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: GoogleCloudPlatform/python-docs-samples
Commit Name: 94ced730d354975b0f99de35835cd4472d1b3e75
Time: 2019-01-25
Author: achinkul@gmail.com
File Name: dlp/inspect_content.py
Class Name:
Method Name: inspect_bigquery


Project Name: GoogleCloudPlatform/python-docs-samples
Commit Name: 94ced730d354975b0f99de35835cd4472d1b3e75
Time: 2019-01-25
Author: achinkul@gmail.com
File Name: dlp/inspect_content.py
Class Name:
Method Name: inspect_gcs_file


Project Name: GoogleCloudPlatform/python-docs-samples
Commit Name: 94ced730d354975b0f99de35835cd4472d1b3e75
Time: 2019-01-25
Author: achinkul@gmail.com
File Name: dlp/inspect_content.py
Class Name:
Method Name: inspect_datastore