mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 09:17:50 -06:00
Format lists and dicts of a single item onto one line
example: "dict": { "value": 10 } becomes "dict": { "value": 10 }
This commit is contained in:
parent
a470f02373
commit
ad7e719146
3 changed files with 17 additions and 2 deletions
|
@ -49,7 +49,11 @@ def formatFile(file: Path, settings) -> None:
|
|||
content = newline.sub(r"\1\2:\1{", content)
|
||||
|
||||
if settings["format"].get("format-definition-single-value-single-line", True):
|
||||
pass # TODO: format entries in the override section which only define a single value to be on one line
|
||||
single_value_dict = re.compile(r"(:)(\s*\n?.*\{\s+)(\".*)(\d*\s*\})(\s*)(,?)")
|
||||
content = single_value_dict.sub(r"\1 { \3 }\6", content)
|
||||
|
||||
single_value_list = re.compile(r"(:)(\s*\n?.*\[\s+)(\".*)(\d*\s*\])(\s*)(,?)")
|
||||
content = single_value_list.sub(r"\1 [ \3 ]\6", content)
|
||||
|
||||
if settings["format"].get("format-definition-paired-coordinate-array", True):
|
||||
paired_coordinates = re.compile(r"(\[)\s+(-?\d*),\s*(-?\d*)\s*(\])")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue