QIDNLF commited on
Commit
4164d80
ยท
verified ยท
1 Parent(s): f7b9851

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -24
app.py CHANGED
@@ -61,7 +61,6 @@ def fetch_available_standards():
61
  # ==========================================
62
  # 2. UI Component Handlers
63
  # ==========================================
64
-
65
  def load_initial_standards():
66
  return gr.Dropdown(choices=fetch_available_standards())
67
 
@@ -221,7 +220,6 @@ def reset_comp_selections():
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)
@@ -403,14 +401,11 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
403
  else: new_cols.append(col)
404
  return df[new_cols]
405
 
406
- # 1. ๋‹จ์ผ ์กฐํšŒ (์—ฌ๊ธฐ์— ์žˆ๋˜ combine_code_desc๋ฅผ ์‚ญ์ œํ–ˆ์Šต๋‹ˆ๋‹ค!)
407
  if base_std and base_ver and base_cat and (not comp_std or not comp_ver or not comp_cat):
408
  df, _ = fetch_database_records(base_std, base_ver, base_cat, type_b)
409
  if "Error" in df.columns: return df
410
- # ์—ด์„ ๋ถ„๋ฆฌ๋œ ์ƒํƒœ ๊ทธ๋Œ€๋กœ ์œ ์ง€ํ•˜๊ณ , ์ค‘๋ณต ๋นˆ์นธ ์ฒ˜๋ฆฌ๋งŒ ์ˆ˜ํ–‰
411
  return apply_visual_merge(df, df.columns)
412
 
413
- # 2. ๋น„๊ต ์กฐํšŒ
414
  if all([base_std, base_ver, base_cat, comp_std, comp_ver, comp_cat]):
415
  df_base, real_anchors_b = fetch_database_records(base_std, base_ver, base_cat, type_b)
416
  df_comp, real_anchors_c = fetch_database_records(comp_std, comp_ver, comp_cat, type_c)
@@ -487,7 +482,6 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
487
  else:
488
  bridge = df_mapping.copy()
489
 
490
- # (์ค‘๋ณต ์ž‘์„ฑ๋œ rename_b ์‚ญ์ œ ์™„๋ฃŒ)
491
  rename_b = {c: f"{c}_{base_ver}" for c in df_base.columns if c != 'merge_key'}
492
  df_base = df_base.rename(columns=rename_b)
493
 
@@ -519,7 +513,6 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
519
  row_dict[rename_b[orig_col]], row_dict[rename_c[orig_col]] = generate_html_diff(b_v, c_v)
520
  result_rows.append(row_dict)
521
 
522
- # ๋น„๊ต ์กฐํšŒ ์‹œ์—๋Š” ๋ฒˆํ˜ธ์™€ ์„ค๋ช…์„ ํ•ฉ์นฉ๋‹ˆ๋‹ค
523
  final_df = combine_code_desc(pd.DataFrame(result_rows))
524
 
525
  if diff_only:
@@ -547,12 +540,10 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
547
  with gr.Blocks() as demo:
548
  gr.Markdown("# ๐Ÿ“œ Regulation Viewer")
549
 
550
- with gr.Row(elem_id="diff_toggle_row"):
551
- diff_filter_cb = gr.Checkbox(label="๐Ÿ’ก ๋ณ€๊ฒฝ๋œ ๋‚ด์šฉ๋งŒ ๋ณด๊ธฐ (Diff Only)", value=False, elem_id="diff_cb_item")
552
-
553
  with gr.Accordion("๐Ÿ“Œ ๊ธฐ์ค€ ๋ฒ•๊ทœ", open=True):
554
  with gr.Column():
555
- # ๋ฒ„ํŠผ์„ ์œ„๋กœ ์˜ฌ๋ฆฌ๊ณ  ์‚ฌ์ด์ฆˆ๋ฅผ ์ž‘๊ฒŒ ๋งŒ๋“ญ๋‹ˆ๋‹ค
556
  base_reset_btn = gr.Button("โ†บ ๊ธฐ์ค€ ๋ฒ•๊ทœ ์ดˆ๊ธฐํ™”", size="sm")
557
  base_standard = gr.Dropdown(label="Standard")
558
  base_version = gr.Dropdown(label="Version")
