fix pylint error for createrepo_c 02/218502/3 accepted/tizen/devbase/services/20191223.073044 accepted/tizen/devbase/services/20200104.053632 accepted/tizen/devbase/services/20200106.013825 accepted/tizen/devbase/services/20200106.013927 accepted/tizen/devbase/services/20200106.014031 accepted/tizen/devbase/services/20200106.014137 accepted/tizen/devbase/services/20200107.024056 accepted/tizen/devbase/services/20200108.052259 accepted/tizen/devbase/services/20200108.235056 accepted/tizen/devbase/services/20200109.052625 accepted/tizen/devbase/services/20200110.011038 accepted/tizen/devbase/services/20200114.020128 accepted/tizen/devbase/services/20200114.115631 accepted/tizen/devbase/services/20200115.231402 accepted/tizen/devbase/services/20200214.062146 accepted/tizen/devbase/services/20200219.094418 submit/trunk/20191223.191128 submit/trunk/20200104.111333 submit/trunk/20200104.134833 submit/trunk/20200104.154833 submit/trunk/20200104.164833 submit/trunk/20200104.173833 submit/trunk/20200105.091502 submit/trunk/20200106.175133 submit/trunk/20200107.100533 submit/trunk/20200107.112802 submit/trunk/20200107.162402 submit/trunk/20200107.170902 submit/trunk/20200107.171656 submit/trunk/20200107.180648 submit/trunk/20200108.020149 submit/trunk/20200108.135302 submit/trunk/20200108.172202 submit/trunk/20200108.172702 submit/trunk/20200108.231448 submit/trunk/20200109.105802 submit/trunk/20200109.112402 submit/trunk/20200109.124502 submit/trunk/20200109.151502 submit/trunk/20200109.154402 submit/trunk/20200110.111659 submit/trunk/20200114.100000 submit/trunk/20200114.110000 submit/trunk/20200115.110101 submit/trunk/20200213.184721 submit/trunk/20200213.191021 submit/trunk/20200214.114520 submit/trunk/20200219.120523 submit/trunk/20200410.102020
authorbiao716.wang <biao716.wang@samsung.com>
Mon, 25 Nov 2019 02:27:50 +0000 (10:27 +0800)
committerbiao716.wang <biao716.wang@samsung.com>
Mon, 25 Nov 2019 03:54:36 +0000 (11:54 +0800)
Change-Id: I7936d9ed28608be9e682b13f59c3bb75f08654a5
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
15 files changed:
examples/python/contenthash_calculation.py
examples/python/repodata_parsing.py
examples/python/repomd_parsing.py
examples/python/simple_createrepo.py
examples/python/simple_modifyrepo.py
examples/python/updateinfo_gen_01.py
examples/python/updateinfo_gen_02.py
examples/python/updateinfo_parsing.py
src/python/__init__.py
tests/python/tests/test_repomd.py
tests/python/tests/test_repomdrecord.py
tests/python/tests/test_version.py
tests/python/tests/test_xml_parser.py
utils/gen_rst.py
utils/get_version.py

index 8b0557f..b39b2d1 100755 (executable)
@@ -48,4 +48,4 @@ if __name__ == "__main__":
     path = REPO_PATH
     if len(sys.argv) == 2:
         path = sys.argv[1]
-    print calculate_contenthash(path)
+    print (calculate_contenthash(path))
index 78b2f81..6df99a1 100755 (executable)
@@ -11,70 +11,70 @@ REPO_PATH = "repo/"
 def print_package_info(pkg):
     def print_pcors(lst, requires=False):
         for item in lst:
