Commits

Anonymous committed 346e869

Removed portability.py, using from __future__ import print_function instead. This means only Python 2.6 and later is supported in 2.x

  • Participants
  • Parent commits df4605c

Comments (0)

Files changed (8)

 * Issue 19: anonymous structs & union fields
 * pycparser is now on PyPI (Python Package Index)
 * Created FAQ on the pycparser project page - the readme now points to it
+* No support for Python 2.5, only starting with 2.6 and 3.x
 
 
 Version Update

examples/func_calls.py

 # Using pycparser for printing out all the calls of some function
 # in a C file.
 #
-# Copyright (C) 2008, Eli Bendersky
+# Copyright (C) 2008-2011, Eli Bendersky
 # License: LGPL
 #-----------------------------------------------------------------
+from __future__ import print_function
 import sys
 
 # This is not required if you've installed pycparser into
 sys.path.insert(0, '..')
 
 from pycparser import c_parser, c_ast, parse_file
-from pycparser.portability import printme
 
 
 # A visitor with some state information (the funcname it's 
 
     def visit_FuncCall(self, node):
         if node.name.name == self.funcname:
-            printme('%s called at %s\n' % (
+            print('%s called at %s' % (
                     self.funcname, node.name.coord))
 
 
 
 if __name__ == "__main__":
     if len(sys.argv) > 2:
-        filename  = sys.argv[1]
+        filename = sys.argv[1]
         func = sys.argv[2]
     else:
         filename = 'c_files/hash.c'

examples/func_defs.py

 # This is a simple example of traversing the AST generated by
 # pycparser.
 #
-# Copyright (C) 2008-2009, Eli Bendersky
+# Copyright (C) 2008-2011, Eli Bendersky
 # License: LGPL
 #-----------------------------------------------------------------
+from __future__ import print_function
 import sys
 
 # This is not required if you've installed pycparser into
 sys.path.insert(0, '..')
 
 from pycparser import c_parser, c_ast, parse_file
-from pycparser.portability import printme
 
 
 # A simple visitor for FuncDef nodes that prints the names and 
 #
 class FuncDefVisitor(c_ast.NodeVisitor):
     def visit_FuncDef(self, node):
-        printme('%s at %s\n' % (node.decl.name, node.decl.coord))
+        print('%s at %s' % (node.decl.name, node.decl.coord))
 
 
 def show_func_defs(filename):

pycparser/_c_ast.cfg

 # Holder for types that are a simple identifier (e.g. the built
 # ins void, char etc. and typedef-defined types)
 #
-IdentifierType: [names]
+IdentifierType: [name]
 
 If: [cond*, iftrue*, iffalse*]
 

pycparser/c_lexer.py

 #
 # CLexer class: lexer for the C language
 #
-# Copyright (C) 2008-2010, Eli Bendersky
+# Copyright (C) 2008-2011, Eli Bendersky
 # License: LGPL
 #-----------------------------------------------------------------
 
 
 
 if __name__ == "__main__":
-    from portability import printme
     filename = '../zp.c'
     text = open(filename).read()
     
     """
     
     def errfoo(msg, a, b):
-        printme(msg)
+        sys.write(msg + "\n")
         sys.exit()
     
     def typelookup(namd):

pycparser/c_parser.py

 #
 # CParser class: Parser and AST builder for the C language
 #
-# Copyright (C) 2008-2010, Eli Bendersky
+# Copyright (C) 2008-2011, Eli Bendersky
 # License: LGPL
 #-----------------------------------------------------------------
 import re
 
 if __name__ == "__main__":
     import pprint
-    import time
-    from portability import printme
+    import time, sys
     
     t1 = time.time()
     parser = CParser(lex_optimize=True, yacc_debug=True, yacc_optimize=False)
-    printme(time.time() - t1)
+    sys.write(time.time() - t1)
     
     buf = ''' 
         int (*k)(int);

pycparser/portability.py

-#-----------------------------------------------------------------
-# pycparser: portability.py
-#
-# Portability code for working with different versions of Python
-#
-# Copyright (C) 2008-2010, Eli Bendersky
-# License: LGPL
-#----------------------
-import sys
-
-
-def printme(s):
-    sys.stdout.write(str(s))
-
-
-
-
-     
     {
         long sa;
         int sb;
-        float;
     };
     """
 
     #--------------- Lexing 
-    #~ from pycparser.portability import printme
     #~ def errfoo(msg, a, b):
         #~ printme(msg)
         #~ sys.exit()