def autogenReplace(autogenCmd, outputLines, autogenDict, entryDict):
    """
    Handle any pattern replacements requested by the user.
    """
    if not autogenDict.has_key('replace'):
        return
    for pathDict in autogenDict['replace']:
        pattern = pathDict['substitute']['pattern']
        containerDst = pathDict['path']
        roles = pathDict.get('onroles', None)
        macro = pathDict['substitute']['macro']
        with autogenCmd.getRoleIfContext(roles, outputLines) as ric:
            outputLines.append('%sREPLACE_PATTERN %s %s %s\n' % (ric.spaces,
                pattern, containerDst, macro))
        outputLines.append('\n')
    return
