Mariia5 commited on
Commit
5a1fe33
·
verified ·
1 Parent(s): cfff812

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +88 -82
app.py CHANGED
@@ -105,6 +105,8 @@ def footer():
105
 
106
  def main():
107
  st.title("Закупочный Патруль")
 
 
108
 
109
  # Кнопка для загрузки PDF файла
110
  pdf_files = st.file_uploader("Загрузите PDF Извещения", type=["pdf"], accept_multiple_files=True)
@@ -113,6 +115,7 @@ def main():
113
  pdf_doc = fitz.open(stream=bytes_data, filetype="pdf")
114
  st.write("Файл Извещения:", pdf_file.name)
115
  #st.write(pdf_doc[0].get_text())
 
116
 
117
  # Кнопка для загрузки DOCX файла
118
  docx_files = st.file_uploader("Загрузите DOCX файл ПК", type=["docx"], accept_multiple_files=True)
@@ -121,11 +124,13 @@ def main():
121
  doc = Document(BytesIO(doc_bytes))
122
  #st.write(doc.paragraphs[0].text)
123
  st.write("файл ПК:", docx_file.name)
 
124
 
125
 
126
  # Кнопка начала проверки
127
  if st.button("Проверить", type="primary"):
128
- if pdf_file is not None and docx_file is not None:
 
129
 
130
  print("=" * 80)
131
  st.write("_" * 80)
@@ -201,91 +206,92 @@ def main():
201
  #st.write(":magenta[ERROR при сравнении, пожалуйста проверьте документ!]")
202
  st.write(f"ERROR при сравнении {ex}")
203
  # break
204
- print("=" * 80)
205
- st.write("_" * 80)
206
- """
207
- ЧАСТЬ 2 "Обеспечение гарантийных обязательств"
208
- """
209
-
210
- # Поле для вывода комментария после проверки
211
- # result_comment_area = st.text_area(f"Результат проверки : {result_comment}")
212
-
213
- # достаем параграфы текстовые из документов
214
- paragraphs = get_doc_blocks(doc)
215
- pdf_blocks = get_pdf_blocks(pdf_doc)
216
-
217
- try:
218
- garant_pdf = detect_garant_pdf(pdf_blocks, debug_print=False)
219
- garant_docx = detect_garant_doc(paragraphs, debug_print=False)
220
-
221
- MCKs = get_mck(pdf_blocks, debug_print=False)
222
- price_doc = detect_garant_doc_price(paragraphs, debug_print=False)
223
-
224
- #print(colored("ERROR при прочтении, пожалуйста проверьте документ!", 'magenta'))
225
- except Exception as ex:
226
- # st.write(f"ERROR при прочтении ЧАСТЬ 2, ")
227
- st.write(f":red[ERROR при прочтении ЧАСТЬ 2, {ex}]")
228
-
229
- check_garant(
230
- garant_pdf=garant_pdf,
231
- garant_docx=garant_docx,
232
- price_doc=price_doc,
233
- MCKs=MCKs
234
- )
235
- print("=" * 80)
236
- st.write("_" * 80)
237
- """
238
- ЧАСТЬ 3 "ИКЗ"
239
- """
240
-
241
- ikz_pdf = get_ikz_pdf(pdf_blocks)
242
- ikz_docx = get_ikz_doc(doc)
243
- if ikz_docx and ikz_pdf:
244
- ikz_docx_clean = set(
245
- [el.replace("-", '') for el in ikz_docx]
246
- )
247
- ikz_pdf_clean = set(
248
- [el.replace("-", '') for el in ikz_pdf]
249
  )
250
- if ikz_docx_clean == ikz_pdf_clean:
251
- # print(colored("РАВНЫ", 'green'))
252
- st.write(":green[РАВНЫ]")
253
- # st.write("РАВНЫ")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  else:
255
- # print(colored("ОШИБКА", 'magenta'))
 
 
 
 
 
 
 
 
 
 
 
 
256
  st.write(":red[ОШИБКА]")
