diff --git a/requirements.txt b/requirements.txt index fc4dd84..a05f62d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,14 @@ +certifi==2025.4.26 +charset-normalizer==3.4.1 fastcore==1.8.1 ghapi==1.0.6 +idna==3.10 Jinja2==3.1.6 +markdown-it-py==3.0.0 MarkupSafe==3.0.2 +mdurl==0.1.2 packaging==25.0 +Pygments==2.19.1 +requests==2.32.3 +rich==14.0.0 +urllib3==2.4.0 diff --git a/commons/static_site_generator.py b/src/static_site_generator.py similarity index 97% rename from commons/static_site_generator.py rename to src/static_site_generator.py index 70e94ed..c2ee73a 100644 --- a/commons/static_site_generator.py +++ b/src/static_site_generator.py @@ -1,23 +1,7 @@ from jinja2 import Environment, FileSystemLoader -def generate_site(data, output_file='./_site/index.html'): - env = Environment(loader=FileSystemLoader('templates')) - template = env.get_template('kaban_board.html') - - # Extract unique statuses from the tasks list - unique_statuses = sorted({task["status"] for task in data["tasks"]}) - - # Add statuses to the data dictionary - data_with_statuses = {**data, "statuses": unique_statuses} - - # Render template with updated data - output = template.render(data_with_statuses) - - with open(output_file, 'w') as f: - f.write(output) - # Example data -data = { +dummy_data = { 'title': 'Version Two', 'github_user': 'octocat', 'team': 'Platform Engineering', @@ -110,4 +94,19 @@ def generate_site(data, output_file='./_site/index.html'): ] } -generate_site(data) +def generate_site(data=dummy_data, output_file='./_site/index.html'): + env = Environment(loader=FileSystemLoader('templates')) + template = env.get_template('kaban_board.html') + + # Extract unique statuses from the tasks list + unique_statuses = sorted({task["status"] for task in data["tasks"]}) + + # Add statuses to the data dictionary + data_with_statuses = {**data, "statuses": unique_statuses} + + # Render template with updated data + output = template.render(data_with_statuses) + + with open(output_file, 'w') as f: + f.write(output) + diff --git a/src/version2config.py b/src/version2config.py index b4b2732..9b7f5a6 100644 --- a/src/version2config.py +++ b/src/version2config.py @@ -1,8 +1,19 @@ import argparse - +import logging +import os class VersionTwoConfig: + + # LOGGER VARIABLES + LOG_LEVEL = logging.INFO + LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s' + def __init__(self): + self.init_parser() + self.init_logger() + self.load_env() + + def init_parser(self): parser = argparse.ArgumentParser( prog='VersionTwo', description="Render an HTML page from a collection of GitHub Issues and Pull Requests" @@ -100,15 +111,22 @@ def __init__(self): self.exclude_label = parsed_args.exclude_label self.publish_board = parsed_args.publish_board + + def init_logger(self): + logging.basicConfig(level=self.LOG_LEVEL, format=self.LOG_FORMAT) + + def load_env(self): + self.GITHUB_PAT = os.getenv("GITHUB_PAT") if os.getenv("GITHUB_PAT") else None + def display_config(self): - print("Configuration:") - print(f"Include User: {self.include_user}") - print(f"Include Repository: {self.include_repository}") - print(f"Include Organization/Repository: {self.include_organization_repository}") - print(f"Include Label: {self.include_label}") - print(f"Exclude Organization: {self.exclude_organization}") - print(f"Exclude Repository: {self.exclude_repository}") - print(f"Exclude Organization/Repository: {self.exclude_organization_repository}") - print(f"Exclude User: {self.exclude_user}") - print(f"Exclude Label: {self.exclude_label}") - print(f"Publish Board: {self.publish_board}") + logging.info("Configuration:") + logging.info(f"Include User: {self.include_user}") + logging.info(f"Include Repository: {self.include_repository}") + logging.info(f"Include Organization/Repository: {self.include_organization_repository}") + logging.info(f"Include Label: {self.include_label}") + logging.info(f"Exclude Organization: {self.exclude_organization}") + logging.info(f"Exclude Repository: {self.exclude_repository}") + logging.info(f"Exclude Organization/Repository: {self.exclude_organization_repository}") + logging.info(f"Exclude User: {self.exclude_user}") + logging.info(f"Exclude Label: {self.exclude_label}") + logging.info(f"Publish Board: {self.publish_board}") diff --git a/version2.py b/version2.py index bca1cc1..c73d975 100644 --- a/version2.py +++ b/version2.py @@ -1,10 +1,12 @@ from src.version2config import VersionTwoConfig +from src.static_site_generator import generate_site def main(): config = VersionTwoConfig() config.display_config() + generate_site() if __name__ == "__main__": main()