6
6
import shlex
7
7
import sys
8
8
import os
9
+ import re
9
10
10
11
rust_dir = os .path .dirname (os .path .abspath (__file__ ))
11
12
rust_dir = os .path .dirname (rust_dir )
@@ -589,11 +590,17 @@ def parse_example_config(known_args, config):
589
590
with open (rust_dir + "/bootstrap.example.toml" ) as example_config :
590
591
example_lines = example_config .read ().split ("\n " )
591
592
for line in example_lines :
592
- if cur_section is None :
593
- if line .count ("=" ) == 1 :
594
- top_level_key = line .split ("=" )[0 ]
595
- top_level_key = top_level_key .strip (" #" )
596
- top_level_keys .append (top_level_key )
593
+ if line .count ("=" ) == 1 and not line .startswith ("# " ):
594
+ key = line .split ("=" )[0 ]
595
+ key = key .strip (" #" )
596
+ parts = key .split ("." );
597
+ if len (parts ) > 1 :
598
+ cur_section = parts [0 ]
599
+ if not (cur_section in sections ):
600
+ sections [cur_section ] = ["[" + cur_section + "]" ]
601
+ section_order .append (cur_section )
602
+ elif cur_section is None :
603
+ top_level_keys .append (key )
597
604
if line .startswith ("[" ):
598
605
cur_section = line [1 :- 1 ]
599
606
if cur_section .startswith ("target" ):
@@ -605,7 +612,8 @@ def parse_example_config(known_args, config):
605
612
sections [cur_section ] = [line ]
606
613
section_order .append (cur_section )
607
614
else :
608
- sections [cur_section ].append (line )
615
+ # remove just the `section.` part from the line, if present.
616
+ sections [cur_section ].append (re .sub ("(#?)([a-zA-Z_-]+\\ .)?(.*)" , "\\ 1\\ 3" , line ))
609
617
610
618
# Fill out the `targets` array by giving all configured targets a copy of the
611
619
# `target` section we just loaded from the example config
0 commit comments