Отфильтрованные схемы данных (исключены общие для всех сущностей поля
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import re
|
||||
import os
|
||||
|
||||
def generate_regex(s: str) -> str:
|
||||
return r"^(\s+)[\[']" + s + r"[\]']:\s*?(?:\n\1\s.*$)+"
|
||||
|
||||
aonprd_filter_keys = [
|
||||
"trait_markdown",
|
||||
"url",
|
||||
"markdown",
|
||||
"name",
|
||||
"rarity",
|
||||
"rarity_id",
|
||||
"legacy_id",
|
||||
"remaster_id",
|
||||
"primary_source_category",
|
||||
"source_markdown",
|
||||
"category",
|
||||
"id",
|
||||
"release_date",
|
||||
"search_markdown",
|
||||
"primary_source_group",
|
||||
"source",
|
||||
"source_category",
|
||||
"source_group",
|
||||
"spoilers",
|
||||
"trait",
|
||||
]
|
||||
|
||||
if __name__ == "__main__":
|
||||
pwd = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
input_dir = pwd + "/../output/aonprd"
|
||||
output_dir = pwd + "/aonprd"
|
||||
|
||||
only_files = [f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f))]
|
||||
|
||||
for file_name in only_files:
|
||||
print(file_name)
|
||||
with open(os.path.join(input_dir, file_name), "r") as file:
|
||||
content = file.read()
|
||||
|
||||
for key in aonprd_filter_keys:
|
||||
content = re.sub(generate_regex(key), "", content, 0, re.MULTILINE)
|
||||
content = re.sub(r"\n+", "\n", content)
|
||||
|
||||
with open(os.path.join(output_dir, file_name), "w") as file:
|
||||
file.write(content)
|
||||
|
||||
Reference in New Issue
Block a user