def prepare_command(message, args, pipeline_data):
    """ Munges the message data based off results of earlier match data """
    command = args[0]

    # replace group place holders
    # unnamed groups replace $groupnumber with the result
    #   e.g. $1
    # named groups use $groupname
    #   e.g. $file_name
    if "pattern" in pipeline_data:
        match = pipeline_data["pattern"]
        for idx, val in enumerate(match.groups()):
            group = idx + 1 # 0 is the full matched text
            command = command.replace("$" + str(group), val)

        for group,val in match.groupdict().items():
            command = command.replace("$" + group, val)

    # $_ is replaced with the message data
    command = command.replace("$_", message['data'])

    # set the data to the expanded version
    message['data'] = command
    return command
dataset/ETHPy150Open lionicsheriff/SublimeAcmePlumbing/Commands.py/prepare_command/original