refactor: centralize output generation in TemplateManager#87
Conversation
Refactor API handler to improve formatting and add write_output method for CSV/JSON.
drkrillo
left a comment
There was a problem hiding this comment.
Great implementation!
I like that you deleted the unnecesary imports in the update_issues.py.
Also the improved readability in the new static method for CSV headers.
Thanks for also taking the tame to improve some other things here. Like new lines for better readability in toher funcitons, and deleting the tabs in render_template function
Thanks for contributing!
| @@ -121,24 +122,61 @@ def render_template(csv_path, template_path, today): | |||
|
|
|||
| with open(csv_path, newline='', encoding='utf-8') as f: | |||
| reader = csv.DictReader(f) | |||
|
|
|||
| for row in reader: | |||
| results.append({ | |||
| 'repo': row['repo'], | |||
| 'repo': row['repo'], | |||
| 'language': row['language'], | |||
| 'title': row['title'], | |||
| 'url': row['url'], | |||
| 'title': row['title'], | |||
| 'url': row['url'], | |||
There was a problem hiding this comment.
I like that you deleted those unnecesary tabs there!
|
|
||
| return rendered_readme | ||
|
|
||
| @staticmethod |
There was a problem hiding this comment.
Perfect implementation with the static method, and improved readability in the CSV columns by using new lines instead all in the same one!
|
|
||
| if args.output: | ||
| write_output(formatted_response, args.output) | ||
| TemplateManager.write_output(formatted_response, args.output) |
There was a problem hiding this comment.
Perfect call for a static method here!
Summary
Refactored output generation responsibilities by moving
write_outputfromupdate_issues.pyintoTemplateManagerto better centralize rendering and output-related functionality.Changes Made
write_outputintoTemplateManagerupdate_issues.pyto useTemplateManager.write_output(...)update_issues.pyWhy
This aligns output generation responsibilities with the existing rendering architecture, making the codebase cleaner, more maintainable, and easier to extend.