Skip to content

Commit

Permalink
Fix python code transformation by adding py_scrub in copybara. .
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 635606767
Change-Id: Ib2bb382cbe7bf9234d82500bbf519eb377c9b8d9
  • Loading branch information
maoning authored and copybara-github committed May 20, 2024
1 parent ae19e91 commit be0f223
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
4 changes: 2 additions & 2 deletions plugin_server/py/common/net/http/http_header_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class HttpHeaderFields(enum.Enum):
CROSS_ORIGIN_EMBEDDER_POLICY = "Cross-Origin-Embedder-Policy"
CROSS_ORIGIN_EMBEDDER_POLICY_REPORT_ONLY = "Cross-Origin-Embedder-Policy-Report-Only"
CROSS_ORIGIN_OPENER_POLICY = "Cross-Origin-Opener-Policy"
CROSS_ORIGIN_OPENER_POLICY_REPORT_ONLY = "Cross-Origin-Opener-Policy-Report-Only" # copybara:replace(google internal field) external code
external code
ETAG = "ETag"
EXPIRES = "Expires"
LAST_MODIFIED = "Last-Modified"
Expand Down Expand Up @@ -157,7 +157,7 @@ class HttpHeaderFields(enum.Enum):
SEC_CH_PREFERS_COLOR_SCHEME = "Sec-CH-Prefers-Color-Scheme"
ACCEPT_CH = "Accept-CH"
CRITICAL_CH = "Critical-CH"
SEC_CH_UA_REDUCED = "Sec-CH-UA-Reduced" # copybara:replace(google internal field) external code
external code
SEC_CH_UA = "Sec-CH-UA"
SEC_CH_UA_ARCH = "Sec-CH-UA-Arch"
SEC_CH_UA_MODEL = "Sec-CH-UA-Model"
Expand Down
18 changes: 3 additions & 15 deletions plugin_server/py/plugin/payload/payload_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@

from ruamel import yaml
from google.protobuf import json_format
# copybara:strip_begin(internal-blaze-run)
from google3.pyglib import resources
# copybara:strip_end_and_replace_begin
# from pathlib import Path
# copybara:replace_end
from pathlib import Path
import payload_generator_pb2 as pg

# copybara:strip_begin(internal-blaze-run)
_PATH = 'google3/third_party/java_src/tsunami/plugin/src/main/resources/com/google/tsunami/plugin/payload/payload_definitions.yaml'
# copybara:strip_end_and_replace_begin
# _PATH = '../../plugin/src/main/resources/com/google/tsunami/plugin/payload/payload_definitions.yaml'
# copybara:replace_end
_PATH = '../../plugin/src/main/resources/com/google/tsunami/plugin/payload/payload_definitions.yaml'

def get_parsed_payload() -> list[pg.PayloadDefinition]:
"""Get payload from payload_definitions.yaml.
Expand All @@ -31,11 +23,7 @@ def get_parsed_payload() -> list[pg.PayloadDefinition]:
- Payload that uses validation regex but does not specify the regex to
be used.
"""
# copybara:strip_begin(internal-blaze-run)
payload_str = str(resources.GetResource(_PATH, 'r'))
# copybara:strip_end_and_replace_begin
# payload_str = Path(_PATH).read_text()
# copybara:replace_end
payload_str = Path(_PATH).read_text()
payload_dict = yaml.safe_load(payload_str)
payload_library = json_format.ParseDict(payload_dict, pg.PayloadLibrary())
return _validate_payloads([p for p in payload_library.payloads])
Expand Down
10 changes: 1 addition & 9 deletions plugin_server/py/plugin_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ def main(unused_argv):

# Load plugins from tsunami_plugins repository.
plugin_pkg = importlib.import_module(
# copybara:strip_begin(internal-blaze-run)
'py_plugins'
# copybara:strip_end_and_replace_begin
# 'py_plugins'
# copybara:replace_end
)
_import_py_plugins(plugin_pkg)

Expand Down Expand Up @@ -186,8 +182,4 @@ def _set_health_service_to_serving(server, health_servicer):

if __name__ == '__main__':
flags.set_default(logging.ALSOLOGTOSTDERR, True)
# copybara:strip_begin(internal-blaze-run)
app.run(main, change_root_and_user=False)
# copybara:strip_end_and_replace_begin
# app.run(main)
# copybara:replace_end
app.run(main)

0 comments on commit be0f223

Please sign in to comment.