pyxl_strings.py 464 B

12345678910111213141516171819
  1. from macropy.core.macros import *
  2. import tokenize
  3. from pyxl.codec.tokenizer import pyxl_tokenize
  4. macros = Macros()
  5. @macros.expr
  6. def p(tree, **kw):
  7. import StringIO
  8. new_string = tokenize.untokenize(pyxl_tokenize(StringIO.StringIO('(' + tree.s + ')').readline)).rstrip().rstrip("\\")
  9. total_string = "from __future__ import unicode_literals;" + new_string
  10. new_tree = ast.parse(total_string)
  11. return new_tree.body[1].value