|
|
@ -1102,14 +1102,18 @@ class MachineFileParser(): |
|
|
|
self.sections: T.Dict[str, T.Dict[str, T.Union[str, bool, int, T.List[str]]]] = {} |
|
|
|
self.sections: T.Dict[str, T.Dict[str, T.Union[str, bool, int, T.List[str]]]] = {} |
|
|
|
|
|
|
|
|
|
|
|
for fname in filenames: |
|
|
|
for fname in filenames: |
|
|
|
with open(fname, encoding='utf-8') as f: |
|
|
|
try: |
|
|
|
content = f.read() |
|
|
|
with open(fname, encoding='utf-8') as f: |
|
|
|
content = content.replace('@GLOBAL_SOURCE_ROOT@', sourcedir) |
|
|
|
content = f.read() |
|
|
|
content = content.replace('@DIRNAME@', os.path.dirname(fname)) |
|
|
|
except UnicodeDecodeError as e: |
|
|
|
try: |
|
|
|
raise EnvironmentException(f'Malformed machine file {fname!r} failed to parse as unicode: {e}') |
|
|
|
self.parser.read_string(content, fname) |
|
|
|
|
|
|
|
except configparser.Error as e: |
|
|
|
content = content.replace('@GLOBAL_SOURCE_ROOT@', sourcedir) |
|
|
|
raise EnvironmentException(f'Malformed machine file: {e}') |
|
|
|
content = content.replace('@DIRNAME@', os.path.dirname(fname)) |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
self.parser.read_string(content, fname) |
|
|
|
|
|
|
|
except configparser.Error as e: |
|
|
|
|
|
|
|
raise EnvironmentException(f'Malformed machine file: {e}') |
|
|
|
|
|
|
|
|
|
|
|
# Parse [constants] first so they can be used in other sections |
|
|
|
# Parse [constants] first so they can be used in other sections |
|
|
|
if self.parser.has_section('constants'): |
|
|
|
if self.parser.has_section('constants'): |
|
|
|