3
3
# ignore-tidy-linelength
4
4
5
5
from __future__ import absolute_import , division , print_function
6
+ import shlex
6
7
import sys
7
8
import os
8
9
rust_dir = os .path .dirname (os .path .abspath (__file__ ))
@@ -290,7 +291,7 @@ def set(key, value, config):
290
291
if isinstance (value , list ):
291
292
# Remove empty values, which value.split(',') tends to generate and
292
293
# replace single quotes for double quotes to ensure correct parsing.
293
- value = [v . replace ( ' \' ' , '"' ) for v in value if v ]
294
+ value = [v for v in value if v ]
294
295
295
296
s = "{:20} := {}" .format (key , value )
296
297
if len (s ) < 70 or VERBOSE :
@@ -300,23 +301,10 @@ def set(key, value, config):
300
301
301
302
arr = config
302
303
303
- # Split on periods unless the block is quoted.
304
- parts = []
305
- current_part = ''
306
- within_quotes = False
307
- for character in key :
308
- if character in ['"' , '\' ' ]:
309
- within_quotes = not within_quotes
310
- elif character == '.' and not within_quotes :
311
- parts .append (current_part )
312
- current_part = ''
313
- else :
314
- current_part += character
315
- else :
316
- if current_part :
317
- parts .append (current_part )
318
- if within_quotes :
319
- raise RuntimeError ('end quote not found in arguments.' )
304
+ # Split `key` on periods using shell semantics.
305
+ lexer = shlex .shlex (key , punctuation_chars = True , posix = True )
306
+ lexer .whitespace = "."
307
+ parts = list (lexer )
320
308
321
309
for i , part in enumerate (parts ):
322
310
if i == len (parts ) - 1 :
0 commit comments