summaryrefslogtreecommitdiff
path: root/ofproto/ipfix-gen-entities
diff options
context:
space:
mode:
authorRussell Bryant <russell@ovn.org>2015-12-14 10:21:53 -0500
committerRussell Bryant <russell@ovn.org>2016-01-12 11:47:33 -0500
commit8ea171aba044bf605c31313330ccabfc4fc5846c (patch)
treee70eb368b777364217575964b96d220da07c951c /ofproto/ipfix-gen-entities
parentf3068bff92dc4fb76ee4aab149990f2492bcbc24 (diff)
downloadopenvswitch-8ea171aba044bf605c31313330ccabfc4fc5846c.tar.gz
python: Fix print function compatibility.
The print statement from Python 2 is a function in Python 3. Enable print function support for Python 2 and convert print statements to function calls. Enable the H233 flake8 warning. If the hacking plugin is installed, this will generate warnings for print statement usage not compatible with Python 3. H233 Python 3.x incompatible use of print operator Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ofproto/ipfix-gen-entities')
-rwxr-xr-xofproto/ipfix-gen-entities20
1 files changed, 11 insertions, 9 deletions
diff --git a/ofproto/ipfix-gen-entities b/ofproto/ipfix-gen-entities
index 54951b63d..a603cd1d1 100755
--- a/ofproto/ipfix-gen-entities
+++ b/ofproto/ipfix-gen-entities
@@ -7,6 +7,8 @@
# notice and this notice are preserved. This file is offered as-is,
# without warranty of any kind.
+from __future__ import print_function
+
import getopt
import re
import sys
@@ -48,16 +50,16 @@ class IpfixEntityHandler(xml.sax.handler.ContentHandler):
self.current_record = dict()
def startDocument(self):
- print """\
+ print("""\
/* IPFIX entities. */
#ifndef IPFIX_ENTITY
#define IPFIX_ENTITY(ENUM, ID, SIZE, NAME)
#endif
-"""
+""")
def endDocument(self):
- print """
-#undef IPFIX_ENTITY"""
+ print("""
+#undef IPFIX_ENTITY""")
def startElement(self, name, attrs):
if name in self.RECORD_FIELDS:
@@ -83,8 +85,8 @@ class IpfixEntityHandler(xml.sax.handler.ContentHandler):
self.current_record['dataTypeSize'] = self.DATA_TYPE_SIZE.get(
self.current_record['dataType'], 0)
- print 'IPFIX_ENTITY(%(enumName)s, %(elementId)s, ' \
- '%(dataTypeSize)i, %(name)s)' % self.current_record
+ print('IPFIX_ENTITY(%(enumName)s, %(elementId)s, '
+ '%(dataTypeSize)i, %(name)s)' % self.current_record)
self.current_record.clear()
def characters(self, content):
@@ -97,7 +99,7 @@ def print_ipfix_entity_macros(xml_file):
def usage(name):
- print """\
+ print("""\
%(name)s: IPFIX entity definition generator
Prints C macros defining IPFIX entities from the standard IANA file at
<http://www.iana.org/assignments/ipfix/ipfix.xml>
@@ -107,7 +109,7 @@ where XML is the standard IANA XML file defining IPFIX entities
The following options are also available:
-h, --help display this help message
-V, --version display version information\
-""" % {'name': name}
+""" % {'name': name})
sys.exit(0)
if __name__ == '__main__':
@@ -122,7 +124,7 @@ if __name__ == '__main__':
if key in ['-h', '--help']:
usage()
elif key in ['-V', '--version']:
- print 'ipfix-gen-entities (Open vSwitch)'
+ print('ipfix-gen-entities (Open vSwitch)')
else:
sys.exit(0)