|
@@ -0,0 +1,64 @@
|
|
|
+"""
|
|
|
+https://www.cyberforum.ru/python-graphics/thread2712141.html
|
|
|
+"""
|
|
|
+import os
|
|
|
+from difflib import SequenceMatcher
|
|
|
+from tqdm import tqdm
|
|
|
+import datetime
|
|
|
+import requests
|
|
|
+
|
|
|
+# ссылка для проверки
|
|
|
+url = "http://213.155.192.79:3001/u20-24koroba/up/raw/be2bd3bd45509d1d3683f5866088beccaa7500ad/%d0%ad%d0%90%d0%a1%d0%b2%d0%97%d0%98/%d0%9b%d0%b5%d0%ba%d1%86%d0%b8%d0%b8/%d0%9f1.1.10_%d0%a0%d0%b0%d1%81%d1%81%d0%bc%d0%be%d1%82%d1%80%d0%b5%d0%bd%d0%b8%d0%b5_%d0%bf%d1%80%d0%b8%d0%bc%d0%b5%d1%80%d0%be%d0%b2_%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%be%d0%bd%d0%b8%d1%80%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d1%8f_%d0%90%d0%98%d0%a1/%d0%9a%d0%be%d1%80%d0%be%d0%b1%d0%b0.md"
|
|
|
+
|
|
|
+# директория файла
|
|
|
+BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
|
|
+print()
|
|
|
+
|
|
|
+response = requests.get(url)
|
|
|
+post_html = response.text
|
|
|
+
|
|
|
+files_paths = []
|
|
|
+dirs = os.listdir(BASE_DIR)
|
|
|
+for dir in dirs:
|
|
|
+ dir_path = os.path.join(BASE_DIR, dir)
|
|
|
+ if os.path.isdir(dir_path) and (dir != "__pycache__"):
|
|
|
+ files = os.listdir(dir_path)
|
|
|
+ for file in files:
|
|
|
+ file_path = os.path.join(BASE_DIR, dir, file)
|
|
|
+ filename, fileext = os.path.splitext(file)
|
|
|
+
|
|
|
+ if os.path.isfile(file_path) and (fileext=='.md'):
|
|
|
+ files_paths.append(file_path)
|
|
|
+
|
|
|
+out_str = ""
|
|
|
+max_ratio = 0
|
|
|
+max_ratio_file = ""
|
|
|
+for file_1 in tqdm(files_paths):
|
|
|
+ small_filename_1 = str(file_1).replace(BASE_DIR, "").strip("\\")
|
|
|
+ try:
|
|
|
+ with open(file_1, encoding="utf-8") as f_1:
|
|
|
+ str1 = f_1.read()
|
|
|
+ except:
|
|
|
+ with open(file_1, encoding="cp1251") as f_1:
|
|
|
+ str1 = f_1.read()
|
|
|
+ f_1.close()
|
|
|
+ with open(file_1, 'w', encoding="utf-8") as f_1:
|
|
|
+ f_1.write(str1)
|
|
|
+ f_1.close()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ratio = int(SequenceMatcher(None, str1.lower(), post_html.lower()).ratio() * 100)
|
|
|
+ if (ratio > 70):
|
|
|
+ out_str += f"{small_filename_1}\n"
|
|
|
+ out_str += f"ratio = {ratio}\n"
|
|
|
+ if (ratio > max_ratio):
|
|
|
+ max_ratio = ratio
|
|
|
+ max_ratio_file = small_filename_1
|
|
|
+
|
|
|
+print(out_str)
|
|
|
+print()
|
|
|
+print(f"max ratio: {max_ratio}%")
|
|
|
+print(f"max ratio file: {max_ratio_file}")
|
|
|
+print("success")
|
|
|
+
|