From 3ddd89774f6635b5612b72439055f6f618eac23e Mon Sep 17 00:00:00 2001 From: Doyno Gretchenliev Date: Sat, 7 Dec 2019 16:50:57 +0200 Subject: [PATCH 1/2] fix sexadecimal number regex --- compose_format/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose_format/__init__.py b/compose_format/__init__.py index d356c89..40ab03b 100755 --- a/compose_format/__init__.py +++ b/compose_format/__init__.py @@ -112,7 +112,7 @@ def fix_sexadecimal_numbers(value): import re SEXADECIMAL_NUMBER = '(?P\d+):(?P\d+)' - match = re.match(SEXADECIMAL_NUMBER, value) + match = re.match(SEXADECIMAL_NUMBER, str(value)) if not match or int(match.group('left')) > 60 or int(match.group('right')) > 60: return value return SingleQuotedScalarString('{0}:{1}'.format(match.group('left'), match.group('right'))) From 23073f907093cce8551bdb8d02a2818e1cd89164 Mon Sep 17 00:00:00 2001 From: Doyno Gretchenliev Date: Sat, 7 Dec 2019 17:26:36 +0200 Subject: [PATCH 2/2] block_seq_indent set to 2 to fix formatting on popular editing tools --- compose_format/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compose_format/__init__.py b/compose_format/__init__.py index 40ab03b..2167bde 100755 --- a/compose_format/__init__.py +++ b/compose_format/__init__.py @@ -77,7 +77,8 @@ def format(self, path, replace=False, strict=True): def format_string(self, data, replace=False, strict=True): data = self.reorder(load(data, RoundTripLoader), strict=strict) - formatted = dump(data, Dumper=RoundTripDumper, indent=2, width=120) + formatted = dump(data, Dumper=RoundTripDumper, + indent=2, block_seq_indent=2, width=120) return formatted.strip() + '\n'