Line-wrap projects.yaml but strip trailing spaces

This restores ruamel's new line-wrapping behavior, but corrects the
trailing spaces that it leaves by stripping them in our customized
output routine.

Change-Id: I795994657abb3d706c2a0725c5955e15e5c067ba
This commit is contained in:
James E. Blair
2025-09-08 09:27:05 -07:00
parent e6fcbe8939
commit 603163a2f7
2 changed files with 1309 additions and 826 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import sys
import ruamel.yaml import ruamel.yaml
@@ -29,9 +27,6 @@ class YAML(object):
self.yaml.allow_duplicate_keys = True self.yaml.allow_duplicate_keys = True
self.yaml.representer.add_representer(type(None), none_representer) self.yaml.representer.add_representer(type(None), none_representer)
self.yaml.indent(mapping=2, sequence=4, offset=2) self.yaml.indent(mapping=2, sequence=4, offset=2)
# Ruamel does weird things with linewrapping like adding extra
# whitespace at the end of lines. Just avoid wrapping entirely.
self.yaml.width = sys.maxsize
def load(self, stream): def load(self, stream):
return self.yaml.load(stream) return self.yaml.load(stream)
@@ -41,9 +36,9 @@ class YAML(object):
newlines = [] newlines = []
for line in x.split('\n'): for line in x.split('\n'):
if '#' in line: if '#' in line:
newlines.append(line) newlines.append(line.rstrip())
else: else:
newlines.append(line[2:]) newlines.append(line[2:].rstrip())
return '\n'.join(newlines) return '\n'.join(newlines)
def dump(self, data, *args, **kwargs): def dump(self, data, *args, **kwargs):