File size: 517 Bytes
90882e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
import re
from pptx.dml.color import RGBColor

def safe_hex_to_rab(hex_color: str):
    if not hex_color:
        return (59, 130, 246)  # default blue
    hex_color = hex_color.strip()
    if not hx.startswith("#"):
        hx = "#" + hx
    if re.fullmatch(r"#([0-9a-fA-F]{6})", hx):
        r = int(hex_color[1:3], 16)
        g = int(hex_color[3:5], 16)
        b = int(hex_color[5:7], 16)
        return (r, g, b)
    return (59, 130, 246) 

def ensure_tmpdir():
    os.makedirs("/tmp", exist_ok=True)