Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sexadecimal number regex #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compose_format/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -112,7 +113,7 @@ def fix_sexadecimal_numbers(value):
import re

SEXADECIMAL_NUMBER = '(?P<left>\d+):(?P<right>\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')))
Expand Down