home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / lib2to3 / fixes / fix_unicode.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  1.1 KB  |  32 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''Fixer that changes unicode to str, unichr to chr, and u"..." into "...".
  5.  
  6. '''
  7. import re
  8. from pgen2 import token
  9. from  import fixer_base
  10.  
  11. class FixUnicode(fixer_base.BaseFix):
  12.     PATTERN = "STRING | NAME<'unicode' | 'unichr'>"
  13.     
  14.     def transform(self, node, results):
  15.         if node.type == token.NAME:
  16.             if node.value == 'unicode':
  17.                 new = node.clone()
  18.                 new.value = 'str'
  19.                 return new
  20.             if node.value == 'unichr':
  21.                 new = node.clone()
  22.                 new.value = 'chr'
  23.                 return new
  24.         elif node.type == token.STRING:
  25.             if re.match('[uU][rR]?[\\\'\\"]', node.value):
  26.                 new = node.clone()
  27.                 new.value = new.value[1:]
  28.                 return new
  29.         
  30.  
  31.  
  32.