-            print "    Name: %s" % item[cr.PCOR_ENTRY_NAME]
-            print "    Flags: %s" % item[cr.PCOR_ENTRY_FLAGS]
-            print "    Epoch: %s" % item[cr.PCOR_ENTRY_EPOCH]
-            print "    Version: %s" % item[cr.PCOR_ENTRY_VERSION]
-            print "    Release: %s" % item[cr.PCOR_ENTRY_RELEASE]
+            print ("    Name: %s" % item[cr.PCOR_ENTRY_NAME])
+            print ("    Flags: %s" % item[cr.PCOR_ENTRY_FLAGS])
+            print ("    Epoch: %s" % item[cr.PCOR_ENTRY_EPOCH])
+            print ("    Version: %s" % item[cr.PCOR_ENTRY_VERSION])
+            print ("    Release: %s" % item[cr.PCOR_ENTRY_RELEASE])
             if requires:
-                print "    Pre: %s" % item[cr.PCOR_ENTRY_PRE]
-            print "    +-----------------------------------+"
+                print( "    Pre: %s" % item[cr.PCOR_ENTRY_PRE])
+            print ("    +-----------------------------------+")
 
     def print_files(lst):
         for item in lst:
-            print "    Name: %s" % item[cr.FILE_ENTRY_NAME]
-            print "    Path: %s" % item[cr.FILE_ENTRY_PATH]
-            print "    Type: %s" % item[cr.FILE_ENTRY_TYPE]
-            print "    +-----------------------------------+"
+            print ("    Name: %s" % item[cr.FILE_ENTRY_NAME])
+            print ("    Path: %s" % item[cr.FILE_ENTRY_PATH])
+            print ("    Type: %s" % item[cr.FILE_ENTRY_TYPE])
+            print ("    +-----------------------------------+")
 
     def print_changelogs(lst):
         for item in lst:
-            print "    Author: %s" % item[cr.CHANGELOG_ENTRY_AUTHOR]
-            print "    Date: %s" % item[cr.CHANGELOG_ENTRY_DATE]
-            print "    Changelog: %s" % item[cr.CHANGELOG_ENTRY_CHANGELOG]
-            print "    +-----------------------------------+"
-
-    print "+=======================================+"
-    print "  %s" % pkg.name
-    print "+=======================================+"
-    print "NEVRA: %s" % pkg.nevra()
-    print "NVRA: %s" % pkg.nvra()
-    print "Name: %s" % pkg.name
-    print "Checksum (pkgId): %s" % pkg.pkgId
-    print "Checksum type: %s" % pkg.checksum_type
-    print "Arch: %s" % pkg.arch
-    print "Version: %s" % pkg.version
-    print "Epoch: %s" % pkg.epoch
-    print "Release: %s" % pkg.release
-    print "Summary: %s" % pkg.summary
-    print "Description: %s" % pkg.description
-    print "URL: %s" % pkg.url
-    print "Time file: %s" % pkg.time_file
-    print "Time build: %s" % pkg.time_build
-    print "License: %s" % pkg.rpm_license
-    print "Vendor: %s" % pkg.rpm_vendor
-    print "Group: %s" % pkg.rpm_group
-    print "Buildhost: %s" % pkg.rpm_buildhost
-    print "Source RPM: %s" % pkg.rpm_sourcerpm
-    print "Header start: %s" % pkg.rpm_header_start
-    print "Header end: %s" % pkg.rpm_header_end
-    print "Packager: %s" % pkg.rpm_packager
-    print "Size package: %s" % pkg.size_package
-    print "Size installed: %s" % pkg.size_installed
-    print "Size archive: %s" % pkg.size_archive
-    print "Location href: %s" % pkg.location_href
-    print "Location base: %s" % pkg.location_base
-    print "Requires:"
+            print ("    Author: %s" % item[cr.CHANGELOG_ENTRY_AUTHOR])
+            print ("    Date: %s" % item[cr.CHANGELOG_ENTRY_DATE])
+            print ("    Changelog: %s" % item[cr.CHANGELOG_ENTRY_CHANGELOG])
+            print ("    +-----------------------------------+")
+
+    print ("+=======================================+")
+    print ("  %s" % pkg.name)
+    print ("+=======================================+")
+    print ("NEVRA: %s" % pkg.nevra())
+    print( "NVRA: %s" % pkg.nvra())
+    print ("Name: %s" % pkg.name)
+    print( "Checksum (pkgId): %s" % pkg.pkgId)
+    print ("Checksum type: %s" % pkg.checksum_type)
+    print ("Arch: %s" % pkg.arch)
+    print( "Version: %s" % pkg.version)
+    print ("Epoch: %s" % pkg.epoch)
+    print ("Release: %s" % pkg.release)
+    print ("Summary: %s" % pkg.summary)
+    print ("Description: %s" % pkg.description)
+    print ("URL: %s" % pkg.url)
+    print ("Time file: %s" % pkg.time_file)
+    print( "Time build: %s" % pkg.time_build)
+    print ("License: %s" % pkg.rpm_license)
+    print ("Vendor: %s" % pkg.rpm_vendor)
+    print ("Group: %s" % pkg.rpm_group)
+    print ("Buildhost: %s" % pkg.rpm_buildhost)
+    print ("Source RPM: %s" % pkg.rpm_sourcerpm)
+    print ("Header start: %s" % pkg.rpm_header_start)
+    print ("Header end: %s" % pkg.rpm_header_end)
+    print ("Packager: %s" % pkg.rpm_packager)
+    print ("Size package: %s" % pkg.size_package)
+    print ("Size installed: %s" % pkg.size_installed)
+    print ("Size archive: %s" % pkg.size_archive)
+    print ("Location href: %s" % pkg.location_href)
+    print ("Location base: %s" % pkg.location_base)
+    print ("Requires:")
     print_pcors(pkg.requires, requires=True)