257
- # st.write("ОШИБКА")
258
- for el in sorted(ikz_docx_clean):
259
- if el not in ikz_pdf_clean:
260
- # print(f"ИКЗ {el} присутствует в .docx, но не в .pdf")
261
- st.write(f"ИКЗ {el} присутствует в .docx, но не в .pdf")
262
- print("-" * 60)
263
- st.write("-" * 60)
264
- for el in sorted(ikz_pdf_clean):
265
- if el not in ikz_docx_clean:
266
- # print(f"ИКЗ {el} присутствует в .pdf, но не в .docx")
267
- st.write(f"ИКЗ {el} присутствует в .pdf, но не в .docx")
268
- else:
269
- # print(colored("ПУСТОЕ ЗНАЧЕНИЕ", 'magenta'))
270
- st.write(":red[ПУСТОЕ ЗНАЧЕНИЕ]")
271
- # st.write("ПУСТОЕ ЗНАЧЕНИЕ")
272
-
273
- print("=" * 80)
274
- st.write("_" * 80)
275
- """
276
- ЧАСТЬ 4 "часть 1 статьи 93 ФЗ-44 в ПК"
277
- """
278
-
279
- fz93_docx = get_fz93_doc(doc)
280
- if fz93_docx: # проверка на пустоту, если есть ст.93 - ОШИБКА
281
- print(colored("ОШИБКА", 'magenta'))
282
- st.write(":red[ОШИБКА]")
283
- print("ч. 1 ст. 93 ФЗ в ПК")
284
- st.write("ч. 1 ст. 93 ФЗ в ПК")
285
  else:
286
- print(colored("ВЕРНО", 'green'))
287
- st.write(":green[ВЕРНО]")
288
-
289
 
290
 
291
 
 
105
 
106
  def main():
107
  st.title("Закупочный Патруль")
108
+ pdf_files_list = []
109
+ docx_files_list = []
110
 
111
  # Кнопка для загрузки PDF файла
112
  pdf_files = st.file_uploader("Загрузите PDF Извещения", type=["pdf"], accept_multiple_files=True)
 
115
  pdf_doc = fitz.open(stream=bytes_data, filetype="pdf")
116
  st.write("Файл Извещения:", pdf_file.name)
117
  #st.write(pdf_doc[0].get_text())
118
+ pdf_files_list.append(pdf_file) # Добавляем файл в список
119
 
120
  # Кнопка для загрузки DOCX файла
121
  docx_files = st.file_uploader("Загрузите DOCX файл ПК", type=["docx"], accept_multiple_files=True)
 
124
  doc = Document(BytesIO(doc_bytes))
125
  #st.write(doc.paragraphs[0].text)
126
  st.write("файл ПК:", docx_file.name)
127
+ docx_files_list.append(docx_file) # Добавляем файл в список
128
 
129
 
130
  # Кнопка начала проверки
131
  if st.button("Проверить", type="primary"):
132
+ #if pdf_file is not None and docx_file is not None:
133
+ if len(pdf_files_list) > 0 and len(docx_files_list) > 0:
134
 
135
  print("=" * 80)
136
  st.write("_" * 80)
 
206
  #st.write(":magenta[ERROR при сравнении, пожалуйста проверьте документ!]")
207
  st.write(f"ERROR при сравнении {ex}")
208
  # break
