From 45d682c4467c52e63a1fea92e0c6249b3722a42f Mon Sep 17 00:00:00 2001 From: Thomas Staudinger Date: Thu, 16 May 2024 00:45:53 +0200 Subject: [PATCH] ybump/yupdate: Adjust to ruamel 0.18 API Signed-off-by: Thomas Staudinger --- ybump | 13 ++++++++----- yupdate | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ybump b/ybump index 76f3d5a..19ad377 100755 --- a/ybump +++ b/ybump @@ -11,7 +11,7 @@ # (at your option) any later version. # import sys -import ruamel.yaml +from ruamel.yaml import YAML def usage(msg=None, ex=1): @@ -28,14 +28,17 @@ if __name__ == "__main__": with open(sys.argv[1]) as fp: lines = fp.readlines() fp.seek(0) - data = ruamel.yaml.round_trip_load(fp) + yaml = YAML() + data = yaml.load(fp) data['release'] += 1 maxwidth = len(max(lines, key=len)) try: with open(sys.argv[1], 'w') as fp: - ruamel.yaml.round_trip_dump( - data, fp, indent=4, block_seq_indent=4, width=maxwidth, - top_level_colon_align=True, prefix_colon=' ') + yaml.indent(mapping=4, sequence=4, offset=4) + yaml.top_level_colon_align = True + yaml.prefix_colon = ' ' + yaml.width = maxwidth + yaml.dump(data, fp) except Exception as e: print("Error writing file, may need to reset it.") print(e) diff --git a/yupdate b/yupdate index 5053a96..645c066 100755 --- a/yupdate +++ b/yupdate @@ -13,10 +13,10 @@ import argparse import sys -import ruamel.yaml import os import subprocess import pisi.version +from ruamel.yaml import YAML parser = argparse.ArgumentParser() parser.add_argument("version", type=str, help="new version of package") @@ -94,7 +94,8 @@ if __name__ == "__main__": with open(ymlfile, "r") as infile: lines = infile.readlines() infile.seek(0) - data = ruamel.yaml.round_trip_load(infile) + yaml = YAML() + data = yaml.load(infile) data['source'] = sources = [] sources.append(source) if args.nb is not None: @@ -104,9 +105,11 @@ if __name__ == "__main__": try: with open(ymlfile, 'w') as fp: - ruamel.yaml.round_trip_dump( - data, fp, indent=4, block_seq_indent=4, width=maxwidth, - top_level_colon_align=True, prefix_colon=' ') + yaml.indent(mapping=4, sequence=4, offset=4) + yaml.top_level_colon_align = True + yaml.prefix_colon = ' ' + yaml.width = maxwidth + yaml.dump(data, fp) except Exception as e: print("Error writing file, may need to reset it.") print(e)