66import shlex
77import sys
88import os
9+ import re
910
1011rust_dir = os .path .dirname (os .path .abspath (__file__ ))
1112rust_dir = os .path .dirname (rust_dir )
@@ -589,11 +590,17 @@ def parse_example_config(known_args, config):
589590 with open (rust_dir + "/bootstrap.example.toml" ) as example_config :
590591 example_lines = example_config .read ().split ("\n " )
591592 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 )
597604 if line .startswith ("[" ):
598605 cur_section = line [1 :- 1 ]
599606 if cur_section .startswith ("target" ):
@@ -605,7 +612,8 @@ def parse_example_config(known_args, config):
605612 sections [cur_section ] = [line ]
606613 section_order .append (cur_section )
607614 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 ))
609617
610618 # Fill out the `targets` array by giving all configured targets a copy of the
611619 # `target` section we just loaded from the example config
0 commit comments