summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-06-27 22:25:36 +0100
committerBenjamin Schubert <contact@benschubert.me>2019-06-27 22:25:36 +0100
commitdb839e8d3ac27fa61634b7da75265b28ac32a7ce (patch)
tree1854bfd486bc9a1617529f21d49c2390d6c5c26d
parent9b645e237f0f1adb8ca871257d3271d51bc668c6 (diff)
downloadbuildstream-bschubert/no-sanitize.tar.gz
-rw-r--r--src/buildstream/_frontend/widget.py11
-rw-r--r--src/buildstream/_workspaces.py2
-rw-r--r--src/buildstream/_yaml.pyx19
3 files changed, 21 insertions, 11 deletions
diff --git a/src/buildstream/_frontend/widget.py b/src/buildstream/_frontend/widget.py
index dce63e14f..b9f534559 100644
--- a/src/buildstream/_frontend/widget.py
+++ b/src/buildstream/_frontend/widget.py
@@ -393,31 +393,28 @@ class LogLine(Widget):
# Element configuration
if "%{config" in format_:
- config = _yaml.node_sanitize(element._Element__config)
line = p.fmt_subst(
line, 'config',
- yaml.round_trip_dump(config, default_flow_style=False, allow_unicode=True))
+ yaml.round_trip_dump(element._Element__config, default_flow_style=False, allow_unicode=True))
# Variables
if "%{vars" in format_:
- variables = _yaml.node_sanitize(element._Element__variables.flat)
+ variables = element._Element__variables.flat
line = p.fmt_subst(
line, 'vars',
yaml.round_trip_dump(variables, default_flow_style=False, allow_unicode=True))
# Environment
if "%{env" in format_:
- environment = _yaml.node_sanitize(element._Element__environment)
line = p.fmt_subst(
line, 'env',
- yaml.round_trip_dump(environment, default_flow_style=False, allow_unicode=True))
+ yaml.round_trip_dump(element._Element__environment, default_flow_style=False, allow_unicode=True))
# Public
if "%{public" in format_:
- environment = _yaml.node_sanitize(element._Element__public)
line = p.fmt_subst(
line, 'public',
- yaml.round_trip_dump(environment, default_flow_style=False, allow_unicode=True))
+ yaml.round_trip_dump(element._Element__public, default_flow_style=False, allow_unicode=True))
# Workspaced
if "%{workspaced" in format_:
diff --git a/src/buildstream/_workspaces.py b/src/buildstream/_workspaces.py
index 3847c7a85..12ddf466a 100644
--- a/src/buildstream/_workspaces.py
+++ b/src/buildstream/_workspaces.py
@@ -114,7 +114,7 @@ class WorkspaceProject():
def load(cls, directory):
workspace_file = os.path.join(directory, WORKSPACE_PROJECT_FILE)
if os.path.exists(workspace_file):
- data_dict = _yaml.node_sanitize(_yaml.roundtrip_load(workspace_file), dict_type=dict)
+ data_dict = _yaml.roundtrip_load(workspace_file)
return cls.from_dict(directory, data_dict)
else:
return None
diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx
index 0de3d46f6..1dcdca048 100644
--- a/src/buildstream/_yaml.pyx
+++ b/src/buildstream/_yaml.pyx
@@ -1318,7 +1318,7 @@ def _list_final_assertions(Node values):
# are required to be symbols.
#
# Args:
-# provenance (Provenance): The provenance of the loaded symbol, or None
+# provenance (Provenance): The provenannoce of the loaded symbol, or None
# symbol_name (str): The loaded symbol name
# purpose (str): The purpose of the string, for an error message
# allow_dashes (bool): Whether dashes are allowed for this symbol
@@ -1425,12 +1425,25 @@ cdef bint _walk_dict_node(MappingNode node, list path, Node target):
###############################################################################
+def represent_mapping(self, MappingNode mapping):
+ return self.represent_dict(mapping.value)
+
+def represent_scalar(self, ScalarNode scalar):
+ return self.represent_str(scalar.value)
+
+def represent_sequence(self, SequenceNode sequence):
+ return self.represent_list(sequence.value)
+
+
# Roundtrip code
# Always represent things consistently:
-yaml.RoundTripRepresenter.add_representer(OrderedDict,
- yaml.SafeRepresenter.represent_dict)
+yaml.RoundTripRepresenter.add_representer(OrderedDict, yaml.SafeRepresenter.represent_dict)
+yaml.RoundTripRepresenter.add_representer(MappingNode, represent_mapping)
+yaml.RoundTripRepresenter.add_representer(ScalarNode, represent_scalar)
+yaml.RoundTripRepresenter.add_representer(SequenceNode, represent_sequence)
+
# Always parse things consistently