Update app.py
Browse files
app.py
CHANGED
|
@@ -25,7 +25,6 @@ def blob_to_base64_html(blob_data):
|
|
| 25 |
try:
|
| 26 |
if isinstance(blob_data, (bytes, bytearray)):
|
| 27 |
encoded = base64.b64encode(blob_data).decode('utf-8')
|
| 28 |
-
# ํต์ฌ ์์ : width๋ฅผ 100%๋ก ์ฃผ์ด ์
๊ฐ๋ก๋๋น์ ๊ฝ ์ฐจ๊ฒ ๋ง๋ค๊ณ , max-height๋ฅผ 600px๋ก ๋๋ํ๊ฒ ๋๋ฆผ
|
| 29 |
return f'''
|
| 30 |
<img src="data:image/png;base64,{encoded}"
|
| 31 |
style="width: 50%; max-height: 400px; object-fit: contain;
|
|
@@ -102,33 +101,21 @@ def update_category_dd(standard, version):
|
|
| 102 |
for _, r in df.iterrows():
|
| 103 |
choices.append(f"{str(r[ch]).strip()}.{str(r[ca]).strip()}")
|
| 104 |
|
| 105 |
-
# 2. ๐ ํ
์ด๋ธ ์ด๋ฆ ๊น๋ํ๊ฒ ์๋ฅด๊ธฐ (
|
| 106 |
-
|
| 107 |
-
prefix = f"{standard}_{version}_".lower()
|
| 108 |
-
prefix_no_under = f"{standard}_{version}".lower()
|
| 109 |
|
| 110 |
for t in tables:
|
| 111 |
if t == main_t:
|
| 112 |
continue
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
if t_lower.startswith(prefix):
|
| 118 |
-
short_name = t[len(prefix):]
|
| 119 |
-
# ํน์ ์ธ๋๋ฐ(_) ์์ด "r171_00seriesTableA" ์ฒ๋ผ ๋ถ์ด์์ ๊ฒฝ์ฐ ๋๋น
|
| 120 |
-
elif t_lower.startswith(prefix_no_under):
|
| 121 |
-
short_name = t[len(prefix_no_under):]
|
| 122 |
-
else:
|
| 123 |
-
short_name = t
|
| 124 |
-
|
| 125 |
-
choices.append(f"{short_name.strip()}")
|
| 126 |
|
| 127 |
conn.close()
|
| 128 |
|
| 129 |
except Exception as e:
|
| 130 |
print(f"[Error in update_category_dd] standard: {standard}, version: {version}")
|
| 131 |
-
import traceback
|
| 132 |
traceback.print_exc()
|
| 133 |
|
| 134 |
return gr.Dropdown(choices=choices)
|
|
@@ -197,12 +184,21 @@ def display_data(standard, version, selection):
|
|
| 197 |
if main_t not in tables:
|
| 198 |
main_t = tables[0]
|
| 199 |
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
df = pd.read_sql(f"SELECT * FROM [{full_table_name}]", conn)
|
| 207 |
df.columns = [c.strip() for c in df.columns]
|
| 208 |
df = df.drop(columns=[c for c in df.columns if c.lower() == "version"], errors="ignore")
|
|
@@ -214,6 +210,7 @@ def display_data(standard, version, selection):
|
|
| 214 |
conn.close()
|
| 215 |
return df
|
| 216 |
|
|
|
|
| 217 |
cols = pd.read_sql(f"PRAGMA table_info([{main_t}])", conn)['name'].tolist()
|
| 218 |
lower = [c.lower().strip() for c in cols]
|
| 219 |
|
|
@@ -392,13 +389,13 @@ table {
|
|
| 392 |
}
|
| 393 |
|
| 394 |
/* -------------------------- */
|
| 395 |
-
/* 2์ปฌ๋ผ
|
| 396 |
/* -------------------------- */
|
| 397 |
table th:nth-last-child(2):first-child, table td:nth-last-child(2):first-child { width: 15% !important; }
|
| 398 |
table th:nth-last-child(1), table td:nth-last-child(1) { width: 85% !important; }
|
| 399 |
|
| 400 |
/* -------------------------- */
|
| 401 |
-
/* 4์ปฌ๋ผ
|
| 402 |
/* -------------------------- */
|
| 403 |
table th:nth-child(1):nth-last-child(4), table td:nth-child(1):nth-last-child(4) { width: 7% !important; }
|
| 404 |
table th:nth-child(2):nth-last-child(3), table td:nth-child(2):nth-last-child(3) { width: 43% !important; }
|
|
@@ -406,7 +403,7 @@ table th:nth-child(3):nth-last-child(2), table td:nth-child(3):nth-last-child(2)
|
|
| 406 |
table th:nth-child(4):nth-last-child(1), table td:nth-child(4):nth-last-child(1) { width: 43% !important; }
|
| 407 |
|
| 408 |
/* -------------------------- */
|
| 409 |
-
/* 5์ปฌ๋ผ
|
| 410 |
/* -------------------------- */
|
| 411 |
table th:nth-child(1):nth-last-child(5), table td:nth-child(1):nth-last-child(5) { width: 15% !important; }
|
| 412 |
table th:nth-child(2):nth-last-child(4), table td:nth-child(2):nth-last-child(4) { width: 10% !important; }
|
|
@@ -415,7 +412,7 @@ table th:nth-child(4):nth-last-child(2), table td:nth-child(4):nth-last-child(2)
|
|
| 415 |
table th:nth-child(5):nth-last-child(1), table td:nth-child(5):nth-last-child(1) { width: 35% !important; }
|
| 416 |
|
| 417 |
/* -------------------------- */
|
| 418 |
-
/* 6์ปฌ๋ผ
|
| 419 |
/* -------------------------- */
|
| 420 |
table th:nth-child(1):nth-last-child(6), table td:nth-child(1):nth-last-child(6) { width: 8% !important; }
|
| 421 |
table th:nth-child(2):nth-last-child(5), table td:nth-child(2):nth-last-child(5) { width: 25% !important; }
|
|
|
|
| 25 |
try:
|
| 26 |
if isinstance(blob_data, (bytes, bytearray)):
|
| 27 |
encoded = base64.b64encode(blob_data).decode('utf-8')
|
|
|
|
| 28 |
return f'''
|
| 29 |
<img src="data:image/png;base64,{encoded}"
|
| 30 |
style="width: 50%; max-height: 400px; object-fit: contain;
|
|
|
|
| 101 |
for _, r in df.iterrows():
|
| 102 |
choices.append(f"{str(r[ch]).strip()}.{str(r[ca]).strip()}")
|
| 103 |
|
| 104 |
+
# 2. ๐ ํ
์ด๋ธ ์ด๋ฆ ๊น๋ํ๊ฒ ์๋ฅด๊ธฐ (๊ฐ๋ ฅํ ์ ๊ท์ ์ ์ฉ)
|
| 105 |
+
pattern = re.compile(f"^{standard}[_\\s-]*{version}[_\\s-]*", re.IGNORECASE)
|
|
|
|
|
|
|
| 106 |
|
| 107 |
for t in tables:
|
| 108 |
if t == main_t:
|
| 109 |
continue
|
| 110 |
|
| 111 |
+
# ๋์๋ฌธ์, ์ธ๋๋ฐ, ๊ณต๋ฐฑ์ ์ฐฐ๋ก๊ฐ์ด ๋ฌด์ํ๊ณ ๊ธฐ์ค ์ ๋์ฌ๋ฅผ ๋ ๋ ค๋ฒ๋ฆผ
|
| 112 |
+
short_name = pattern.sub("", t).strip(" _")
|
| 113 |
+
choices.append(short_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
conn.close()
|
| 116 |
|
| 117 |
except Exception as e:
|
| 118 |
print(f"[Error in update_category_dd] standard: {standard}, version: {version}")
|
|
|
|
| 119 |
traceback.print_exc()
|
| 120 |
|
| 121 |
return gr.Dropdown(choices=choices)
|
|
|
|
| 184 |
if main_t not in tables:
|
| 185 |
main_t = tables[0]
|
| 186 |
|
| 187 |
+
# ๐ ์๋ฆฐ short_name์ผ๋ก ์๋ ํ๋ค์ ํ
์ด๋ธ ์ฐพ๊ธฐ (Reverse Lookup)
|
| 188 |
+
full_table_name = None
|
| 189 |
+
pattern = re.compile(f"^{standard}[_\\s-]*{version}[_\\s-]*", re.IGNORECASE)
|
| 190 |
+
|
| 191 |
+
for t in tables:
|
| 192 |
+
if t == selection: # ํ๋ค์์ด ๊ทธ๋๋ก ๋งค์นญ๋๋ ๊ฒฝ์ฐ
|
| 193 |
+
full_table_name = t
|
| 194 |
+
break
|
| 195 |
+
short = pattern.sub("", t).strip(" _")
|
| 196 |
+
if short == selection: # ๋๋กญ๋ค์ด์ ์งง์ ์ด๋ฆ๊ณผ ๋งค์นญ๋๋ ์ค์ DB ํ
์ด๋ธ ์ฐพ๊ธฐ
|
| 197 |
+
full_table_name = t
|
| 198 |
+
break
|
| 199 |
+
|
| 200 |
+
# ํ
์ด๋ธ(A4/1 ๋ฑ)์ ์ ํํ ๊ฒฝ์ฐ
|
| 201 |
+
if full_table_name:
|
| 202 |
df = pd.read_sql(f"SELECT * FROM [{full_table_name}]", conn)
|
| 203 |
df.columns = [c.strip() for c in df.columns]
|
| 204 |
df = df.drop(columns=[c for c in df.columns if c.lower() == "version"], errors="ignore")
|
|
|
|
| 210 |
conn.close()
|
| 211 |
return df
|
| 212 |
|
| 213 |
+
# ALL ๋๋ ์ฑํฐ.์นดํ
๊ณ ๋ฆฌ ์ ํํ ๊ฒฝ์ฐ
|
| 214 |
cols = pd.read_sql(f"PRAGMA table_info([{main_t}])", conn)['name'].tolist()
|
| 215 |
lower = [c.lower().strip() for c in cols]
|
| 216 |
|
|
|
|
| 389 |
}
|
| 390 |
|
| 391 |
/* -------------------------- */
|
| 392 |
+
/* 2์ปฌ๋ผ */
|
| 393 |
/* -------------------------- */
|
| 394 |
table th:nth-last-child(2):first-child, table td:nth-last-child(2):first-child { width: 15% !important; }
|
| 395 |
table th:nth-last-child(1), table td:nth-last-child(1) { width: 85% !important; }
|
| 396 |
|
| 397 |
/* -------------------------- */
|
| 398 |
+
/* 4์ปฌ๋ผ */
|
| 399 |
/* -------------------------- */
|
| 400 |
table th:nth-child(1):nth-last-child(4), table td:nth-child(1):nth-last-child(4) { width: 7% !important; }
|
| 401 |
table th:nth-child(2):nth-last-child(3), table td:nth-child(2):nth-last-child(3) { width: 43% !important; }
|
|
|
|
| 403 |
table th:nth-child(4):nth-last-child(1), table td:nth-child(4):nth-last-child(1) { width: 43% !important; }
|
| 404 |
|
| 405 |
/* -------------------------- */
|
| 406 |
+
/* 5์ปฌ๋ผ */
|
| 407 |
/* -------------------------- */
|
| 408 |
table th:nth-child(1):nth-last-child(5), table td:nth-child(1):nth-last-child(5) { width: 15% !important; }
|
| 409 |
table th:nth-child(2):nth-last-child(4), table td:nth-child(2):nth-last-child(4) { width: 10% !important; }
|
|
|
|
| 412 |
table th:nth-child(5):nth-last-child(1), table td:nth-child(5):nth-last-child(1) { width: 35% !important; }
|
| 413 |
|
| 414 |
/* -------------------------- */
|
| 415 |
+
/* 6์ปฌ๋ผ */
|
| 416 |
/* -------------------------- */
|
| 417 |
table th:nth-child(1):nth-last-child(6), table td:nth-child(1):nth-last-child(6) { width: 8% !important; }
|
| 418 |
table th:nth-child(2):nth-last-child(5), table td:nth-child(2):nth-last-child(5) { width: 25% !important; }
|