@@ -565,9 +556,15 @@ with gr.Blocks() as demo:
565
  comp_version = gr.Dropdown(label="Version", choices=[])
566
  comp_category = gr.Dropdown(label="Category", choices=[])
567
 
568
-
569
-
570
  search_btn = gr.Button("๐Ÿ” ์กฐํšŒ", variant="primary")
 
 
 
 
 
 
 
 
571
  output_df = gr.Dataframe(wrap=True, interactive=False, datatype="html", max_height=800)
572
 
573
  demo.load(fn=load_initial_standards, inputs=None, outputs=base_standard)
@@ -601,7 +598,6 @@ with gr.Blocks() as demo:
601
  # ==========================================
602
  # 5. Application Styling (CSS)
603
  # ==========================================
604
-
605
  css = """
606
  table {
607
  table-layout: auto !important;
@@ -677,21 +673,22 @@ td img {
677
  display: block;
678
  max-width: none !important;
679
  }
 
 
 
 
680
  #diff_toggle_row {
681
- justify-content: flex-end !important; /* ์˜ค๋ฅธ์ชฝ ๋์œผ๋กœ ์ซ™ ๋ฐ€์–ด๋ƒ…๋‹ˆ๋‹ค */
 
682
  margin-top: 5px !important;
683
- margin-bottom: -15px !important; /* ํ‘œ์™€ ์ด์งˆ๊ฐ์ด ์—†๋„๋ก ์•„๋ž˜๋กœ ๋ฐ”์ง ๋‹น๊ฒจ ๋ถ™์ž…๋‹ˆ๋‹ค */
684
- pointer-events: none; /* ๋นˆ ๊ณต๊ฐ„ ํด๋ฆญ ๋ฐฉ์ง€ */
685
  }
686
 
687
  #diff_cb_item {
688
- flex: none !important; /* ๊ฐ€๋กœ ๊ณต๊ฐ„์„ ๋‹ค ์ฐจ์ง€ํ•˜๋Š” ๊ฒƒ์„ ๋ง‰์Šต๋‹ˆ๋‹ค */
689
- width: auto !important;
690
- min-width: max-content !important;
691
- background: transparent !important; /* ๋ฐฐ๊ฒฝ์„ ํˆฌ๋ช…ํ•˜๊ฒŒ ํ•ด์„œ ๊น”๋”ํ•˜๊ฒŒ ๋งŒ๋“ญ๋‹ˆ๋‹ค */
692
- border: none !important;
693
- box-shadow: none !important;
694
- pointer-events: auto; /* ์ฒดํฌ๋ฐ•์Šค ๋ถ€๋ถ„๋งŒ ํด๋ฆญ ๊ฐ€๋Šฅํ•˜๊ฒŒ ๋ณต๊ตฌ */
695
  }
696
  """
697
 
 
61
  # ==========================================
62
  # 2. UI Component Handlers
63
  # ==========================================
 
64
  def load_initial_standards():
65
  return gr.Dropdown(choices=fetch_available_standards())
66
 
 
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)
 
401
  else: new_cols.append(col)
402
  return df[new_cols]
403
 
 
404
  if base_std and base_ver and base_cat and (not comp_std or not comp_ver or not comp_cat):
405
  df, _ = fetch_database_records(base_std, base_ver, base_cat, type_b)
406
  if "Error" in df.columns: return df
 
407
  return apply_visual_merge(df, df.columns)
408
 
 
409
  if all([base_std, base_ver, base_cat, comp_std, comp_ver, comp_cat]):
410
  df_base, real_anchors_b = fetch_database_records(base_std, base_ver, base_cat, type_b)
411
  df_comp, real_anchors_c = fetch_database_records(comp_std, comp_ver, comp_cat, type_c)
 
482
  else:
483
  bridge = df_mapping.copy()
484
 
 
485
  rename_b = {c: f"{c}_{base_ver}" for c in df_base.columns if c != 'merge_key'}
486
  df_base = df_base.rename(columns=rename_b)
487
 
 
513
  row_dict[rename_b[orig_col]], row_dict[rename_c[orig_col]] = generate_html_diff(b_v, c_v)
514
  result_rows.append(row_dict)
515
 
 
516
  final_df = combine_code_desc(pd.DataFrame(result_rows))
517
 
518
  if diff_only:
 
540
  with gr.Blocks() as demo:
541
  gr.Markdown("# ๐Ÿ“œ Regulation Viewer")
542
 
543
+ # [์ˆ˜์ • ์™„๋ฃŒ] ์•„์ฝ”๋””์–ธ์€ ๊นจ๋—ํ•œ Row ์•ˆ์— ์•ˆ์ „ํ•˜๊ฒŒ ๋“ค์–ด๊ฐ”์Šต๋‹ˆ๋‹ค!
544
+ with gr.Row():
 
545
  with gr.Accordion("๐Ÿ“Œ ๊ธฐ์ค€ ๋ฒ•๊ทœ", open=True):
546
  with gr.Column():
 
547
  base_reset_btn = gr.Button("โ†บ ๊ธฐ์ค€ ๋ฒ•๊ทœ ์ดˆ๊ธฐํ™”", size="sm")
548
  base_standard = gr.Dropdown(label="Standard")
549
  base_version = gr.Dropdown(label="Version")
 
556
  comp_version = gr.Dropdown(label="Version", choices=[])
557
  comp_category = gr.Dropdown(label="Category", choices=[])
558
 
 
 
559
  search_btn = gr.Button("๐Ÿ” ์กฐํšŒ", variant="primary")
560
+
561
+ # =======================================================
562
+ # [์ˆ˜์ • ์™„๋ฃŒ] ์ฒดํฌ๋ฐ•์Šค๋Š” ์•„์ฝ”๋””์–ธ ๋ฐ–์œผ๋กœ ๊บผ๋‚ด์„œ ์กฐํšŒ ๋ฒ„ํŠผ ๋ฐ‘์— ๋ถ™์˜€์Šต๋‹ˆ๋‹ค!
563
+ # container=False๋ฅผ ์ฃผ์–ด ํšŒ์ƒ‰ ๋ฐ•์Šค๋„ ์™„๋ฒฝํ•˜๊ฒŒ ๋‚ ๋ ธ์Šต๋‹ˆ๋‹ค.
564
+ # =======================================================
565
+ with gr.Row(elem_id="diff_toggle_row"):
566
+ diff_filter_cb = gr.Checkbox(label="๐Ÿ’ก ๋ณ€๊ฒฝ๋œ ๋‚ด์šฉ๋งŒ ๋ณด๊ธฐ (Diff Only)", value=False, elem_id="diff_cb_item", container=False)
567
+
568
  output_df = gr.Dataframe(wrap=True, interactive=False, datatype="html", max_height=800)
569
 
570
  demo.load(fn=load_initial_standards, inputs=None, outputs=base_standard)
 
598
  # ==========================================
599
  # 5. Application Styling (CSS)
600
  # ==========================================
 
601
  css = """
602
  table {
603
  table-layout: auto !important;
 
673
  display: block;
674
  max-width: none !important;
675
  }
676
+
677
+ /* ----------------------------------------------------
678
+ [์ˆ˜์ • ์™„๋ฃŒ] Diff ํ•„ํ„ฐ ์ฒดํฌ๋ฐ•์Šค ์šฐ์ธก ์ƒ๋‹จ ๊ฐ•์ œ ๋ฐฐ์น˜
679
+ ---------------------------------------------------- */
680
  #diff_toggle_row {
681
+ display: flex !important;
682
+ justify-content: flex-end !important; /* ์˜ค๋ฅธ์ชฝ ๋์œผ๋กœ ๊ฐ•์ œ ์ •๋ ฌ */
683
  margin-top: 5px !important;
684
+ margin-bottom: -15px !important; /* ํ‘œ์™€ ๊ฐ€๊น๊ฒŒ ์•„๋ž˜๋กœ ๋‹น๊น€ */
685
+ padding-right: 10px !important;
686
  }
687
 
688
  #diff_cb_item {
689
+ flex-grow: 0 !important; /* ๊ฐ€๋กœ ๊ณต๊ฐ„ ๋‹ค ์ฐจ์ง€ํ•˜๋Š” ๊ฒƒ ๋ฐฉ์ง€ */
690
+ width: max-content !important; /* ๊ธ€์ž ํฌ๊ธฐ๋งŒํผ๋งŒ ๋„ˆ๋น„ ์ฐจ์ง€ */
691
+ min-width: 0 !important;
 
 
 
 
692
  }
693
  """
694