# import ast
# from copy import deepcopy

# class SymbolReplacer(ast.NodeTransformer):
#     def __init__(self, symbol_table):
#         self.symbol_table = symbol_table

#     def visit_Name(self, node):
#         if node.id in self.symbol_table:
#             return deepcopy(self.symbol_table[node.id])
#         return node


# class SymbolReplacer_2(ast.NodeTransformer):
#     def __init__(self, symbol_table):
#         self.symbol_table = symbol_table

#     def visit_Attribute(self, node):
#         if 'symbol_interpolate' in self.symbol_table:
#             node.attr = node.attr.replace('symbol_interpolate', str(self.symbol_table['symbol_interpolate'].n))

#             if hasattr(node.value, "attr"):
#                 node.value.attr = node.value.attr.replace('symbol_interpolate', str(self.symbol_table['symbol_interpolate'].n))

#         return node


# def replace_symbols(tree, symbol_table):
#     temp = SymbolReplacer(symbol_table).visit(tree)
#     return SymbolReplacer_2(symbol_table).visit(temp)

import libcst as cst

from .node_replacer import NodeReplacer

class SymbolReplacer(NodeReplacer):
    def _get_key(self, node: cst.CSTNode):
        if isinstance(node, cst.Name):
            return node.value
        else:
            return None

def replace_symbols(tree, symbol_table):
    return tree.visit(SymbolReplacer(symbol_table))

2e6f75b4adf2eaa8bc8572dd8584156ef38cc63c
<mask token>


class SymbolReplacer(NodeReplacer):
    <mask token>


<mask token>

<mask token>


class SymbolReplacer(NodeReplacer):

    def _get_key(self, node: cst.CSTNode):
        if isinstance(node, cst.Name):
            return node.value
        else:
            return None


<mask token>

<mask token>


class SymbolReplacer(NodeReplacer):

    def _get_key(self, node: cst.CSTNode):
        if isinstance(node, cst.Name):
            return node.value
        else:
            return None


def replace_symbols(tree, symbol_table):
    return tree.visit(SymbolReplacer(symbol_table))

import libcst as cst
from .node_replacer import NodeReplacer


class SymbolReplacer(NodeReplacer):

    def _get_key(self, node: cst.CSTNode):
        if isinstance(node, cst.Name):
            return node.value
        else:
            return None


def replace_symbols(tree, symbol_table):
    return tree.visit(SymbolReplacer(symbol_table))

# import ast
# from copy import deepcopy

# class SymbolReplacer(ast.NodeTransformer):
#     def __init__(self, symbol_table):
#         self.symbol_table = symbol_table

#     def visit_Name(self, node):
#         if node.id in self.symbol_table:
#             return deepcopy(self.symbol_table[node.id])
#         return node


# class SymbolReplacer_2(ast.NodeTransformer):
#     def __init__(self, symbol_table):
#         self.symbol_table = symbol_table

#     def visit_Attribute(self, node):
#         if 'symbol_interpolate' in self.symbol_table:
#             node.attr = node.attr.replace('symbol_interpolate', str(self.symbol_table['symbol_interpolate'].n))

#             if hasattr(node.value, "attr"):
#                 node.value.attr = node.value.attr.replace('symbol_interpolate', str(self.symbol_table['symbol_interpolate'].n))

#         return node


# def replace_symbols(tree, symbol_table):
#     temp = SymbolReplacer(symbol_table).visit(tree)
#     return SymbolReplacer_2(symbol_table).visit(temp)

import libcst as cst

from .node_replacer import NodeReplacer

class SymbolReplacer(NodeReplacer):
    def _get_key(self, node: cst.CSTNode):
        if isinstance(node, cst.Name):
            return node.value
        else:
            return None

def replace_symbols(tree, symbol_table):
    return tree.visit(SymbolReplacer(symbol_table))
