first commit

This commit is contained in:
2026-05-21 08:40:24 -04:00
commit b084545275
711 changed files with 3659856 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
# FILE: generate_center_trainings_topic_analysis_word.py
# CREATED: 1/12/25
# AUTHOR: Vincent Allen
# CONTACT: valle276@live.kutztown.edu vincent@vtallen.com
# Calls the word document builder with the necessary functions and files extracted from the target image door, to create a final word document for the center
# specific trainings analysis report.
# IMPORTANT: You must supply each center you want to show up in the center specific report using the -c flag for each.
# Ex: if you wanted just Kutztown and Clarion you would add the arguments "-c Kutztown -c Clarion"
# The names ARE case-sensitive
import argparse
from functools import partial
# import the word library
from pasbdc_word_library import WordDocumentBuilder, PageConfig
# import the word page generators
from section_3_word_library_module import center_topic_analysis_page_maker, center_topic_analysis_page_one_maker
from shared_tools_module import ImageRegistry, StatChartVariants, VARIANT_SUFFIX_MAP
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--images", required=True)
parser.add_argument("--reportname", required=False, help="The filename prefix identifying images for this report. Defaults to trainingsreport", default="trainingsreport")
parser.add_argument("--centerchartcategorybase", required=False, type=str, default="topicanalysis",
help="The chart category to use for the center specific graphs to find the chart images with ImageRegistry. The center name will be appended to the end of this value and should be the second part of the filename.")
parser.add_argument("-c", "--center", action='append', required=True, help="For each occurrence of the --center argument, the script will generate a per center trainings report and look for the appropriate images in the images directory." )
parser.add_argument("--output", required=True, help="The name to give the output file")
parser.add_argument("--fiscalyear", required=True, type=str, help="The fiscal year to use for the report")
args = parser.parse_args()
# Parse the image paths in the selected dir and build the dictionary
registry = ImageRegistry(args.images, args.reportname)
# Build all needed functions for the center specific reports
center_specific_page_funcs = []
for center in args.center:
try:
topic_event_count_chart=registry.get(f"{args.centerchartcategorybase}{center}",
VARIANT_SUFFIX_MAP[StatChartVariants.TOTAL_ATTENDED])
topic_event_percent_chart=registry.get(f"{args.centerchartcategorybase}{center}",
VARIANT_SUFFIX_MAP[StatChartVariants.PERCENT_ATTENDED])
topic_attendee_count_chart=registry.get(f"{args.centerchartcategorybase}{center}",
VARIANT_SUFFIX_MAP[StatChartVariants.TOTAL_COUNT])
topic_attendee_percent_chart=registry.get(f"{args.centerchartcategorybase}{center}",
VARIANT_SUFFIX_MAP[StatChartVariants.TOTAL_PERCENT])
except:
# The above statements would throw an exception if the could not find a particular center's graphs.
# This way, if a center did not have any trainings in the time frame of your data, the whole thing does not blow up
print(f"\tWARNING: No graphs found for center '{center}' for {args.fiscalyear}. Skipping.")
continue
# Use partial to fix the function arguments for each center page function. Let the Word document builder supply the shared constants
center_page_func = partial(
center_topic_analysis_page_maker,
center=center,
topic_event_count_chart=topic_event_count_chart,
topic_event_percent_chart=topic_event_percent_chart,
topic_attendee_count_chart=topic_attendee_count_chart,
topic_attendee_percent_chart=topic_attendee_percent_chart
)
center_specific_page_funcs.append(PageConfig(page_function=center_page_func, add_page_break=True))
print(f"\tBuilt page function for {center}")
builder = WordDocumentBuilder()
builder.create_document(
[
PageConfig(page_function=center_topic_analysis_page_one_maker, add_page_break=False)
] + center_specific_page_funcs,
args.output,
fiscal_year=args.fiscalyear,
section_number=7,
desk_review_section_number=1,
)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,135 @@
# FILE: generate_trainings_analysis_word.py
# CREATED: 2/12/25
# AUTHOR: Vincent Allen
# CONTACT: valle276@live.kutztown.edu vincent@vtallen.com
# Calls the Word document builder with the necessary functions and files extracted from the target image door, to create a final word document for the trainings analysis report (including the center specific topic analysis as well).
import argparse
from functools import partial
# import the word library
from pasbdc_word_library import WordDocumentBuilder, PageConfig
# import the word page generators
from section_1_word_library_module import *
# import the chart variants enum
from section_1_graph_library_module import ( # pyright:ignore
StatChartVariants
)
import argparse
from functools import partial
import os
# import the word library
from pasbdc_word_library import WordDocumentBuilder, PageConfig
# import the Word page generators
from section_3_word_library_module import center_topic_analysis_page_one_maker, center_trainings_analysis_page_one_maker
from shared_tools_module import ImageRegistry, StatChartVariants, VARIANT_SUFFIX_MAP
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--images", required=True)
parser.add_argument("--reportname", required=False, help="The filename prefix identifying images for this report. Defaults to trainingsreport", default="trainingsreport")
parser.add_argument("--centerchartcategorybase", required=False, type=str, default="trainingsreport",
help="The chart category to use for the center specific graphs to find the chart images with ImageRegistry. The center name will be appended to the end of this value and should be the second part of the filename.")
parser.add_argument("-c", "--center", action='append', required=True, help="For each occurrence of the --center argument, the script will generate a per center trainings report and look for the appropriate images in the images directory." )
parser.add_argument("--output", required=True, help="The name to give the output file")
parser.add_argument("--fiscalyear", required=True, type=str, help="The fiscal year to use for the report")
args = parser.parse_args()
# Parse the image paths in the selected dir and build the dictionary
# Build all needed functions for the center specific reports
all_page_funcs = []
center_page_funcs = []
for center in args.center:
registry = ImageRegistry(args.images, f"{args.reportname}{center}")
# Collect the paths to all the graphs for a single center's report
try:
# Primary topic charts
primary_topic_pie_total=registry.get(f"topics-pie", VARIANT_SUFFIX_MAP[StatChartVariants.TOTAL_PERCENT])
primary_topic_pie_no_first_total=registry.get("topics-pie", VARIANT_SUFFIX_MAP[StatChartVariants.NO_FIRST_STEPS_PERCENT])
primary_topic_bar_small_topics_total=registry.get("training-topics", VARIANT_SUFFIX_MAP[StatChartVariants.SMALL_BARS_TRAININGS_PERCENT])
primary_topic_bar_small_topics_percent=registry.get("training-topics", VARIANT_SUFFIX_MAP[StatChartVariants.SMALL_BARS_TRAININGS])
# Attendee Bin Charts
attendee_bin_chart_total_count=registry.get("attendee-bins", VARIANT_SUFFIX_MAP[StatChartVariants.TOTAL_COUNT])
attendee_bin_chart_total_percent=registry.get("attendee-bins", VARIANT_SUFFIX_MAP[StatChartVariants.TOTAL_PERCENT])
attendee_bin_chart_no_first_no_pre_total_count=registry.get("attendee-bins", VARIANT_SUFFIX_MAP[StatChartVariants.NO_FIRST_NO_PREPLANNNG_COUNT])
attendee_bin_chart_no_first_no_pre_total_percent=registry.get("attendee-bins", VARIANT_SUFFIX_MAP[StatChartVariants.NO_FIRST_NO_PREPLANNNG_PERCENT])
attendee_bin_chart_first_pre_total_count=registry.get("attendee-bins", VARIANT_SUFFIX_MAP[StatChartVariants.FIRST_AND_PREPLANNING_ONLY])
attendee_bin_chart_first_pre_total_percent=registry.get("attendee-bins", VARIANT_SUFFIX_MAP[StatChartVariants.FIRST_AND_PREPLANNING_ONLY_PERCENT])
except Exception as e:
# The above statements would throw an exception if the could not find a particular center's graphs.
# This way, if a center did not have any trainings in the time frame of your data, the whole thing does not blow up
print(f"\tWARNING: No graphs found for center '{center}' for {args.fiscalyear}. Skipping.")
continue
# Use partial to fix the function arguments for each center page function.
# Let the Word document builder supply the shared constants
primary_topic_page_func = partial(
primary_topic_analysis_page_maker,
center=center,
primary_topic_pie_total=primary_topic_pie_total,
primary_topic_pie_no_first_total=primary_topic_pie_no_first_total,
primary_topic_bar_small_topics_total=primary_topic_bar_small_topics_total,
primary_topic_bar_small_topics_percent=primary_topic_bar_small_topics_percent,
is_center_specific=True
)
center_page_funcs.append(PageConfig(page_function=primary_topic_page_func, add_page_break=True))
all_page_funcs.append(PageConfig(page_function=primary_topic_page_func, add_page_break=True))
attendee_bin_page_func = partial(
attendee_bin_charts_page_maker,
center=center,
attendee_bin_chart_total_count=attendee_bin_chart_total_count,
attendee_bin_chart_total_percent=attendee_bin_chart_total_percent,
attendee_bin_chart_no_first_no_pre_total_count=attendee_bin_chart_no_first_no_pre_total_count,
attendee_bin_chart_no_first_no_pre_total_percent=attendee_bin_chart_no_first_no_pre_total_percent,
attendee_bin_chart_first_pre_total_count=attendee_bin_chart_first_pre_total_count,
attendee_bin_chart_first_pre_total_percent=attendee_bin_chart_first_pre_total_percent,
)
center_page_funcs.append(PageConfig(page_function=attendee_bin_page_func, add_page_break=True))
all_page_funcs.append(PageConfig(page_function=attendee_bin_page_func, add_page_break=True))
out_path = os.path.join(args.output, f"{center}_trainings_analysis.docx")
center_builder = WordDocumentBuilder()
center_builder.create_document(
[
PageConfig(page_function=center_trainings_analysis_page_one_maker, add_page_break=False)
] + center_page_funcs,
out_path,
fiscal_year=args.fiscalyear,
section_number=7,
desk_review_section_number=3,
)
print(f"\tBuilt report for {center}: {out_path}")
center_page_funcs.clear()
builder = WordDocumentBuilder()
builder.create_document(
[
PageConfig(page_function=center_trainings_analysis_page_one_maker, add_page_break=False)
] + all_page_funcs,
os.path.join(args.output, f"AllCenters_trainings_analysis.docx"),
fiscal_year=args.fiscalyear,
section_number=7,
desk_review_section_number=3,
)
if __name__ == "__main__":
main()