Coverage for /pythoncovmergedfiles/medio/medio/src/underscore/underscore/constant_changer.py: 75%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright (c) 2013 Huan Do, http://huan.do
3import ast
5from utils import value_of
7class ConstantChanger(ast.NodeTransformer):
9 def __init__(self, env):
10 self.env = env
12 def visit_Constant(self, node):
13 if not hasattr(node, 'isdoc'):
14 value = value_of(node)
15 return ast.Name(id=self.env.constants[value].name)
16 else:
17 return node
19 visit_Num = visit_Str = visit_Constant