- Updated manifest.json with new generated timestamp. - Added close mappings to APIRequest and Administration classes. - Renamed slots in AccessPolicy to has_or_had_embargo_end_date and has_or_had_embargo_reason. - Changed class_uri for Accumulation to rico:AccumulationRelation and updated description. - Added exact mappings to Altitude, AppellationType, and ArchitecturalStyle classes. - Removed deprecated slots from CollectionManagementSystem and updated has_or_had_type. - Added new slots for has_or_had_embargo_end_date and has_or_had_embargo_reason. - Updated slot definitions for has_or_had_assessment, has_or_had_sequence_index, and others with new URIs and mappings. - Removed unused slots end_seconds and end_time. - Added new slot definitions for has_or_had_exhibition_type, has_or_had_extent_text, and is_or_was_documented_by.
61 lines
2.1 KiB
Python
61 lines
2.1 KiB
Python
import yaml
|
|
import os
|
|
import shutil
|
|
|
|
# Paths
|
|
SLOT_FIXES_PATH = "/Users/kempersc/apps/glam/data/fixes/slot_fixes.yaml"
|
|
SLOTS_DIR = "/Users/kempersc/apps/glam/schemas/20251121/linkml/modules/slots/"
|
|
ARCHIVE_DIR = os.path.join(SLOTS_DIR, "archive")
|
|
|
|
# Ensure archive directory exists
|
|
os.makedirs(ARCHIVE_DIR, exist_ok=True)
|
|
|
|
def get_processed_slots(fixes_path):
|
|
processed_slots = []
|
|
try:
|
|
with open(fixes_path, 'r') as f:
|
|
data = yaml.safe_load(f)
|
|
|
|
if 'fixes' in data:
|
|
for fix in data['fixes']:
|
|
if fix.get('processed', {}).get('status') == True:
|
|
# Extract slot name from URL
|
|
# e.g., https://nde.nl/ontology/hc/slot/activities_societies -> activities_societies
|
|
original_id = fix.get('original_slot_id', '')
|
|
if '/slot/' in original_id:
|
|
slot_name = original_id.split('/slot/')[-1]
|
|
processed_slots.append(slot_name)
|
|
except Exception as e:
|
|
print(f"Error reading YAML: {e}")
|
|
# Fallback to simple parsing if yaml load fails (e.g. huge file)
|
|
# This is less robust but works for simple structure
|
|
pass
|
|
|
|
return processed_slots
|
|
|
|
def main():
|
|
print(f"Reading fixes from {SLOT_FIXES_PATH}...")
|
|
processed_slots = get_processed_slots(SLOT_FIXES_PATH)
|
|
print(f"Found {len(processed_slots)} processed slots in fixes file.")
|
|
|
|
# Get current slot files
|
|
current_files = os.listdir(SLOTS_DIR)
|
|
|
|
moved_count = 0
|
|
for slot_name in processed_slots:
|
|
filename = f"{slot_name}.yaml"
|
|
src_path = os.path.join(SLOTS_DIR, filename)
|
|
dst_path = os.path.join(ARCHIVE_DIR, filename)
|
|
|
|
if os.path.exists(src_path):
|
|
print(f"Moving {filename} to archive...")
|
|
try:
|
|
shutil.move(src_path, dst_path)
|
|
moved_count += 1
|
|
except Exception as e:
|
|
print(f"Failed to move {filename}: {e}")
|
|
|
|
print(f"Operation complete. Archived {moved_count} files.")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|