use list unpacking to simplify for loop references

pull/9348/head
Eli Schwartz 3 years ago
parent 4ab70c5512
commit 47ae0b82f0
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 9
      mesonbuild/mintro.py

@ -492,14 +492,15 @@ updated_introspection_files = [] # type: T.List[str]
def write_intro_info(intro_info: T.Sequence[T.Tuple[str, T.Union[dict, T.List[T.Any]]]], info_dir: str) -> None: def write_intro_info(intro_info: T.Sequence[T.Tuple[str, T.Union[dict, T.List[T.Any]]]], info_dir: str) -> None:
global updated_introspection_files global updated_introspection_files
for i in intro_info: for kind, data in intro_info:
out_file = os.path.join(info_dir, 'intro-{}.json'.format(i[0])) print(f'processing {kind}, {data}')
out_file = os.path.join(info_dir, f'intro-{kind}.json')
tmp_file = os.path.join(info_dir, 'tmp_dump.json') tmp_file = os.path.join(info_dir, 'tmp_dump.json')
with open(tmp_file, 'w', encoding='utf-8') as fp: with open(tmp_file, 'w', encoding='utf-8') as fp:
json.dump(i[1], fp) json.dump(data, fp)
fp.flush() # Not sure if this is needed fp.flush() # Not sure if this is needed
os.replace(tmp_file, out_file) os.replace(tmp_file, out_file)
updated_introspection_files += [i[0]] updated_introspection_files += [kind]
def generate_introspection_file(builddata: build.Build, backend: backends.Backend) -> None: def generate_introspection_file(builddata: build.Build, backend: backends.Backend) -> None:
coredata = builddata.environment.get_coredata() coredata = builddata.environment.get_coredata()

Loading…
Cancel
Save