objektify2 / fn.py
tripleS-Dev
update V1.2.0L Beta
b818488
raw
history blame contribute delete
No virus
1.96 kB
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