def _ast_build_string(data): # used to return a string representation of AST data if isinstance(data, ast.Str): # Already a string, just return the value return utils.safe_str(data.s) if isinstance(data, ast.BinOp): # need to build the string from a binary operation return _ast_binop_stringify(data) if isinstance(data, ast.Name): # a variable, stringify the variable name return "[[" + utils.safe_str(data.id) + "]]" return "XXX" # placeholder for unaccounted for values
def string_val(self): '''Get a string value of a standalone string :return: String value of a standalone string ''' if 'str' in self._context: return utils.safe_str(self._context['str']) else: return None