MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / _encode_extension

Function _encode_extension

py/selenium/webdriver/remote/webdriver.py:128–139  ·  view source on GitHub ↗

Return the extension at `path` as a base64-encoded archive. A directory is zipped with its contents at the archive root, a file is read as-is, and anything else is assumed to already be base64-encoded bytes.

(path: str)

Source from the content-addressed store, hash-verified

126
127
128def _encode_extension(path: str) -> str:
129 """Return the extension at `path` as a base64-encoded archive.
130
131 A directory is zipped with its contents at the archive root, a file is read
132 as-is, and anything else is assumed to already be base64-encoded bytes.
133 """
134 if os.path.isdir(path):
135 return _zip_directory(path, root=path)
136 if os.path.isfile(path):
137 with open(path, "rb") as extension:
138 return base64.b64encode(extension.read()).decode("utf-8")
139 return path
140
141
142def import_cdp() -> None:

Callers 2

_web_extension_dataMethod · 0.85

Calls 3

_zip_directoryFunction · 0.85
decodeMethod · 0.65
readMethod · 0.65

Tested by

no test coverage detected