Spaces:
Running
Running
from datetime import datetime | |
import pytz | |
import os | |
import shutil | |
def hex_to_rgb(hex_color): | |
# Remove the '#' character if it exists | |
hex_color = hex_color.lstrip('#') | |
# Convert the hex string to integers | |
r, g, b = tuple(int(hex_color[i:i + 2], 16) for i in (0, 2, 4)) | |
return r, g, b | |
def get_kr_time(): | |
# νκ΅ μκ°λ μ€μ | |
korea_time_zone = pytz.timezone('Asia/Seoul') | |
# νμ¬ μκ°μ νκ΅ μκ°λλ‘ λ³ν | |
current_time_in_korea = datetime.now(korea_time_zone) | |
# μνλ νμμΌλ‘ μκ° ν¬λ§·ν | |
return current_time_in_korea.strftime("%Y%m%d-%H%M%S") | |
def url_mapping(url): | |
# κ° λ¬Έμμ΄μ λμνλ URL 맀ν | |
url_mapping = { | |
"tripleS website": "https://triplescosmos.com/", | |
"tripleS youtube": "https://youtube.com/@triplescosmos", | |
"tripleS π": "https://x.com/triplescosmos", | |
"tripleS discord": "https://discord.gg/triplescosmos" | |
} | |
# qr_urlμ΄ λ§€νλ λ¬Έμμ΄ μ€ νλλΌλ©΄ ν΄λΉ URLμ, μλλΌλ©΄ qr_url κ·Έλλ‘λ₯Ό λ°ν | |
return url_mapping.get(url, url) | |
def zip(name): | |
# '/data' ν΄λλ₯Ό 'data.zip'μΌλ‘ μμΆ | |
shutil.make_archive(f'/data/{name}', 'zip', f'/data/{name}') | |
shutil.rmtree(f'/data/{name}') | |
def remove(filename): | |
# './data/' λλ ν°λ¦¬ κ²½λ‘ μ€μ | |
directory = '/data/' | |
file_path = os.path.join(directory, filename) | |
# νμΌμ΄ zip νμΌμΈμ§ νμΈ | |
if filename.endswith('.zip'): | |
# νμΌ μμ | |
os.remove(file_path) | |
def transform_number(n): | |
n = n + 1 | |
if n < 1 or n > 29: | |
raise ValueError("μ λ ₯ κ°μ 1λΆν° 29 μ¬μ΄μ¬μΌ ν©λλ€.") | |
if 1 <= n <= 14: | |
return n | |
elif n == 15: | |
return 19 | |
elif 16 <= n <= 24: | |
return n + 5 | |
elif 25 <= n <= 28: | |
return n - 10 | |
elif n == 29: | |
return 20 |