def get_value(self, node):
        """Convert value from an AST node."""
        if not isinstance(node, ast.Dict):
            raise TypeError("must be a dictionary")

        evaluator = SafeEvaluator()
        try:
            value = evaluator.run(node)
        except Exception as ex:
            # TODO: Handle errors.
            raise ex

        try:
            # Ensure value is a serializable dictionary.
            value = json.loads(json.dumps(value))
            if not isinstance(value, dict):
                raise TypeError
        except (TypeError, ValueError):
            raise TypeError("must be serializable")

        return value
def get_value ( self , node ) : if not isinstance ( node , ast . Dict ) : raise TypeError ( "must be a dictionary" ) evaluator = SafeEvaluator ( ) try : value = evaluator . run ( node ) except Exception as ex : raise ex try : value = json . loads ( json . dumps ( value ) ) if not isinstance ( value , dict ) : raise TypeError except ( TypeError , ValueError ) : raise TypeError ( "must be serializable" ) return value
Convert value from an AST node.