Update app.py
Browse files
app.py
CHANGED
|
@@ -61,6 +61,7 @@ def fetch_available_standards():
|
|
| 61 |
# ==========================================
|
| 62 |
# 2. UI Component Handlers
|
| 63 |
# ==========================================
|
|
|
|
| 64 |
def load_initial_standards():
|
| 65 |
return gr.Dropdown(choices=fetch_available_standards())
|
| 66 |
|
|
@@ -220,6 +221,7 @@ def reset_comp_selections():
|
|
| 220 |
# ==========================================
|
| 221 |
# 3. Core Logic & Data Processing
|
| 222 |
# ==========================================
|
|
|
|
| 223 |
def generate_html_diff(base_text, comp_text):
|
| 224 |
base_text = "" if pd.isna(base_text) else str(base_text)
|
| 225 |
comp_text = "" if pd.isna(comp_text) else str(comp_text)
|
|
@@ -425,8 +427,7 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
|
|
| 425 |
df_comp['merge_key'] = df_comp[real_anchors_c].apply(lambda row: '-'.join(row.values.astype(str)), axis=1).str.replace(" ", "")
|
| 426 |
|
| 427 |
conn_map = sqlite3.connect(os.path.join(UPLOAD_DIR, "mapping.db"))
|
| 428 |
-
|
| 429 |
-
# DB์ Base_Type, Comp_Type ์ปฌ๋ผ์ด ์๋์ง ํ์ธ (์๋ฌ ๋ฐฉ์ง์ฉ)
|
| 430 |
map_cols = pd.read_sql("PRAGMA table_info(Mapping_table)", conn_map)['name'].tolist()
|
| 431 |
|
| 432 |
if 'Base_Type' in map_cols and 'Comp_Type' in map_cols:
|
|
@@ -436,7 +437,7 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
|
|
| 436 |
q_rv = "SELECT Comp_section AS Base_section, Base_section AS Comp_section FROM Mapping_table WHERE TRIM(Comp_std)=? AND TRIM(Comp_ver)=? AND TRIM(Comp_Type)=? AND TRIM(Base_std)=? AND TRIM(Base_ver)=? AND TRIM(Base_Type)=?"
|
| 437 |
df_rv = pd.read_sql(q_rv, conn_map, params=[base_std.strip(), base_ver.strip(), type_b, comp_std.strip(), comp_ver.strip(), type_c])
|
| 438 |
else:
|
| 439 |
-
|
| 440 |
q = "SELECT Base_section, Comp_section FROM Mapping_table WHERE TRIM(Base_std)=? AND TRIM(Base_ver)=? AND TRIM(Comp_std)=? AND TRIM(Comp_ver)=?"
|
| 441 |
df_fw = pd.read_sql(q, conn_map, params=[base_std.strip(), base_ver.strip(), comp_std.strip(), comp_ver.strip()])
|
| 442 |
q_rv = "SELECT Comp_section AS Base_section, Base_section AS Comp_section FROM Mapping_table WHERE TRIM(Comp_std)=? AND TRIM(Comp_ver)=? AND TRIM(Base_std)=? AND TRIM(Base_ver)=?"
|
|
@@ -454,7 +455,6 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
|
|
| 454 |
else:
|
| 455 |
df_mapping = pd.DataFrame(columns=['Base_section', 'Comp_section'])
|
| 456 |
|
| 457 |
-
# [์์ ] ๊ฐ์ ๋ฒ๊ท & ๊ฐ์ ์นดํ
๊ณ ๋ฆฌ์ผ ๋๋ง ๋ฒํธ ์ผ์น ์๋ ๋งคํ ํ์ฉ
|
| 458 |
if base_std.strip().upper() == comp_std.strip().upper() and type_b == type_c:
|
| 459 |
implicit = pd.DataFrame({'Base_section': list(set(df_base['merge_key']) & set(df_comp['merge_key'])),
|
| 460 |
'Comp_section': list(set(df_base['merge_key']) & set(df_comp['merge_key']))})
|
|
@@ -545,7 +545,6 @@ with gr.Blocks() as demo:
|
|
| 545 |
base_category.change(fn=update_comp_category_dropdown, inputs=comp_change_triggers, outputs=[comp_category])
|
| 546 |
comp_version.change(fn=update_comp_category_dropdown, inputs=comp_change_triggers, outputs=[comp_category])
|
| 547 |
|
| 548 |
-
# JS๋ฅผ ์์ ํ ์ ๊ฑฐํ๊ณ ์์ํ๊ฒ ํ์ด์ฌ ๋ก์ง๋ง ๋ฐ์ธ๋ฉ
|
| 549 |
search_btn.click(
|
| 550 |
fn=execute_unified_search,
|
| 551 |
inputs=[base_standard, base_version, base_category, comp_standard, comp_version, comp_category],
|
|
@@ -559,6 +558,7 @@ with gr.Blocks() as demo:
|
|
| 559 |
# ==========================================
|
| 560 |
# 5. Application Styling (CSS)
|
| 561 |
# ==========================================
|
|
|
|
| 562 |
css = """
|
| 563 |
table {
|
| 564 |
table-layout: auto !important;
|
|
|
|
| 61 |
# ==========================================
|
| 62 |
# 2. UI Component Handlers
|
| 63 |
# ==========================================
|
| 64 |
+
|
| 65 |
def load_initial_standards():
|
| 66 |
return gr.Dropdown(choices=fetch_available_standards())
|
| 67 |
|
|
|
|
| 221 |
# ==========================================
|
| 222 |
# 3. Core Logic & Data Processing
|
| 223 |
# ==========================================
|
| 224 |
+
|
| 225 |
def generate_html_diff(base_text, comp_text):
|
| 226 |
base_text = "" if pd.isna(base_text) else str(base_text)
|
| 227 |
comp_text = "" if pd.isna(comp_text) else str(comp_text)
|
|
|
|
| 427 |
df_comp['merge_key'] = df_comp[real_anchors_c].apply(lambda row: '-'.join(row.values.astype(str)), axis=1).str.replace(" ", "")
|
| 428 |
|
| 429 |
conn_map = sqlite3.connect(os.path.join(UPLOAD_DIR, "mapping.db"))
|
| 430 |
+
|
|
|
|
| 431 |
map_cols = pd.read_sql("PRAGMA table_info(Mapping_table)", conn_map)['name'].tolist()
|
| 432 |
|
| 433 |
if 'Base_Type' in map_cols and 'Comp_Type' in map_cols:
|
|
|
|
| 437 |
q_rv = "SELECT Comp_section AS Base_section, Base_section AS Comp_section FROM Mapping_table WHERE TRIM(Comp_std)=? AND TRIM(Comp_ver)=? AND TRIM(Comp_Type)=? AND TRIM(Base_std)=? AND TRIM(Base_ver)=? AND TRIM(Base_Type)=?"
|
| 438 |
df_rv = pd.read_sql(q_rv, conn_map, params=[base_std.strip(), base_ver.strip(), type_b, comp_std.strip(), comp_ver.strip(), type_c])
|
| 439 |
else:
|
| 440 |
+
|
| 441 |
q = "SELECT Base_section, Comp_section FROM Mapping_table WHERE TRIM(Base_std)=? AND TRIM(Base_ver)=? AND TRIM(Comp_std)=? AND TRIM(Comp_ver)=?"
|
| 442 |
df_fw = pd.read_sql(q, conn_map, params=[base_std.strip(), base_ver.strip(), comp_std.strip(), comp_ver.strip()])
|
| 443 |
q_rv = "SELECT Comp_section AS Base_section, Base_section AS Comp_section FROM Mapping_table WHERE TRIM(Comp_std)=? AND TRIM(Comp_ver)=? AND TRIM(Base_std)=? AND TRIM(Base_ver)=?"
|
|
|
|
| 455 |
else:
|
| 456 |
df_mapping = pd.DataFrame(columns=['Base_section', 'Comp_section'])
|
| 457 |
|
|
|
|
| 458 |
if base_std.strip().upper() == comp_std.strip().upper() and type_b == type_c:
|
| 459 |
implicit = pd.DataFrame({'Base_section': list(set(df_base['merge_key']) & set(df_comp['merge_key'])),
|
| 460 |
'Comp_section': list(set(df_base['merge_key']) & set(df_comp['merge_key']))})
|
|
|
|
| 545 |
base_category.change(fn=update_comp_category_dropdown, inputs=comp_change_triggers, outputs=[comp_category])
|
| 546 |
comp_version.change(fn=update_comp_category_dropdown, inputs=comp_change_triggers, outputs=[comp_category])
|
| 547 |
|
|
|
|
| 548 |
search_btn.click(
|
| 549 |
fn=execute_unified_search,
|
| 550 |
inputs=[base_standard, base_version, base_category, comp_standard, comp_version, comp_category],
|
|
|
|
| 558 |
# ==========================================
|
| 559 |
# 5. Application Styling (CSS)
|
| 560 |
# ==========================================
|
| 561 |
+
|
| 562 |
css = """
|
| 563 |
table {
|
| 564 |
table-layout: auto !important;
|