Skip to content

chore: Added config python module #15

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

Merged
merged 9 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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
35 changes: 17 additions & 18 deletions commons/static_site_generator.py → src/static_site_generator.py
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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)

42 changes: 30 additions & 12 deletions src/version2config.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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}")
5 changes: 5 additions & 0 deletions version2.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
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()