- Removed obsolete slots: `has_or_had_custodian_observation`, `provider`, and `specificity_annotation`. - Updated `has_or_had_score` slot to use `SpecificityScore` class and modified its description and examples. - Added new slots: `end_seconds`, `end_time`, `has_archive_path`, `has_or_had_custodian_name`, `protocol_name`, and `protocol_version`. - Introduced a script `check_annotation_types.py` to validate the presence and structure of `custodian_types` in YAML files. - Added a script `update_specificity.py` to automate updates related to `SpecificityAnnotation` to `SpecificityScore`.
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
import os
|
|
|
|
def fix_file(path):
|
|
filename = os.path.basename(path)
|
|
classname = filename.replace('.yaml', '')
|
|
|
|
with open(path, 'r') as f:
|
|
lines = f.readlines()
|
|
|
|
new_lines = []
|
|
in_imports = False
|
|
modified = False
|
|
|
|
for line in lines:
|
|
stripped = line.strip()
|
|
if stripped == "imports:":
|
|
in_imports = True
|
|
new_lines.append(line)
|
|
continue
|
|
|
|
if in_imports:
|
|
if not stripped.startswith("-"):
|
|
if stripped and not stripped.startswith("#"):
|
|
in_imports = False
|
|
new_lines.append(line)
|
|
else:
|
|
import_path = stripped.lstrip("- ").strip()
|
|
# Check for self-import: - ./ClassName
|
|
if import_path == f"./{classname}":
|
|
print(f"Removing self-import in {path}: {stripped}")
|
|
modified = True
|
|
continue
|
|
else:
|
|
new_lines.append(line)
|
|
else:
|
|
new_lines.append(line)
|
|
|
|
if modified:
|
|
with open(path, 'w') as f:
|
|
f.writelines(new_lines)
|
|
|
|
def process_directory(directory):
|
|
for root, dirs, files in os.walk(directory):
|
|
for file in files:
|
|
if file.endswith(".yaml"):
|
|
fix_file(os.path.join(root, file))
|
|
|
|
process_directory("schemas/20251121/linkml/modules/classes")
|