From 85c62be4592b9ae80e71e4543f8789862f6aca4d Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 21 Jun 2023 15:28:02 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20post-p?= =?UTF-8?q?rocessor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- dlp/snippets/deid.py | 16 ++++++---------- dlp/snippets/deid_test.py | 4 +++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/dlp/snippets/deid.py b/dlp/snippets/deid.py index 0413206e5c64..7fe220b58597 100644 --- a/dlp/snippets/deid.py +++ b/dlp/snippets/deid.py @@ -928,7 +928,7 @@ def deidentify_with_time_extract( input_csv_file: str, output_csv_file: str, ) -> None: - """ Uses the Data Loss Prevention API to deidentify dates in a CSV file through + """Uses the Data Loss Prevention API to deidentify dates in a CSV file through time part extraction. Args: project: The Google Cloud project id to use as a parent resource. @@ -968,9 +968,7 @@ def map_data(value): try: date = datetime.strptime(value, "%m/%d/%Y") return { - "date_value": { - "year": date.year, "month": date.month, "day": date.day - } + "date_value": {"year": date.year, "month": date.month, "day": date.day} } except ValueError: return {"string_value": value} @@ -995,9 +993,7 @@ def map_rows(row): "field_transformations": [ { "primitive_transformation": { - "time_part_config": { - "part_to_extract": "YEAR" - } + "time_part_config": {"part_to_extract": "YEAR"} }, "fields": date_fields, } @@ -2266,14 +2262,14 @@ def deidentify_table_with_multiple_crypto_hash( time_extract_parser.add_argument( "input_csv_file", help="The path to the CSV file to deidentify. The first row of the " - "file must specify column names, and all other rows must contain " - "valid values.", + "file must specify column names, and all other rows must contain " + "valid values.", ) time_extract_parser.add_argument( "date_fields", nargs="+", help="The list of date fields in the CSV file to de-identify. Example: " - "['birth_date', 'register_date']", + "['birth_date', 'register_date']", ) time_extract_parser.add_argument( "output_csv_file", help="The path to save the time-extracted data." diff --git a/dlp/snippets/deid_test.py b/dlp/snippets/deid_test.py index 5162fa35fd81..fa2541cbf736 100644 --- a/dlp/snippets/deid_test.py +++ b/dlp/snippets/deid_test.py @@ -230,7 +230,9 @@ def test_deidentify_with_date_shift_using_context_field( assert "Successful" in out -def test_deidentify_with_time_extract(tempdir: TextIO, capsys: pytest.CaptureFixture) -> None: +def test_deidentify_with_time_extract( + tempdir: TextIO, capsys: pytest.CaptureFixture +) -> None: output_filepath = os.path.join(str(tempdir), "year-extracted.csv") deid.deidentify_with_time_extract(