Skip to content

Commit

Permalink
Add action to restore generated files from git repository
Browse files Browse the repository at this point in the history
  • Loading branch information
kvid committed Jul 20, 2020
1 parent 9ad3e13 commit d4feae6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/wireviz/build_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ def clean_examples():
os.remove(filename)


def restore_generated():
for key, value in paths.items():
# collect input YAML files
filename_list = collect_filenames('Restoring', key, input_extensions)
# collect files to restore
filename_list = [fn.with_suffix(ext) for fn in filename_list for ext in generated_extensions]
filename_list.append(value['path'] / readme)
# restore files
for filename in filename_list:
cmd = f'git checkout -- {filename}'
print(f' {cmd}')
os.system(cmd)


def parse_args():
parser = argparse.ArgumentParser(description='Wireviz Example Manager',)
parser.add_argument('action', nargs='?', action='store', default='build')
Expand All @@ -105,6 +119,8 @@ def main():
build('tutorial', build_readme = True, include_source = True, include_readme = True)
elif args.action == 'clean':
clean_examples()
elif args.action == 'restore':
restore_generated()


if __name__ == '__main__':
Expand Down

0 comments on commit d4feae6

Please sign in to comment.