Spaces:
Sleeping
Sleeping
Youngsun Lim commited on
Commit ยท
901cd2b
1
Parent(s): a8fef31
app.py reward code
Browse files
app.py
CHANGED
|
@@ -247,18 +247,26 @@ def _persist_reward_code(pid: str, code: str, total_done: int):
|
|
| 247 |
commit_message="append reward code"
|
| 248 |
)
|
| 249 |
|
| 250 |
-
def _gen_reward_code(pid: str, length: int = 10, forbid_ambiguous: bool=True) -> str:
|
| 251 |
"""
|
| 252 |
-
์ฐธ๊ฐ์์๊ฒ ๋ณด์ฌ์ค ๋๋ค ์ฝ๋.
|
| 253 |
-
-
|
| 254 |
-
- ๋๋ฌธ์/์ซ์ ์กฐํฉ
|
| 255 |
"""
|
| 256 |
-
|
| 257 |
-
#
|
| 258 |
-
|
| 259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
rng = secrets.SystemRandom()
|
| 261 |
-
|
|
|
|
|
|
|
| 262 |
|
| 263 |
|
| 264 |
|
|
|
|
| 247 |
commit_message="append reward code"
|
| 248 |
)
|
| 249 |
|
| 250 |
+
def _gen_reward_code(pid: str, length: int = 10, forbid_ambiguous: bool = True) -> str:
|
| 251 |
"""
|
| 252 |
+
์ฐธ๊ฐ์์๊ฒ ๋ณด์ฌ์ค ๋๋ค ์ฝ๋.
|
| 253 |
+
- ํญ์ '2026'์ผ๋ก ์์
|
| 254 |
+
- ๋ค์ ๋๋ฌธ์/์ซ์ ์กฐํฉ ๋๋ค ๋ฌธ์์ด์ ๋ถ์ฌ ์ด length ์๋ฆฟ์๋ก ๋ง๋ฆ
|
| 255 |
"""
|
| 256 |
+
prefix = "2026"
|
| 257 |
+
# prefix๋ฅผ ํฌํจํด์ ์ ์ฒด ๊ธธ์ด๊ฐ length๊ฐ ๋๋๋ก ๋ค์ ๋ถ์ผ ๊ธธ์ด ๊ณ์ฐ
|
| 258 |
+
random_len = max(0, length - len(prefix))
|
| 259 |
+
|
| 260 |
+
if forbid_ambiguous:
|
| 261 |
+
# I, O, 0, 1 ์ ๊ฑฐ
|
| 262 |
+
alphabet = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"
|
| 263 |
+
else:
|
| 264 |
+
alphabet = string.ascii_uppercase + string.digits
|
| 265 |
+
|
| 266 |
rng = secrets.SystemRandom()
|
| 267 |
+
suffix = "".join(rng.choice(alphabet) for _ in range(random_len))
|
| 268 |
+
|
| 269 |
+
return prefix + suffix
|
| 270 |
|
| 271 |
|
| 272 |
|