MCPcopy
hub / github.com/pex-tool/pex / encode

Method encode

package/scie_config.py:92–122  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

90 )
91
92 def encode(self) -> str:
93 pbs_releases: Counter[str] = Counter()
94 python_versions: Counter[str] = Counter()
95 for platform_config in self.platforms:
96 pbs_releases[platform_config.pbs_release] += 1
97 python_versions[platform_config.python_version] += 1
98 default_pbs_release, _count = pbs_releases.most_common(n=1)[0]
99 default_python_version, _count = python_versions.most_common(n=1)[0]
100
101 platforms = {}
102 for platform_config in self.platforms:
103 data: dict[str, Any] = {}
104 if platform_config.pbs_release != default_pbs_release:
105 data["pbs-release"] = platform_config.pbs_release
106 if platform_config.python_version != default_python_version:
107 data["python-version"] = platform_config.python_version
108 if not platform_config.required:
109 data["required"] = False
110 platforms[platform_config.name] = data
111
112 return base64.urlsafe_b64encode(
113 json.dumps(
114 {
115 "pbs-release": default_pbs_release,
116 "python-version": default_python_version,
117 "pex-extras": self.pex_extras,
118 "extra-lock-args": self.extra_lock_args,
119 "platforms": platforms,
120 }
121 ).encode()
122 ).decode("ascii")

Callers 15

fingerprint_cache_inputsFunction · 0.45
mainFunction · 0.45
test_to_unicodeFunction · 0.45
do_GETMethod · 0.45
createMethod · 0.45
test_pex.pyFile · 0.45
test_execute_replFunction · 0.45
test_checkFunction · 0.45

Calls 1

decodeMethod · 0.80

Tested by 15

test_to_unicodeFunction · 0.36
do_GETMethod · 0.36
createMethod · 0.36
test_execute_replFunction · 0.36
test_checkFunction · 0.36
expect_banner_headerFunction · 0.36
expect_banner_footerFunction · 0.36
test_pex_cli_no_argsFunction · 0.36