@@ -46,7 +46,9 @@ def deidentify_with_mask(
4646 parent = dlp .project_path (project )
4747
4848 # Construct inspect configuration dictionary
49- inspect_config = {"info_types" : [{"name" : info_type } for info_type in info_types ]}
49+ inspect_config = {
50+ "info_types" : [{"name" : info_type } for info_type in info_types ]
51+ }
5052
5153 # Construct deidentify configuration dictionary
5254 deidentify_config = {
@@ -131,17 +133,24 @@ def deidentify_with_fpe(
131133 # Construct FPE configuration dictionary
132134 crypto_replace_ffx_fpe_config = {
133135 "crypto_key" : {
134- "kms_wrapped" : {"wrapped_key" : wrapped_key , "crypto_key_name" : key_name }
136+ "kms_wrapped" : {
137+ "wrapped_key" : wrapped_key ,
138+ "crypto_key_name" : key_name ,
139+ }
135140 },
136141 "common_alphabet" : alphabet ,
137142 }
138143
139144 # Add surrogate type
140145 if surrogate_type :
141- crypto_replace_ffx_fpe_config ["surrogate_info_type" ] = {"name" : surrogate_type }
146+ crypto_replace_ffx_fpe_config ["surrogate_info_type" ] = {
147+ "name" : surrogate_type
148+ }
142149
143150 # Construct inspect configuration dictionary
144- inspect_config = {"info_types" : [{"name" : info_type } for info_type in info_types ]}
151+ inspect_config = {
152+ "info_types" : [{"name" : info_type } for info_type in info_types ]
153+ }
145154
146155 # Construct deidentify configuration dictionary
147156 deidentify_config = {
@@ -176,7 +185,12 @@ def deidentify_with_fpe(
176185
177186# [START dlp_reidentify_fpe]
178187def reidentify_with_fpe (
179- project , string , alphabet = None , surrogate_type = None , key_name = None , wrapped_key = None
188+ project ,
189+ string ,
190+ alphabet = None ,
191+ surrogate_type = None ,
192+ key_name = None ,
193+ wrapped_key = None ,
180194):
181195 """Uses the Data Loss Prevention API to reidentify sensitive data in a
182196 string that was encrypted by Format Preserving Encryption (FPE).
@@ -333,7 +347,11 @@ def map_data(value):
333347 try :
334348 date = datetime .strptime (value , "%m/%d/%Y" )
335349 return {
336- "date_value" : {"year" : date .year , "month" : date .month , "day" : date .day }
350+ "date_value" : {
351+ "year" : date .year ,
352+ "month" : date .month ,
353+ "day" : date .day ,
354+ }
337355 }
338356 except ValueError :
339357 return {"string_value" : value }
@@ -426,7 +444,8 @@ def write_data(data):
426444
427445 mask_parser = subparsers .add_parser (
428446 "deid_mask" ,
429- help = "Deidentify sensitive data in a string by masking it with a " "character." ,
447+ help = "Deidentify sensitive data in a string by masking it with a "
448+ "character." ,
430449 )
431450 mask_parser .add_argument (
432451 "--info_types" ,
@@ -438,7 +457,8 @@ def write_data(data):
438457 default = ["FIRST_NAME" , "LAST_NAME" , "EMAIL_ADDRESS" ],
439458 )
440459 mask_parser .add_argument (
441- "project" , help = "The Google Cloud project id to use as a parent resource."
460+ "project" ,
461+ help = "The Google Cloud project id to use as a parent resource." ,
442462 )
443463 mask_parser .add_argument ("item" , help = "The string to deidentify." )
444464 mask_parser .add_argument (
@@ -471,11 +491,13 @@ def write_data(data):
471491 default = ["FIRST_NAME" , "LAST_NAME" , "EMAIL_ADDRESS" ],
472492 )
473493 fpe_parser .add_argument (
474- "project" , help = "The Google Cloud project id to use as a parent resource."
494+ "project" ,
495+ help = "The Google Cloud project id to use as a parent resource." ,
475496 )
476497 fpe_parser .add_argument (
477498 "item" ,
478- help = "The string to deidentify. " "Example: string = 'My SSN is 372819127'" ,
499+ help = "The string to deidentify. "
500+ "Example: string = 'My SSN is 372819127'" ,
479501 )
480502 fpe_parser .add_argument (
481503 "key_name" ,
@@ -513,11 +535,13 @@ def write_data(data):
513535 "Encryption (FPE)." ,
514536 )
515537 reid_parser .add_argument (
516- "project" , help = "The Google Cloud project id to use as a parent resource."
538+ "project" ,
539+ help = "The Google Cloud project id to use as a parent resource." ,
517540 )
518541 reid_parser .add_argument (
519542 "item" ,
520- help = "The string to deidentify. " "Example: string = 'My SSN is 372819127'" ,
543+ help = "The string to deidentify. "
544+ "Example: string = 'My SSN is 372819127'" ,
521545 )
522546 reid_parser .add_argument (
523547 "surrogate_type" ,
@@ -553,7 +577,8 @@ def write_data(data):
553577 help = "Deidentify dates in a CSV file by pseudorandomly shifting them." ,
554578 )
555579 date_shift_parser .add_argument (
556- "project" , help = "The Google Cloud project id to use as a parent resource."
580+ "project" ,
581+ help = "The Google Cloud project id to use as a parent resource." ,
557582 )
558583 date_shift_parser .add_argument (
559584 "input_csv_file" ,
0 commit comments