def transform_expression(expr, mapping):
    """Returns a new expression string with the names transformed based on
    the value of the mapping dict.  Note that this transforms only from
    the beginning of a name, so for example, if you have abc.xyz.abc and
    a mapping of { 'abc': 'XXX' }, you'll get 'XXX.xyz.abc', not
    'XXX.xyz.XXX'.
    """
    if expr in mapping:
        return mapping[expr]

    new_ast = ExprNameTransformer(mapping).visit(ast.parse(expr, mode='eval'))
    ast.fix_missing_locations(new_ast)

    ep = ExprPrinter()
    ep.visit(new_ast)
    return ep.get_text()
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/printexpr.py/transform_expression/original