From 120f488d9300d7da9fa4aaa20f12c4a937ba021e Mon Sep 17 00:00:00 2001 From: Alex Groleau Date: Fri, 17 Apr 2026 18:27:49 -0400 Subject: [PATCH] cleanup --- scripts/migrate_legacy_schemas.py | 55 ------------------------------- scripts/migrate_properly.py | 54 ------------------------------ scripts/revert_puncs_to_types.js | 41 ----------------------- scripts/revert_puncs_to_types.py | 29 ---------------- scripts/update_fixtures.js | 43 ------------------------ scripts/update_fixtures.py | 33 ------------------- 6 files changed, 255 deletions(-) delete mode 100644 scripts/migrate_legacy_schemas.py delete mode 100644 scripts/migrate_properly.py delete mode 100644 scripts/revert_puncs_to_types.js delete mode 100644 scripts/revert_puncs_to_types.py delete mode 100644 scripts/update_fixtures.js delete mode 100644 scripts/update_fixtures.py diff --git a/scripts/migrate_legacy_schemas.py b/scripts/migrate_legacy_schemas.py deleted file mode 100644 index c30c484..0000000 --- a/scripts/migrate_legacy_schemas.py +++ /dev/null @@ -1,55 +0,0 @@ -import json -import os -import glob - -fixtures_dir = 'fixtures' -for filepath in glob.glob(os.path.join(fixtures_dir, '*.json')): - try: - with open(filepath, 'r') as f: - data = json.load(f) - except Exception as e: - continue - - changed = False - for suite in data: - db = suite.get("database") - if not db or "schemas" not in db: - continue - - legacy_schemas = db["schemas"] - # Make sure types array is ready - if "types" not in db: - db["types"] = [] - - # Push schemas into types - for schema_id, schema_def in legacy_schemas.items(): - base_name = schema_id.split('.')[-1] - - # Find an existing type with base_name first - found = False - for t in db["types"]: - if t.get("name") == base_name: - if "schemas" not in t: - t["schemas"] = {} - t["schemas"][schema_id] = schema_def - found = True - break - - if not found: - db["types"].append({ - "name": base_name, - "variations": [base_name], # Optional placeholder, shouldn't break anything - "hierarchy": [base_name, "entity"], - "schemas": { - schema_id: schema_def - } - }) - - # Clean up legacy global map - del db["schemas"] - changed = True - - if changed: - with open(filepath, 'w') as f: - json.dump(data, f, indent=2) - print("Migrated legacy schemas to types in", filepath) diff --git a/scripts/migrate_properly.py b/scripts/migrate_properly.py deleted file mode 100644 index fedf73e..0000000 --- a/scripts/migrate_properly.py +++ /dev/null @@ -1,54 +0,0 @@ -import json -import os -import glob - -fixtures_dir = 'fixtures' -for filepath in glob.glob(os.path.join(fixtures_dir, '*.json')): - try: - with open(filepath, 'r') as f: - data = json.load(f) - except Exception as e: - print(f"Failed to load {filepath}: {e}") - continue - - changed = False - for suite in data: - db = suite.get("database") - if not db or "schemas" not in db: - continue - - legacy_schemas = db["schemas"] - # Make sure types array is ready - if "types" not in db: - db["types"] = [] - - # Push schemas into types - for schema_id, schema_def in legacy_schemas.items(): - base_name = schema_id.split('.')[-1] - - # Find an existing type with base_name first - found = False - for t in db["types"]: - if t.get("name") == base_name: - if "schemas" not in t: - t["schemas"] = {} - t["schemas"][schema_id] = schema_def - found = True - break - - if not found: - db["types"].append({ - "name": base_name, - "schemas": { - schema_id: schema_def - } - }) - - # Clean up legacy global map - del db["schemas"] - changed = True - - if changed: - with open(filepath, 'w') as f: - json.dump(data, f, indent=2) - print("Migrated legacy schemas to types properly in", filepath) diff --git a/scripts/revert_puncs_to_types.js b/scripts/revert_puncs_to_types.js deleted file mode 100644 index 0de3656..0000000 --- a/scripts/revert_puncs_to_types.js +++ /dev/null @@ -1,41 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -function updateFile(filePath) { - let content = fs.readFileSync(filePath, 'utf8'); - let data; - try { - data = JSON.parse(content); - } catch (e) { - console.error("Failed to parse " + filePath, e); - return; - } - - let changed = false; - for (let suite of data) { - if (suite.database && suite.database.puncs && suite.database.puncs.length > 0) { - if (!suite.database.types) suite.database.types = []; - for (let punc of suite.database.puncs) { - // Determine if we should push it to types. - // Basically all of them should go to types except maybe if they are explicitly being tested as Puncs? - // But the tests construct Queryer and Merger using these ids, which query the Type Realm. - suite.database.types.push(punc); - } - delete suite.database.puncs; - changed = true; - } - } - - if (changed) { - fs.writeFileSync(filePath, JSON.stringify(data, null, 2)); - console.log("Reverted puncs to types in " + filePath); - } -} - -let fixturesDir = 'fixtures'; -let files = fs.readdirSync(fixturesDir); -for (let file of files) { - if (file.endsWith('.json')) { - updateFile(path.join(fixturesDir, file)); - } -} diff --git a/scripts/revert_puncs_to_types.py b/scripts/revert_puncs_to_types.py deleted file mode 100644 index 6541fc1..0000000 --- a/scripts/revert_puncs_to_types.py +++ /dev/null @@ -1,29 +0,0 @@ -import json -import os -import glob - -fixtures_dir = 'fixtures' -for filepath in glob.glob(os.path.join(fixtures_dir, '*.json')): - with open(filepath, 'r') as f: - try: - data = json.load(f) - except Exception as e: - print("Failed to parse", filepath, e) - continue - - changed = False - for suite in data: - db = suite.get("database", {}) - puncs = db.get("puncs", []) - if puncs: - if "types" not in db: - db["types"] = [] - for punc in puncs: - db["types"].append(punc) - del db["puncs"] - changed = True - - if changed: - with open(filepath, 'w') as f: - json.dump(data, f, indent=2) - print("Reverted puncs to types in", filepath) diff --git a/scripts/update_fixtures.js b/scripts/update_fixtures.js deleted file mode 100644 index 243f381..0000000 --- a/scripts/update_fixtures.js +++ /dev/null @@ -1,43 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -function updateFile(filePath) { - let content = fs.readFileSync(filePath, 'utf8'); - let data; - try { - data = JSON.parse(content); - } catch (e) { - console.error("Failed to parse " + filePath, e); - return; - } - - let changed = false; - for (let suite of data) { - if (suite.database && suite.database.schemas) { - if (!suite.database.puncs) suite.database.puncs = []; - for (let id of Object.keys(suite.database.schemas)) { - let schema = suite.database.schemas[id]; - let puncType = { - name: id, - schemas: { [id]: schema } - }; - suite.database.puncs.push(puncType); - } - delete suite.database.schemas; - changed = true; - } - } - - if (changed) { - fs.writeFileSync(filePath, JSON.stringify(data, null, 2)); - console.log("Updated " + filePath); - } -} - -let fixturesDir = 'fixtures'; -let files = fs.readdirSync(fixturesDir); -for (let file of files) { - if (file.endsWith('.json')) { - updateFile(path.join(fixturesDir, file)); - } -} diff --git a/scripts/update_fixtures.py b/scripts/update_fixtures.py deleted file mode 100644 index 83dea54..0000000 --- a/scripts/update_fixtures.py +++ /dev/null @@ -1,33 +0,0 @@ -import json -import os - -fixtures_dir = 'fixtures' - -for filename in os.listdir(fixtures_dir): - if not filename.endswith('.json'): - continue - filepath = os.path.join(fixtures_dir, filename) - with open(filepath, 'r') as f: - try: - data = json.load(f) - except json.JSONDecodeError: - print("Failed to parse", filepath) - continue - changed = False - for suite in data: - db = suite.get('database', {}) - if 'schemas' in db: - if 'types' not in db: - db['types'] = [] - for id_str, schema in db['schemas'].items(): - target_type = { - 'name': id_str, - 'schemas': { id_str: schema } - } - db['types'].append(target_type) - del db['schemas'] - changed = True - if changed: - with open(filepath, 'w') as f: - json.dump(data, f, indent=2) - print("Updated", filepath)