Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 02c593c

Browse filesBrowse files
committed
update to follow Ruby PR's comment structure
1 parent 9469c10 commit 02c593c
Copy full SHA for 02c593c

File tree

Expand file treeCollapse file tree

3 files changed

+13
-25
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+13
-25
lines changed

‎dlp/dlp_inspect_image_file.py

Copy file name to clipboardExpand all lines: dlp/dlp_inspect_image_file.py
+4-8Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ def inspect_image_file(project_id='YOUR_PROJECT_ID',
2727
with open(filepath, mode='rb') as f:
2828
file_bytes = f.read()
2929

30-
# Construct the item
30+
# Construct request
31+
parent = dlp.project_path(project_id)
3132
item = {'byte_item': {'type': 'IMAGE', 'data': file_bytes}}
32-
33-
# Construct the configuration
3433
inspect_config = {
3534
# The infoTypes of information to match
3635
'info_types': [
@@ -42,13 +41,10 @@ def inspect_image_file(project_id='YOUR_PROJECT_ID',
4241
'include_quote': True,
4342
}
4443

45-
# Convert the project id into a full resource id
46-
parent = dlp.project_path(project_id)
47-
48-
# Call the API
44+
# Run request
4945
response = dlp.inspect_content(parent, inspect_config, item)
5046

51-
# Print out the results
47+
# Print the results
5248
if response.result.findings:
5349
for finding in response.result.findings:
5450
print('Quote: {}'.format(finding.quote))

‎dlp/dlp_inspect_string.py

Copy file name to clipboardExpand all lines: dlp/dlp_inspect_string.py
+5-9Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def inspect_string(project_id='YOUR_PROJECT_ID'):
2222
# Instantiate a client
2323
dlp = google.cloud.dlp.DlpServiceClient()
2424

25-
# Construct the configuration
25+
# Construct request
26+
parent = dlp.project_path(project_id)
27+
item = {'value': 'My name is Gary Smith and my email is gary@example.com'}
2628
inspect_config = {
2729
# The infoTypes of information to match
2830
'info_types': [
@@ -34,16 +36,10 @@ def inspect_string(project_id='YOUR_PROJECT_ID'):
3436
'include_quote': True,
3537
}
3638

37-
# Construct the `item`
38-
item = {'value': 'My name is Gary Smith and my email is gary@example.com'}
39-
40-
# Convert the project id into a full resource id
41-
parent = dlp.project_path(project_id)
42-
43-
# Call the API
39+
# Run request
4440
response = dlp.inspect_content(parent, inspect_config, item)
4541

46-
# Print out the results
42+
# Print the results
4743
if response.result.findings:
4844
for finding in response.result.findings:
4945
print('Quote: {}'.format(finding.quote))

‎dlp/dlp_inspect_text_file.py

Copy file name to clipboardExpand all lines: dlp/dlp_inspect_text_file.py
+4-8Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ def inspect_text_file(project_id='YOUR_PROJECT_ID',
2727
with open(filepath, mode='rb') as f:
2828
file_bytes = f.read()
2929

30-
# Construct the item
30+
# Construct request
31+
parent = dlp.project_path(project_id)
3132
item = {'byte_item': {'type': 'TEXT_UTF8', 'data': file_bytes}}
32-
33-
# Construct the configuration
3433
inspect_config = {
3534
# The infoTypes of information to match
3635
'info_types': [
@@ -42,13 +41,10 @@ def inspect_text_file(project_id='YOUR_PROJECT_ID',
4241
'include_quote': True,
4342
}
4443

45-
# Convert the project id into a full resource id
46-
parent = dlp.project_path(project_id)
47-
48-
# Call the API
44+
# Run request
4945
response = dlp.inspect_content(parent, inspect_config, item)
5046

51-
# Print out the results
47+
# Print the results
5248
if response.result.findings:
5349
for finding in response.result.findings:
5450
print('Quote: {}'.format(finding.quote))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.