COMMAND_RE = re.compile('([A-Z_ ]+[A-Z]) ?(.+)? *')

def get_params(fname, desired_command):
    with open(fname, 'r') as f:
        content = f.read()
for element in content.split('$'):
    element = element.replace('\n', ' ').strip()
if not element:
    continue
command, result = COMMAND_RE.search(element).groups()
if desired_command == command or desired_command == '${}'.format(command):
    return result or True
Читать и анализировать файл токенов?