Bug 1804178 - [4/6] Remove pytoml output postprocessing r=glandium

The postprocessing phase that cleaned up `pytoml`'s output has little
effect on `toml`'s output, which is already largely clean. Remove the
additional code.

Differential Revision: https://phabricator.services.mozilla.com/D164153
This commit is contained in:
Ray Kraesig 2022-12-20 23:01:25 +00:00
parent 2ba26991d4
commit 665483f331
2 changed files with 2 additions and 12 deletions

View file

@ -115,6 +115,7 @@ git = "https://github.com/smol-rs/async-task"
rev = "f6488e35beccb26eb6e85847b02aa78a42cd3d0e"
replace-with = "vendored-sources"
# Take advantage of the fact that cargo will treat lines starting with #
# as comments to add preprocessing directives. This file can thus by copied
# as-is to $topsrcdir/.cargo/config with no preprocessing to be used there

View file

@ -885,22 +885,11 @@ license file's hash.
mozpath.normsep(os.path.normcase(self.topsrcdir)),
)
# Normalize pytoml output:
# - removing empty lines
# - remove empty [section]
def toml_dump(data):
dump = toml.dumps(data)
if isinstance(data, dict):
for k, v in data.items():
if all(isinstance(v2, dict) for v2 in v.values()):
dump = dump.replace("[%s]" % k, "")
return dump.strip()
cargo_config = os.path.join(self.topsrcdir, ".cargo", "config.in")
with open(cargo_config, "w", encoding="utf-8", newline="\n") as fh:
fh.write(
CARGO_CONFIG_TEMPLATE.format(
config=toml_dump(config),
config=toml.dumps(config),
replace_name=replace_name,
directory=replace["directory"],
)