209
+ print("=" * 80)
210
+ st.write("_" * 80)
211
+ """
212
+ ЧАСТЬ 2 "Обеспечение гарантийных обязательств"
213
+ """
214
+
215
+ # Поле для вывода комментария после проверки
216
+ # result_comment_area = st.text_area(f"Результат проверки : {result_comment}")
217
+
218
+ # достаем параграфы текстовые из документов
219
+ paragraphs = get_doc_blocks(doc)
220
+ pdf_blocks = get_pdf_blocks(pdf_doc)
221
+
222
+ try:
223
+ garant_pdf = detect_garant_pdf(pdf_blocks, debug_print=False)
224
+ garant_docx = detect_garant_doc(paragraphs, debug_print=False)
225
+
226
+ MCKs = get_mck(pdf_blocks, debug_print=False)
227
+ price_doc = detect_garant_doc_price(paragraphs, debug_print=False)
228
+
229
+ #print(colored("ERROR при прочтении, пожалуйста проверьте документ!", 'magenta'))
230
+ except Exception as ex:
231
+ # st.write(f"ERROR при прочтении ЧАСТЬ 2, ")
232
+ st.write(f":red[ERROR при прочтении ЧАСТЬ 2, {ex}]")
233
+
234
+ check_garant(
235
+ garant_pdf=garant_pdf,
236
+ garant_docx=garant_docx,
237
+ price_doc=price_doc,
238
+ MCKs=MCKs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  )
240
+ print("=" * 80)
241
+ st.write("_" * 80)
242
+ """
243
+ ЧАСТЬ 3 "ИКЗ"
244
+ """
245
+
246
+ ikz_pdf = get_ikz_pdf(pdf_blocks)
247
+ ikz_docx = get_ikz_doc(doc)
248
+ if ikz_docx and ikz_pdf:
249
+ ikz_docx_clean = set(
250
+ [el.replace("-", '') for el in ikz_docx]
251
+ )
252
+ ikz_pdf_clean = set(
253
+ [el.replace("-", '') for el in ikz_pdf]
254
+ )
255
+ if ikz_docx_clean == ikz_pdf_clean:
256
+ # print(colored("РАВНЫ", 'green'))
257
+ st.write(":green[РАВНЫ]")
258
+ # st.write("РАВНЫ")
259
+ else:
260
+ # print(colored("ОШИБКА", 'magenta'))
261
+ st.write(":red[ОШИБКА]")
262
+ # st.write("ОШИБКА")
263
+ for el in sorted(ikz_docx_clean):
264
+ if el not in ikz_pdf_clean:
265
+ # print(f"ИКЗ {el} присутствует в .docx, но не в .pdf")
266
+ st.write(f"ИКЗ {el} присутствует в .docx, но не в .pdf")
267
+ print("-" * 60)
268
+ st.write("-" * 60)
269
+ for el in sorted(ikz_pdf_clean):
270
+ if el not in ikz_docx_clean:
271
+ # print(f"ИКЗ {el} присутствует в .pdf, но не в .docx")
272
+ st.write(f"ИКЗ {el} присутствует в .pdf, но не в .docx")
273
  else:
274
+ # print(colored("ПУСТОЕ ЗНАЧЕНИЕ", 'magenta'))
275
+ st.write(":red[ПУСТОЕ ЗНАЧЕНИЕ]")
276
+ # st.write("ПУСТОЕ ЗНАЧЕНИЕ")
277
+
278
+ print("=" * 80)
279
+ st.write("_" * 80)
280
+ """
281
+ ЧАСТЬ 4 "часть 1 статьи 93 ФЗ-44 в ПК"
282
+ """
283
+
284
+ fz93_docx = get_fz93_doc(doc)
285
+ if fz93_docx: # проверка на пустоту, если есть ст.93 - ОШИБКА
286
+ print(colored("ОШИБКА", 'magenta'))
287
  st.write(":red[ОШИБКА]")
288
+ print("ч. 1 ст. 93 ФЗ в ПК")
289
+ st.write("ч. 1 ст. 93 ФЗ в ПК")
290
+ else:
291
+ print(colored("ВЕРНО", 'green'))
292
+ st.write(":green[ВЕРНО]")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  else:
294
+ st.write("Нет документов для проверки") # Сообщение, если нет загруженных файлов
 
 
295
 
296
 
297