Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save To Option in Create Report #57

Merged
merged 3 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Quorum/auto_report/create_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description='This tool generates automatic proposal reports.')
parser.add_argument('--proposal_id', required=True, type=int, help='The proposal id to generate report to.')
parser.add_argument('--template', default=DEFAULT_TEMPLATE_PATH, help='The report template to use.')
parser.add_argument('--generate_report_path', type=Path, help='Specify where to save the report.')

args = parser.parse_args()

if not Path(args.template).exists():
raise FileNotFoundError(f'could not find template at {args.template}.')

if args.generate_report_path is None:
args.generate_report_path = Path(f'v3-{args.proposal_id}.md')

return parser.parse_args()
return args


def create_report(proposal_id: int, template: Path):
def create_report(proposal_id: int, template: Path, generate_report_path: Path):
pprinter.pretty_print(f'Generating a report using template in {template}', pprinter.Colors.INFO)
env = Environment(loader=FileSystemLoader(template.parent))
env.globals.update(zip=zip)
Expand All @@ -35,15 +39,15 @@ def create_report(proposal_id: int, template: Path):

report = template.render(tags)

with open((report_path:=f'v3-{proposal_id}.md'), 'w') as f:
with open(generate_report_path, 'w') as f:
f.write(report)

pprinter.pretty_print(f'Created report at {report_path}.', pprinter.Colors.SUCCESS)
pprinter.pretty_print(f'Created report at {generate_report_path}.', pprinter.Colors.SUCCESS)


def main():
args = parse_args()
create_report(args.proposal_id, args.template)
create_report(args.proposal_id, args.template, args.generate_report_path)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion Quorum/tests/test_auto_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_auto_report():
with open(EXPECTED_DIR / 'v3-132.md') as f:
expected = f.read()

create_report.create_report(132, create_report.DEFAULT_TEMPLATE_PATH)
create_report.create_report(132, create_report.DEFAULT_TEMPLATE_PATH, Path('v3-132.md'))
with open(Path('v3-132.md')) as f:
actual = f.read()

Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20241231.143248.434517
20241231.145836.988868
Loading