DEV Community

Query Filter
Query Filter

Posted on

docker-194

from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN

# Initialize presentation
prs = Presentation()
prs.slide_width = Inches(13.333)  # 16:9 Widescreen standard
prs.slide_height = Inches(7.5)

# Color Palette Definitions
DARK_BLUE = RGBColor(12, 35, 64)
TEAL_INFO = RGBColor(0, 150, 136)
TEXT_DARK = RGBColor(40, 40, 40)
BG_TERMINAL = RGBColor(30, 30, 30)
TEXT_TERMINAL = RGBColor(240, 240, 240)

def apply_text_styling(run, font_name="Calibri", font_size=16, bold=False, color=TEXT_DARK):
    run.font.name = font_name
    run.font.size = Pt(font_size)
    run.font.bold = bold
    run.font.color.rgb = color

def add_standard_slide(title_text):
    slide = prs.slides.add_slide(prs.slide_layouts[6]) # Blank layout

    # Title Box
    title_box = slide.shapes.add_textbox(Inches(0.75), Inches(0.5), Inches(11.833), Inches(1.0))
    tf = title_box.text_frame
    tf.word_wrap = True
    p = tf.paragraphs[0]
    p.text = title_text
    apply_text_styling(p.runs[0], font_size=36, bold=True, color=DARK_BLUE)

    # Content Box
    content_box = slide.shapes.add_textbox(Inches(0.75), Inches(1.8), Inches(11.833), Inches(5.0))
    return content_box.text_frame

# ==============================================================================
# SLIDE 1: Title Slide (Custom Layout)
# ==============================================================================
slide_1 = prs.slides.add_slide(prs.slide_layouts[6])
title_box = slide_1.shapes.add_textbox(Inches(1.0), Inches(2.2), Inches(11.333), Inches(3.5))
tf_1 = title_box.text_frame
tf_1.word_wrap = True

p1 = tf_1.paragraphs[0]
p1.text = "Automated Legacy Java Library\nDecompilation Pipeline"
apply_text_styling(p1.runs[0], font_size=44, bold=True, color=DARK_BLUE)
p1.space_after = Pt(20)

p2 = tf_1.add_paragraph()
p2.text = "Modernizing Source Artifacts for Java 21+ Environments"
apply_text_styling(p2.runs[0], font_size=20, bold=False, color=TEAL_INFO)
p2.space_after = Pt(40)

p3 = tf_1.add_paragraph()
p3.text = "Presenter: Systems Architecture Team  |  Platform: Git Bash / MSYS2 on Windows"
apply_text_styling(p3.runs[0], font_size=14, color=TEXT_DARK)

# ==============================================================================
# SLIDE 2: Problem Statement
# ==============================================================================
tf_2 = add_standard_slide("The Challenge of Legacy Black Boxes")
points_2 = [
    ("System Dependencies: ", "Upgrading core infrastructure (like the COMET and CPLS systems) requires modernizing outdated libraries (such as the Java 6 ETSF library)."),
    ("Lost Context: ", "Source repositories for older .jar files are often missing, corrupt, or unmaintained across historical project structures."),
    ("The Objective: ", "Safely disassemble binary .jar artifacts back into clean, high-concurrency-ready Java 21+ source code structures without introducing structural regression.")
]
for bold_prefix, text in points_2:
    p = tf_2.add_paragraph() if tf_2.paragraphs[0].text else tf_2.paragraphs[0]
    p.space_after = Pt(14)
    p.level = 0
    apply_text_styling(p.add_run(), font_size=18, bold=True, color=DARK_BLUE)
    p.runs[0].text = bold_prefix
    apply_text_styling(p.add_run(), font_size=18, bold=False, color=TEXT_DARK)
    p.runs[1].text = text

# ==============================================================================
# SLIDE 3: Architecture Blueprint
# ==============================================================================
tf_3 = add_standard_slide("Pipeline Architecture Blueprint")
points_3 = [
    ("1. Version Control Audit: ", "Peeks inside bytecode headers to identify compliance states before processing."),
    ("2. Auto-Discovery Engine: ", "Dynamically maps the local filesystem to locate the IDE decompiler runtime."),
    ("3. Fernflower Decompilation: ", "Disassembles compiled binary classes into highly structured source code."),
    ("4. Extraction & Housekeeping: ", "Unpacks the generated archives and automatically drops intermediate artifacts.")
]
for bold_prefix, text in points_3:
    p = tf_3.add_paragraph() if tf_3.paragraphs[0].text else tf_3.paragraphs[0]
    p.space_after = Pt(14)
    p.level = 0
    apply_text_styling(p.add_run(), font_size=18, bold=True, color=TEAL_INFO)
    p.runs[0].text = bold_prefix
    apply_text_styling(p.add_run(), font_size=18, bold=False, color=TEXT_DARK)
    p.runs[1].text = text

