def track(node): if node.type == "file": node = node.getChild("call") if node.type == "call": isClass = False oper = node.getChild("operand", False) if oper: vari = oper.getChild("variable", False) if vari: isClass = (treeutil.assembleVariable(vari))[0] == "qx.Class.define" if not isClass: return classname = node.getChild("params").getChild("constant").get("value") print "Found class: %s" % classname config = node.getChild("params").getChild("map") for entry in config.children: if entry.get("key") == "statics": print "Scanning statics..." statics = mapScan(entry.getChild("value").getChild("map")) if entry.get("key") == "members": print "Scanning members..." members = mapScan(entry.getChild("value").getChild("map"))
def track(node): if node.type == "file": node = node.getChild("call") if node.type == "call": isClass = False oper = node.getChild("operand", False) if oper: vari = oper.getChild("variable", False) if vari: isClass = ( treeutil.assembleVariable(vari))[0] == "qx.Class.define" if not isClass: return classname = node.getChild("params").getChild("constant").get("value") print "Found class: %s" % classname config = node.getChild("params").getChild("map") for entry in config.children: if entry.get("key") == "statics": print "Scanning statics..." statics = mapScan(entry.getChild("value").getChild("map")) if entry.get("key") == "members": print "Scanning members..." members = mapScan(entry.getChild("value").getChild("map"))
def search_loop(node, stringMap={}, verbose=False): if node.type == "call": oper = node.getChild("operand", False) if oper: variable = oper.getChild("variable", False) if variable: try: variableName = (treeutil.assembleVariable(variable))[0] except tree.NodeAccessException: variableName = None # Don't extract from locales if variableName == "qx.locale.Locale.define" or variableName == "qx.Locale.define": return stringMap if node.type == "constant" and node.get("constantType") == "string": if verbose: pvalue = node.get("value") if isinstance(pvalue, unicode): pvalue = pvalue.encode("utf-8") print " - Found: '%s'" % pvalue if node.get("detail") == "singlequotes": quote = "'" elif node.get("detail") == "doublequotes": quote = '"' value = "%s%s%s" % (quote, node.get("value"), quote) if value in stringMap: stringMap[value] += 1 else: stringMap[value] = 1 if check(node, verbose): for child in node.children: search_loop(child, stringMap, verbose) return stringMap
def search_loop(node, stringMap={}, verbose=False): if node.type == "call": oper = node.getChild("operand", False) if oper: variable = oper.getChild("variable", False) if variable: try: variableName = (treeutil.assembleVariable(variable))[0] except tree.NodeAccessException: variableName = None # Don't extract from locales if variableName == "qx.Locale.define": return stringMap if node.type == "constant" and node.get("constantType") == "string": if verbose: pvalue = node.get("value") if isinstance(pvalue, unicode): pvalue = pvalue.encode("utf-8") print " - Found: '%s'" % pvalue if node.get("detail") == "singlequotes": quote = "'" elif node.get("detail") == "doublequotes": quote = '"' value = "%s%s%s" % (quote, node.get("value"), quote) if value in stringMap: stringMap[value] += 1 else: stringMap[value] = 1 if check(node, verbose): for child in node.children: search_loop(child, stringMap, verbose) return stringMap