-    print "Provides:"
+    print( "Provides:")
     print_pcors(pkg.provides)
-    print "Conflicts:"
+    print ("Conflicts:")
     print_pcors(pkg.conflicts)
-    print "Obsoletes:"
+    print ("Obsoletes:")
     print_pcors(pkg.obsoletes)
-    print "Files:"
+    print( "Files:")
     print_files(pkg.files)
-    print "Changelogs:"
+    print( "Changelogs:")
     print_changelogs(pkg.changelogs)
 
 def first_method():
@@ -156,7 +156,7 @@ def second_method():
                              the XML_WARNING_* constants.
         :param message: String message.
         """
-        print "PARSER WARNING: %s" % message
+        print ("PARSER WARNING: %s" % message)
         return True
 
     repomd2 = cr.Repomd()
@@ -213,11 +213,11 @@ def second_method():
 
 
 if __name__ == "__main__":
-    print '"All in one shot" method:'
+    print( '"All in one shot" method:')
     first_method()
 
-    print
+    print()
 
-    print "Callback based method:"
+    print( "Callback based method:")
     second_method()
 
index 48d8c14..b0a0c40 100755 (executable)
@@ -9,28 +9,28 @@ REPO_PATH = "repo/"
 
 def parse_repomd(path):
     repomd = cr.Repomd(path)
-    print "Revision:", repomd.revision
+    print( "Revision:", repomd.revision)
     if repomd.contenthash:
-        print "Contenthash:", repomd.contenthash
-        print "Contenthash type:", repomd.contenthash_type
-    print "Repo tags:", repomd.repo_tags
-    print "Content tags:", repomd.content_tags
-    print "Distro tags:", repomd.distro_tags
+        print( "Contenthash:", repomd.contenthash)
+        print( "Contenthash type:", repomd.contenthash_type)
+    print ("Repo tags:", repomd.repo_tags)
+    print ("Content tags:", repomd.content_tags)
+    print ("Distro tags:", repomd.distro_tags)
     print
     for rec in repomd.records:
-        print "Type:", rec.type
-        print "Location href:", rec.location_href
-        print "Location base:", rec.location_base
-        print "Checksum:", rec.checksum
-        print "Checksum type:", rec.checksum_type
-        print "Checksum open:", rec.checksum_open
-        print "Checksum open type:", rec.checksum_open_type
-        print "Timestamp:", rec.timestamp
-        print "Size:", rec.size
-        print "Size open:", rec.size_open
+        print ("Type:", rec.type)
+        print ("Location href:", rec.location_href)
+        print ("Location base:", rec.location_base)
+        print ("Checksum:", rec.checksum)
+        print( "Checksum type:", rec.checksum_type)
+        print( "Checksum open:", rec.checksum_open)
+        print ("Checksum open type:", rec.checksum_open_type)
+        print ("Timestamp:", rec.timestamp)
+        print( "Size:", rec.size)
+        print ("Size open:", rec.size_open)
         if rec.db_ver:
-            print "Db version:", rec.db_ver
-        print
+            print ("Db version:", rec.db_ver)
+        print()
 
 if __name__ == "__main__":
     repomd_path = os.path.join(REPO_PATH, "repodata/repomd.xml")
index e5b3478..748db3a 100755 (executable)
@@ -50,7 +50,7 @@ def do_repodata(path):
     for filename in pkg_list:
         pkg = cr.package_from_rpm(filename)
         pkg.location_href = os.path.basename(filename)
-        print "Processing: %s" % pkg.nevra()
+        print ("Processing: %s" % pkg.nevra())
         pri_xml.add_pkg(pkg)
         fil_xml.add_pkg(pkg)
         oth_xml.add_pkg(pkg)
@@ -90,9 +90,9 @@ def do_repodata(path):
 
 if __name__ == "__main__":
     if len(sys.argv) != 2 or not os.path.isdir(sys.argv[1]):
-        print "Usage: %s <directory>" % (sys.argv[0])
+        print( "Usage: %s <directory>" % (sys.argv[0]))
         sys.exit(1)
 
     do_repodata(sys.argv[1])
 
-    print "Repository created in %s" % sys.argv[1]
+    print ("Repository created in %s" % sys.argv[1])
index c66d133..451801a 100755 (executable)
@@ -28,5 +28,6 @@ def modifyrepo(filename, repodata):
 if __name__ == '__main__':
     # Generate the updateinfo.xml
     execfile('updateinfo_gen_02.py')
+    #OUT_FILE is defined in updateinfo_gen_02.py, it will be OK at runtime.
+    modifyrepo(OUT_FILE, REPO_PATH) #pylint: disable=undefined-variable
 
-    modifyrepo(OUT_FILE, REPO_PATH)
index 799efc6..dcd61b9 100755 (executable)
@@ -46,7 +46,7 @@ def generate():
     ui = cr.UpdateInfo()
     ui.append(rec)
 
-    print ui.xml_dump(),
+    print( ui.xml_dump(),)
 
 if __name__ == "__main__":
     generate()
index fe70bf9..f99f9e2 100755 (executable)
@@ -50,7 +50,7 @@ def generate():
     f.add_chunk(chunk)
     f.close()
 
-    print "See the %s" % OUT_FILE
+    print ("See the %s" % OUT_FILE)
 
 
 if __name__ == "__main__":
index 364ed63..02e5aab 100755 (executable)
@@ -10,46 +10,46 @@ import createrepo_c as cr
 def parse_updateinfo(path):
     uinfo = cr.UpdateInfo(path)
     for update in uinfo.updates:
-        print "From:         %s" % update.fromstr
-        print "Status:       %s" % update.status
-        print "Type:         %s" % update.type
-        print "Version:      %s" % update.version
-        print "Id:           %s" % update.id
-        print "Title:        %s" % update.title
-        print "Issued date:  %s" % update.issued_date
-        print "Updated date: %s" % update.updated_date
-        print "Rights:       %s" % update.rights
-        print "Release:      %s" % update.release
-        print "Pushcount:    %s" % update.pushcount
-        print "Severity:     %s" % update.severity
-        print "Summary:      %s" % update.summary
-        print "Description:  %s" % update.description
-        print "Solution:     %s" % update.solution
-        print "References:"
+        print( "From:         %s" % update.fromstr)
+        print ("Status:       %s" % update.status)
+        print ("Type:         %s" % update.type)
+        print ("Version:      %s" % update.version)
+        print( "Id:           %s" % update.id)
+        print ("Title:        %s" % update.title)
+        print ("Issued date:  %s" % update.issued_date)
+        print ("Updated date: %s" % update.updated_date)
+        print ("Rights:       %s" % update.rights)
+        print ("Release:      %s" % update.release)
+        print( "Pushcount:    %s" % update.pushcount)
+        print ("Severity:     %s" % update.severity)
+        print ("Summary:      %s" % update.summary)
+        print ("Description:  %s" % update.description)
+        print ("Solution:     %s" % update.solution)
+        print ("References:")
         for ref in update.references:
-            print "  Href:  %s" % ref.href
-            print "  Id:    %s" % ref.id
-            print "  Type:  %s" % ref.type
-            print "  Title: %s" % ref.title
-            print "  ----------------------------"
-        print "Pkglist (collections):"
+            print( "  Href:  %s" % ref.href)
+            print( "  Id:    %s" % ref.id)
+            print( "  Type:  %s" % ref.type)
+            print ("  Title: %s" % ref.title)
+            print( "  ----------------------------")
+        print ("Pkglist (collections):")
         for col in update.collections:
-            print "  Short: %s" % col.shortname
-            print "  name:  %s" % col.name
-            print "  Packages:"
+            print ("  Short: %s" % col.shortname)
+            print ("  name:  %s" % col.name)
+            print( "  Packages:")
             for pkg in col.packages:
-                print "    Name:     %s" % pkg.name
-                print "    Version:  %s" % pkg.version
-                print "    Release:  %s" % pkg.release
-                print "    Epoch:    %s" % pkg.epoch
-                print "    Arch:     %s" % pkg.arch
-                print "    Src:      %s" % pkg.src
-                print "    Filename: %s" % pkg.filename
-                print "    Sum:      %s" % pkg.sum
-                print "    Sum type: %s (%s)" % (pkg.sum_type, cr.checksum_name_str(pkg.sum_type))
-                print "    Reboot suggested: %s" % pkg.reboot_suggested
-            print "  ----------------------------"
-        print "=============================="
+                print ("    Name:     %s" % pkg.name)
+                print ("    Version:  %s" % pkg.version)
+                print ("    Release:  %s" % pkg.release)
+                print( "    Epoch:    %s" % pkg.epoch)
+                print ("    Arch:     %s" % pkg.arch)
+                print( "    Src:      %s" % pkg.src)
+                print ("    Filename: %s" % pkg.filename)
+                print ("    Sum:      %s" % pkg.sum)
+                print( "    Sum type: %s (%s)" % (pkg.sum_type, cr.checksum_name_str(pkg.sum_type)))
+                print ("    Reboot suggested: %s" % pkg.reboot_suggested)
+            print ("  ----------------------------")
+        print( "==============================")
 
 
 if __name__ == "__main__":
index 95483ab..e71394a 100644 (file)
@@ -4,8 +4,9 @@
 import sys, os, site
 sys.path.append(os.path.join(site.getsitepackages()[0], 'createrepo_c/'))
 sys.path.append('/usr/lib/pyshared/python2.7/createrepo_c')
-import _createrepo_c
-from _createrepo_c import *
+#_createrepo_c is a so lib that belong to createrepo_c, it will be OK to import using the above statement at runtime.
+import _createrepo_c  #pylint: disable=import-error
+from _createrepo_c import * #pylint: disable=import-error
 
 VERSION_MAJOR = _createrepo_c.VERSION_MAJOR  #: Major version
 VERSION_MINOR = _createrepo_c.VERSION_MINOR  #: Minor version
index 6b6b3ad..5a41f17 100644 (file)
@@ -47,11 +47,11 @@ class TestCaseRepomd(unittest.TestCase):
         md.set_revision("foobar")
         self.assertEqual(md.revision, "foobar")
 
-        self.assertEqual(md.repoid, None);
+        self.assertEqual(md.repoid, None)
         md.set_repoid("barid", "sha256")
         self.assertEqual(md.repoid, "barid")
 
-        self.assertEqual(md.contenthash, None);
+        self.assertEqual(md.contenthash, None)
         md.set_contenthash("fooid", "sha256")
         self.assertEqual(md.contenthash, "fooid")
 
index 9d2a14b..7e2a0bc 100644 (file)
@@ -141,7 +141,7 @@ class TestCaseRepomdRecord(unittest.TestCase):
         self.assertEqual(rec.checksum_open_type, None)
         self.assertEqual(rec.size, 0)
 
-        rec.load_contentstat(stat);
+        rec.load_contentstat(stat)
 
         self.assertEqual(rec.checksum_open, "foobar")
         self.assertEqual(rec.checksum_open_type, "sha256")
index 2a944c2..93cabe4 100644 (file)
@@ -5,6 +5,6 @@ from . import fixtures
 
 class TestCaseVersion(unittest.TestCase):
     def test_version(self):
-        self.assertTrue(isinstance(cr.VERSION_MAJOR, int));
-        self.assertTrue(isinstance(cr.VERSION_MINOR, int));
-        self.assertTrue(isinstance(cr.VERSION_PATCH, int));
+        self.assertTrue(isinstance(cr.VERSION_MAJOR, int))
+        self.assertTrue(isinstance(cr.VERSION_MINOR, int))
+        self.assertTrue(isinstance(cr.VERSION_PATCH, int))
index a5f5d6a..3c37342 100644 (file)
@@ -174,7 +174,7 @@ class TestCaseXmlParserPrimary(unittest.TestCase):
 
     def test_xml_parser_primary_newpkgcb_abort(self):
         def newpkgcb(pkgId, name, arch):
-            raise Error("Foo error")
+            raise Exception("Foo error")
         self.assertRaises(cr.CreaterepoCError,
                           cr.xml_parse_primary,
                           REPO_02_PRIXML, newpkgcb, None, None, 1)
@@ -183,7 +183,7 @@ class TestCaseXmlParserPrimary(unittest.TestCase):
         def newpkgcb(pkgId, name, arch):
             return cr.Package()
         def pkgcb(pkg):
-            raise Error("Foo error")
+            raise Exception("Foo error")
         self.assertRaises(cr.CreaterepoCError,
                           cr.xml_parse_primary,
                           REPO_02_PRIXML, newpkgcb, pkgcb, None, 1)
@@ -192,7 +192,7 @@ class TestCaseXmlParserPrimary(unittest.TestCase):
         def newpkgcb(pkgId, name, arch):
             return cr.Package()
         def warningcb(type, msg):
-            raise Error("Foo error")
+            raise Exception("Foo error")
         self.assertRaises(cr.CreaterepoCError,
                           cr.xml_parse_primary,
                           PRIMARY_MULTI_WARN_00_PATH,
@@ -348,7 +348,7 @@ class TestCaseXmlParserFilelists(unittest.TestCase):
 
     def test_xml_parser_filelists_newpkgcb_abort(self):
         def newpkgcb(pkgId, name, arch):
-            raise Error("Foo error")
+            raise Exception("Foo error")
         self.assertRaises(cr.CreaterepoCError,
                           cr.xml_parse_filelists,
                           REPO_02_FILXML, newpkgcb, None, None)
@@ -357,7 +357,7 @@ class TestCaseXmlParserFilelists(unittest.TestCase):
         def newpkgcb(pkgId, name, arch):
             return cr.Package()
         def pkgcb(pkg):
-            raise Error("Foo error")
+            raise Exception("Foo error")
         self.assertRaises(cr.CreaterepoCError,
                           cr.xml_parse_filelists,
                           REPO_02_FILXML, newpkgcb, pkgcb, None)
@@ -366,7 +366,7 @@ class TestCaseXmlParserFilelists(unittest.TestCase):
         def newpkgcb(pkgId, name, arch):
             return cr.Package()
         def warningcb(type, msg):
-            raise Error("Foo error")
+            raise Exception("Foo error")
         self.assertRaises(cr.CreaterepoCError,
                           cr.xml_parse_filelists,
                           FILELISTS_MULTI_WARN_00_PATH,
@@ -526,7 +526,7 @@ class TestCaseXmlParserOther(unittest.TestCase):
 
     def test_xml_parser_other_newpkgcb_abort(self):
         def newpkgcb(pkgId, name, arch):
-            raise Error("Foo error")
+            raise Exception("Foo error")
         self.assertRaises(cr.CreaterepoCError,
                           cr.xml_parse_other,
                           REPO_02_OTHXML, newpkgcb, None, None)
@@ -535,7 +535,7 @@ class TestCaseXmlParserOther(unittest.TestCase):
         def newpkgcb(pkgId, name, arch):
             return cr.Package()
         def pkgcb(pkg):
-            raise Error("Foo error")
+            raise Exception("Foo error")
         self.assertRaises(cr.CreaterepoCError,
                           cr.xml_parse_other,
                           REPO_02_OTHXML, newpkgcb, pkgcb, None)
@@ -544,7 +544,7 @@ class TestCaseXmlParserOther(unittest.TestCase):
         def newpkgcb(pkgId, name, arch):
             return cr.Package()
         def warningcb(type, msg):
-            raise Error("Foo error")
+            raise Exception("Foo error")
         self.assertRaises(cr.CreaterepoCError,
                           cr.xml_parse_other,
                           OTHER_MULTI_WARN_00_PATH,
index a5395f5..90291ba 100755 (executable)
@@ -70,13 +70,13 @@ def parse_arguments_from_c_file(filename):
     try:
         content = open(filename, "r").read()
     except IOError:
-        print "Error: Cannot open file %s" % filename
+        print( "Error: Cannot open file %s" % filename)
         return args
 
     re_cmd_entries = re.compile(r"\s*(static|const)[ ]+GOptionEntry[^{]*{(?P<entries>.*)\s*NULL\s*}[,]?\s*};", re.MULTILINE|re.DOTALL)
     match = re_cmd_entries.search(content)
     if not match:
-        print "Warning: Cannot find GOptionEntry section in %s" % filename
+        print ("Warning: Cannot find GOptionEntry section in %s" % filename)
         return args
 
     re_single_entry = re.compile(r"""{\s*"(?P<long_name>[^"]*)"\s*,        # long name
@@ -181,7 +181,7 @@ if __name__ == "__main__":
 
     ret = info.gen_rst()
     if not ret:
-        print >> sys.stderr, "Error: Rst has not been generated"
+        print >> sys.stderr,"Error: Rst has not been generated"
         sys.exit(1)
 
-    print ret
+    print (ret)
index c840003..8e707e9 100755 (executable)
@@ -11,7 +11,7 @@ VERSION_FILE_PATH = "VERSION.cmake"
 def parse(root_dir):
     path = os.path.join(root_dir, VERSION_FILE_PATH)
     if not os.path.exists(path):
-        print "File %s doesn't exists" % path
+        print ("File %s doesn't exists" % path)
         return None
 
     content = open(path, "r").read()
@@ -42,12 +42,12 @@ if __name__ == "__main__":
         sys.exit(1)
 
     if options.major:
-        print ver['major']
+        print (ver['major'])
     elif options.minor:
-        print ver['minor']
+        print( ver['minor'])
     elif options.patch:
-        print ver['patch']
+        print( ver['patch'])
     else:
-        print "%(major)s.%(minor)s.%(patch)s" % ver
+        print( "%(major)s.%(minor)s.%(patch)s" % ver)
 
     sys.exit(0)