# ==============================================================================
# SLIDE 4: Phase 1 – Version Control Audit
# ==============================================================================
tf_4 = add_standard_slide("Phase 1: Version Control Audit")
points_4 = [
    ("Source Inspection via 'javap': ", "The script targets the first .class file inside the archive and extracts the binary major version header directly from the bytecode."),
    ("Dynamic Matrix Mapping: ", "Maps internal bytecode numbers to human-readable names (e.g., major version 50 -> Java 6; 65 -> Java 21)."),
    ("Target Runtime Verification: ", "Queries the discovered IntelliJ Java binary via 'java -version' to ensure destination alignment."),
    ("Deterministic Logging: ", "Outputs a dedicated [VERSION CONTROL] console block detailing the exact transition path before the compilation takes place.")
]
for bold_prefix, text in points_4:
    p = tf_4.add_paragraph() if tf_4.paragraphs[0].text else tf_4.paragraphs[0]
    p.space_after = Pt(12)
    p.level = 0
    apply_text_styling(p.add_run(), font_size=16, bold=True, color=DARK_BLUE)
    p.runs[0].text = bold_prefix
    apply_text_styling(p.add_run(), font_size=16, bold=False, color=TEXT_DARK)
    p.runs[1].text = text

# ==============================================================================
# SLIDE 5: Phase 2 – Dynamic Environment Discovery
# ==============================================================================
tf_5 = add_standard_slide("Phase 2: Dynamic Environment Discovery")
points_5 = [
    ("The Fragility Problem: ", "Hardcoding specific IDE versions (e.g., 'IntelliJ IDEA 2024.3.3') breaks when software updates patch or push paths forward."),
    ("The Automated Discovery Solution: ", "The script dynamically scans standard corporate installation spaces (C:/Program Files/JetBrains and local AppData)."),
    ("Smart Selection Matrix: ", "Employs an alphanumeric reverse sort ('sort -r') to guarantee that the newest available IDE version and runtime engine are utilized automatically."),
    ("Fail-Safe Containment: ", "Gracefully interrupts execution with a unique exit code if critical binaries (java.exe or java-decompiler.jar) cannot be resolved.")
]
for bold_prefix, text in points_5:
    p = tf_5.add_paragraph() if tf_5.paragraphs[0].text else tf_5.paragraphs[0]
    p.space_after = Pt(12)
    p.level = 0
    apply_text_styling(p.add_run(), font_size=16, bold=True, color=DARK_BLUE)
    p.runs[0].text = bold_prefix
    apply_text_styling(p.add_run(), font_size=16, bold=False, color=TEXT_DARK)
    p.runs[1].text = text

# ==============================================================================
# SLIDE 6: Phase 3 – Decompilation Execution
# ==============================================================================
tf_6 = add_standard_slide("Phase 3: Decompilation Execution")
points_6 = [
    ("Target Directory Enforcement: ", "Checks for the presence of the output folder, instantly spinning up the destination directories via 'mkdir -p' if they do not exist."),
    ("Absolute Path Mapping ('realpath'): ", "Upgrades input strings to fully qualified filesystem paths to prevent context loss during terminal directory switching."),
    ("Preserving Type Signatures: ", "Applies the critical generic signature flag (-dgs=true) to preserve advanced structural syntax patterns during decompilation.")
]
for bold_prefix, text in points_6:
    p = tf_6.add_paragraph() if tf_6.paragraphs[0].text else tf_6.paragraphs[0]
    p.space_after = Pt(14)
    p.level = 0
    apply_text_styling(p.add_run(), font_size=18, bold=True, color=DARK_BLUE)
    p.runs[0].text = bold_prefix
    apply_text_styling(p.add_run(), font_size=18, bold=False, color=TEXT_DARK)
    p.runs[1].text = text

# ==============================================================================
# SLIDE 7: Phase 4 – Extraction & Housekeeping
# ==============================================================================
tf_7 = add_standard_slide("Phase 4: Extraction & Validation")
points_7 = [
    ("Unpacking the Payload: ", "The Fernflower engine packages its results as a nested .jar file inside your destination folder."),
    ("Native Unpacking: ", "Uses the JDK utility ('jar -xvf') to extract the structural directories cleanly into the local folder context."),
    ("Automated Housekeeping: ", "Automatically removes the duplicate intermediate archive file to prevent build-path conflicts or git history clutter."),
    ("Deterministic Inventory Report: ", "Runs a localized filesystem discovery ('find . -type f') to output a scannable inventory summary of all reconstructed files.")
]
for bold_prefix, text in points_7:
    p = tf_7.add_paragraph() if tf_7.paragraphs[0].text else tf_7.paragraphs[0]
    p.space_after = Pt(12)
    p.level = 0
    apply_text_styling(p.add_run(), font_size=16, bold=True, color=DARK_BLUE)
    p.runs[0].text = bold_prefix
    apply_text_styling(p.add_run(), font_size=16, bold=False, color=TEXT_DARK)
    p.runs[1].text = text

# ==============================================================================
# SLIDE 8: Enterprise Safeguards
# ==============================================================================
tf_8 = add_standard_slide("Built-In Resiliency Matrix")
points_8 = [
    ("Strict Error Containment ('set -eo pipefail'): ", "Ensures that if any individual command or sub-pipe breaks, execution halts instantly instead of continuing blindly down the line."),
    ("Context Traps ('trap cleanup_on_err EXIT'): ", "Captures the exact line number and failing command, outputting a highly readable troubleshooting message upon an unexpected crash."),
    ("Idempotent Behavior: ", "Overwrites older directory traces cleanly on retry without interactive human prompts, making the script fully compatible with automated CI/CD integration pipelines.")
]
for bold_prefix, text in points_8:
    p = tf_8.add_paragraph() if tf_8.paragraphs[0].text else tf_8.paragraphs[0]
    p.space_after = Pt(14)
    p.level = 0
    apply_text_styling(p.add_run(), font_size=18, bold=True, color=DARK_BLUE)
    p.runs[0].text = bold_prefix
    apply_text_styling(p.add_run(), font_size=18, bold=False, color=TEXT_DARK)
    p.runs[1].text = text

# ==============================================================================
# SLIDE 9: Execution Walkthrough (Custom Terminal Layout)
# ==============================================================================
slide_9 = prs.slides.add_slide(prs.slide_layouts[6])

# Slide Title
title_box_9 = slide_9.shapes.add_textbox(Inches(0.75), Inches(0.5), Inches(11.833), Inches(1.0))
p_9 = title_box_9.text_frame.paragraphs[0]
p_9.text = "Execution Walkthrough & Console Output"
apply_text_styling(p_9.runs[0], font_size=36, bold=True, color=DARK_BLUE)

# Dark Terminal Background Shape
shape = slide_9.shapes.add_shape(
    1,  # MSO_SHAPE.RECTANGLE
    Inches(0.75), Inches(1.6), Inches(11.833), Inches(5.2)
)
shape.fill.solid()
shape.fill.fore_color.rgb = BG_TERMINAL
shape.line.color.rgb = BG_TERMINAL

# Terminal Content Box
terminal_box = slide_9.shapes.add_textbox(Inches(0.9), Inches(1.7), Inches(11.5), Inches(5.0))
tf_9 = terminal_box.text_frame
tf_9.word_wrap = True

terminal_text = (
    "$ ./decompile_lib.sh ../etsf-1.0_A20.jar lib\n"
    "[INFO] Locating IntelliJ installation environment...\n"
    "[INFO] Found Runtime: /c/Program Files/JetBrains/IntelliJ IDEA 2026.1/jbr/bin/java.exe\n"
    "------------------------------------------------------------\n"
    "[VERSION CONTROL] Pipeline Architecture Mapping:\n"
    "[VERSION CONTROL]    >> SOURCE bytecode format:   Java 6\n"
    "[VERSION CONTROL]    >> TARGET decompiler runtime: Java 21.0.2\n"
    "------------------------------------------------------------\n"
    "[INFO] Destination folder 'lib' does not exist. Creating it now...\n"
    "[INFO] Executing ConsoleDecompiler against etsf-1.0_A20.jar...\n"
    "[INFO] Extracting generated source archive inside target folder...\n"
    " extracted: com/etsf/core/Parser.java\n"
    " extracted: com/etsf/core/Validator.java\n"
    "[INFO] --- Disassembled File Inventory Summary ---\n"
    "./com/etsf/core/Parser.java\n"
    "./com/etsf/core/Validator.java\n"
    "[INFO] Decompilation pipeline successfully completed."
)

p_term = tf_9.paragraphs[0]
p_term.text = terminal_text
p_term.line_spacing = 1.1
apply_text_styling(p_term.runs[0], font_name="Consolas", font_size=13, color=TEXT_TERMINAL)

# Save presentation
prs.save("Java_Decompilation_Pipeline.pptx")
print("Successfully generated 'Java_Decompilation_Pipeline.pptx' with 16:9 widescreen mapping.")
Enter fullscreen mode Exit fullscreen mode

Top comments (0)