Spaces:
Running
Running
File size: 1,958 Bytes
9793ed6 100d5f6 b818488 100d5f6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
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 |