Commit a2d54aad authored by Peter Hutterer's avatar Peter Hutterer
Browse files

Replace a list comprehension with a yield function


Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 98f55779
...@@ -36,10 +36,12 @@ if __name__ == '__main__': ...@@ -36,10 +36,12 @@ if __name__ == '__main__':
ci_folder.mkdir(exist_ok=True) ci_folder.mkdir(exist_ok=True)
globals_file = config_folder / 'ci-globals.yml' globals_file = config_folder / 'ci-globals.yml'
def is_distribution_file(f): def distribution_files():
return f.name.endswith('.yml') and not f.name.startswith('ci-') for f in config_folder.iterdir():
if f.name.endswith('.yml') and not f.name.startswith('ci-'):
yield f
for distrib in [x for x in config_folder.iterdir() if is_distribution_file(x)]: for distrib in distribution_files():
name = distrib.name[:-4] # drop .yml name = distrib.name[:-4] # drop .yml
# generate the distribution's template file, # generate the distribution's template file,
...@@ -92,7 +94,7 @@ if __name__ == '__main__': ...@@ -92,7 +94,7 @@ if __name__ == '__main__':
s = '", "'.join(sorted(set(remote_images))) s = '", "'.join(sorted(set(remote_images)))
new_config.write(f'remote_images: ["{s}"]\n'.encode('utf8')) new_config.write(f'remote_images: ["{s}"]\n'.encode('utf8'))
distributions = [d.name[:-4] for d in config_folder.iterdir() if is_distribution_file(d)] distributions = [d.name[:-4] for d in distribution_files()]
s = '", "'.join(sorted(set(distributions))) s = '", "'.join(sorted(set(distributions)))
new_config.write(f'distribs: ["{s}"]\n'.encode('utf8')) new_config.write(f'distribs: ["{s}"]\n'.encode('utf8'))
new_config.flush() new_config.flush()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment