UpdatePaths: Handle lists containing strings (#62595)

* UpdatePaths: Handle lists containing strings

The split_re regex considers two alternatives when splitting out property
values.
The first alternative, "(?:.+?)" looks for a value that starts and
ends with a double quote, containing any characters between, but using
the smallest length possible.
The second alternative, [^";]* looks for a value that does not contain
any double quotes or semicolons.

Neither of these cases will handle a value such as network = list("fsc");

To handle this case without a major rewrite, the second alternative is
updated to [^"][^;]+ which looks for a value that does not start with a
double quote and does not contain a semicolon.

* UpdatePaths Support @OLD;... too

This strips the trailing semicolon, if present, which it will be if
you're overriding an old value after specifying @OLD.

* UpdatePaths: Handle single char case

Whoops
This commit is contained in:
esainane
2021-11-17 09:38:32 +13:00
committed by GitHub
parent f9f3136fcd
commit def9f08b4b
+1 -1
View File
@@ -27,7 +27,7 @@ default_map_directory = "../../_maps"
replacement_re = re.compile(r'\s*(?P<path>[^{]*)\s*(\{(?P<props>.*)\})?')
#urgent todo: replace with actual parser, this is slow as janitor in crit
split_re = re.compile(r'((?:[A-Za-z0-9_\-$]+)\s*=\s*(?:"(?:.+?)"|[^";]*)|@OLD)')
split_re = re.compile(r'((?:[A-Za-z0-9_\-$]+)\s*=\s*(?:"(?:.+?)"|[^";][^;]*)|@OLD);?')
def props_to_string(props):