import sys, importlib.util spec = importlib.util.spec_from_file_location('mod', r'C:\Users\SJ\.minimax-agent\projects\Workflow\scripts\SARS Retun History Period.py') m_mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(m_mod) print('SUBITEM_LABELS["EMP201"]:') label = m_mod.SUBITEM_LABELS['EMP201'] print(f' repr: {label!r}') print(f' bytes hex: {label.encode("utf-8").hex()}') apos = label[label.index("'")] print(f' apostrophe at pos {label.index("'")}: U+{ord(apos):04X}') # Get the actual snapshot snap = m_mod.run_ab('snapshot', '-i') # Find the EMP201 line for line in snap.split('\n'): if 'EMP201' in line: print(f'\nactual line: {line!r}') print(f' bytes hex: {line.encode("utf-8").hex()}') # Find the apostrophe i = line.index("Employee") apos = line[i+8] # "Employee" is 8 chars print(f' apostrophe at pos {i+8}: U+{ord(apos):04X}') # Test find_ref ref = m_mod.find_ref(line, 'link', label) print(f' find_ref result: {ref}') # Try with just `s Tax` substring import re m = re.search(r'Employee.Tax', line) print(f' Employee.Tax regex: {m}') if m: print(f' matched chars: {m.group()[8]!r} U+{ord(m.group()[8]):04X}') break