Yoon-gu Hwang commited on
Commit
912684e
1 Parent(s): e48a7e5

yield 삭제

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -30,7 +30,7 @@ generation = gr.Dropdown(
30
  download = gr.File(label="Download a file")
31
  text = gr.DataFrame()
32
 
33
- def write_docx(gen):
34
  filename = f'포켓몬{gen}.docx'
35
 
36
  document = Document()
@@ -50,7 +50,7 @@ def write_docx(gen):
50
 
51
  data_dict = []
52
  start, end = GEN_RANGE[gen]
53
- for k in range(start, end+1):
54
  name = pokemons[k-1]['name']
55
  number = pokemons[k-1]['number']
56
  types = pokemons[k-1]['types']
@@ -91,13 +91,9 @@ def write_docx(gen):
91
  hdr_cells[0].paragraphs[0].alignment = docx.enum.text.WD_ALIGN_PARAGRAPH.CENTER
92
 
93
  document.add_page_break()
94
- yield df[['No', '이름', '타입']], None
95
 
96
- print("Saving docx file...")
97
- print(f"{os.listdir()}")
98
  document.save(filename)
99
- print(f"{os.listdir()}")
100
- return df, filename
101
 
102
  demo = gr.Interface(write_docx, generation, [text, download], title="대치동 포켓몬 도감 생성기",
103
  description="원하는 포켓몬 세대를 선택하고, 다운로드를 눌러주세요.")
 
30
  download = gr.File(label="Download a file")
31
  text = gr.DataFrame()
32
 
33
+ def write_docx(gen, progress=gr.Progress()):
34
  filename = f'포켓몬{gen}.docx'
35
 
36
  document = Document()
 
50
 
51
  data_dict = []
52
  start, end = GEN_RANGE[gen]
53
+ for k in progress.tqdm(range(start, end+1)):
54
  name = pokemons[k-1]['name']
55
  number = pokemons[k-1]['number']
56
  types = pokemons[k-1]['types']
 
91
  hdr_cells[0].paragraphs[0].alignment = docx.enum.text.WD_ALIGN_PARAGRAPH.CENTER
92
 
93
  document.add_page_break()
 
94
 
 
 
95
  document.save(filename)
96
+ return df[['No', '이름', '타입']], filename
 
97
 
98
  demo = gr.Interface(write_docx, generation, [text, download], title="대치동 포켓몬 도감 생성기",
99
  description="원하는 포켓몬 세대를 선택하고, 다운로드를 눌러주세요.")