import os filepath = 'schemas/20251121/linkml/modules/classes/FinancialStatement.yaml' with open(filepath, 'r') as f: lines = f.readlines() new_lines = [] skip = False for i, line in enumerate(lines): # In slot_usage for has_or_had_net_asset, there is a nested has_or_had_expenses # which is likely indentation error or copy-paste error. # line 369: has_or_had_net_asset: # line 370: range: decimal # line 371: required: false # line 372: has_or_had_expenses: <-- This should not be here? # It seems block is accidentally indented under . # It should be a sibling slot usage? # But is already imported. # Let's inspect the line indent. stripped = line.strip() if stripped.startswith('has_or_had_expenses:'): # Check indentation. indent = len(line) - len(line.lstrip()) # slot_usage is at 4 spaces. # has_or_had_net_asset is at 6 spaces. # properties of has_or_had_net_asset (range, required) are at 8 spaces. # If is at 8 spaces, it's inside definition. # If it's at 6 spaces, it's a new slot usage entry (which is correct). if indent == 8: # It's wrongly indented inside has_or_had_net_asset? # Or is it providing examples/defaults? # The structure looks like: # has_or_had_net_asset: # range: decimal # required: false # has_or_had_expenses: ... # This key is invalid for a SlotDefinition unless it's an annotation? # But here it contains a list of values. # It looks like an example block that got misplaced as a property key? # Looking at the content: # has_or_had_expenses: # - value: # - has_or_had_type: PROGRAM # This looks like content? # Let's see if we can just dedent it to 6 spaces to make it a slot usage? # But is already defined in list. # Does have slot? Yes. # So at 6 spaces would define usage for that slot. # Let's check output around line 372. # has_or_had_net_asset: # range: decimal # required: false # has_or_had_expenses: # - value: ... # Yes, it's at same level as . # If I dedent it to 6 spaces, it becomes a slot_usage entry. # BUT slot usage might already exist? # No, I don't see another one in the file read output. # So the fix is to dedent and its block. pass new_lines.append(line) # Let's write a script to fix indentation.