From eaab7678d3f6c75524298225c3e26a9b90158561 Mon Sep 17 00:00:00 2001 From: Vaclav Lunak Date: Mon, 12 Jun 2023 19:54:38 +0200 Subject: [PATCH] remove stray file --- create_cr_and_diff.py | 1 - generate_forced_matches.py | 54 -------------------------------------- 2 files changed, 55 deletions(-) delete mode 100644 generate_forced_matches.py diff --git a/create_cr_and_diff.py b/create_cr_and_diff.py index d7ca05c..c128d5d 100644 --- a/create_cr_and_diff.py +++ b/create_cr_and_diff.py @@ -1,7 +1,6 @@ import asyncio import json import os -import sys from app.difftool.diffmaker import CRDiffMaker from app.parsing.cr import extract_cr diff --git a/generate_forced_matches.py b/generate_forced_matches.py deleted file mode 100644 index 4414ccf..0000000 --- a/generate_forced_matches.py +++ /dev/null @@ -1,54 +0,0 @@ -import json - -from dotenv import load_dotenv -from sqlalchemy import select - -from app.database.models import Cr -from app.difftool.diffmaker import CRDiffMaker - -load_dotenv() - -import app.database.operations as ops -from app.database.db import SessionLocal - -session = SessionLocal() - - -def get_cr(set_code): - stmt = select(Cr.data).where(Cr.set_code == set_code) - return session.execute(stmt).scalar_one() - - -def in_diff(diff, match): - matched_list = [ - x - for x in diff - if diff["old"] and diff["new"] and diff["old"]["ruleNum"] == match[0] and diff["new"]["ruleNum"] == match[1] - ] - return len(matched_list) > 0 - - -forced = "./gen/forced-matches" -out = "./gen/matches" - -diff_list = ops.get_cr_diff_metadata(session) -cr_list = ops.get_cr_metadata(session) -for date, old_code, new_code, _, _ in diff_list: - diff = ops.get_cr_diff(session, old_code, new_code) - changes = diff.changes - forced_list = [] - for change in diff.changes: - old = change.get("old") or {} - new = change.get("new") or {} - forced_list.append((old.get("ruleNum"), new.get("ruleNum"))) - with open(f"{forced}/{new_code}.json", "w") as f: - json.dump(forced_list, f) - - print("Parsing:", old_code, new_code) - old_cr = get_cr(old_code) - new_cr = get_cr(new_code) - generated_diff = CRDiffMaker(forced_list).diff(old_cr, new_cr) - with open(f"{out}/{new_code}.json", "w") as f: - json.dump(generated_diff.moved, f) - -session.close()