port code from python2.x to python3.x 79/283879/9 upstream/0.17.4
authorbiao716.wang <biao716.wang@samsung.com>
Fri, 4 Nov 2022 12:09:29 +0000 (21:09 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Mon, 7 Nov 2022 01:54:47 +0000 (10:54 +0900)
Disable binding to python
Change-Id: I1c83b716ffcdcf64464da2fedeab913ac4137589
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
20 files changed:
CMakeLists.txt
acceptance_tests/tests/base.py
debian/control
debian/createrepo-c-devel.install
debian/rules
doc/python/conf.py
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
packaging/createrepo_c.spec
src/python/__init__.py
tests/python/tests/test_load_metadata.py
tests/python/tests/test_sqlite.py
utils/gen_rst.py
utils/get_version.py

index bf560fb64011882b787f852eaa56bc12a6420590..a89a1fce778431596113798a31cafa7f5cb0d083 100644 (file)
@@ -99,7 +99,7 @@ IF (ENABLE_DRPM)
 ENDIF (ENABLE_DRPM)
 
 # option to enable/disable python support
-OPTION (ENABLE_PYTHON "Enable python support?" ON)
+OPTION (ENABLE_PYTHON "Enable python support?" OFF)
 
 # Threaded XZ Compression
 # Note: This option is disabled by default, because Createrepo_c
index 3bd91d50a9b048aaa2fa7f36a50d7d153d9d15f7..bce2162f37a167ad55cd97920d24a573ce61aa0e 100644 (file)
@@ -329,7 +329,7 @@ class BaseTestCase(unittest.TestCase):
     def assert_repo_files(self, repo, file_patterns, additional_files_allowed=True):
         """Assert that files (defined by re) are in the repo
         """
-        compiled_patterns = map(re.compile, file_patterns)
+        compiled_patterns = list(map(re.compile, file_patterns))
         fns = os.listdir(os.path.join(repo, "repodata/"))
         used_patterns = []
         for pattern in compiled_patterns:
@@ -352,7 +352,7 @@ class BaseTestCase(unittest.TestCase):
         self.assertTrue(os.path.isdir(a))
         self.assertTrue(os.path.isdir(b))
 
-        _, logfn = tempfile.mkstemp(prefix="out_dircmp_%s_" % long(time.time()), dir=self.tdir)
+        _, logfn = tempfile.mkstemp(prefix="out_dircmp_%s_" % int(time.time()), dir=self.tdir)
         logfile = open(logfn, "w")
         logfile.write("A: %s\n" % a)
         logfile.write("B: %s\n" % b)
index cc2cd518d81f7ea4981e87ec1cb44d04ff2b40cb..c5a068d3de9b5a0fa2a09c17ace1eab92638bfcc 100644 (file)
@@ -2,19 +2,19 @@ Source: createrepo-c
 Section: devel
 Priority: extra
 Maintainer: Jian-feng Ding <jian-feng.ding@intel.com>
-Build-Depends: debhelper (>= 7.0.15), cdbs, libpython2.7, python-dev, dh-python, python-docutils, cmake, dpatch, libbz2-dev, librpm-dev, liblzma-dev, libcurl3 | libcurl4, libcurl4-openssl-dev, libmagic-dev, libexpat1, doxygen, pkg-config, libglib2.0-dev, libssl-dev
+Build-Depends: debhelper (>= 7.0.15), cdbs, libpython3-dev, python3-dev, libpython3-all-dev, dh-python, python3-docutils, cmake, dpatch, libbz2-dev, librpm-dev, liblzma-dev, libcurl3 | libcurl4, libcurl4-openssl-dev, libmagic-dev, libexpat1, doxygen, pkg-config, libglib2.0-dev, libssl-dev
 Standards-Version: 0.10.4
 Homepage: http://www.tizen.org
 
 Package: createrepo-c
 Architecture: i386 amd64
-Depends:  ${python:Depends},
+Depends:  ${python3:Depends},
  rpm,
- python-rpm,
- python-urlgrabber,
+ python3-rpm,
+ python3-urlgrabber,
  cpio,
  bzip2,
- libpython2.7,
+ libpython3-dev,
  libcurl3 | libcurl4,
  libxml2,
  gzip,
@@ -26,10 +26,10 @@ Description: image creator for Linux distributions
 
 Package: createrepo-c-devel
 Architecture: i386 amd64
-Depends:  ${python:Depends},
+Depends:  ${python3:Depends},
  rpm,
- python-rpm,
- python-urlgrabber,
+ python3-rpm,
+ python3-urlgrabber,
  cpio,
  bzip2,
  libcreaterepo-c,
@@ -39,7 +39,7 @@ Description: image creator for Linux distributions
 
 Package: libcreaterepo-c
 Architecture: i386 amd64
-Depends:  ${python:Depends},
+Depends:  ${python3:Depends},
  cpio,
  bzip2,
  libcurl3 | libcurl4,
index a083e81580082cde6b20963c83a058bd4b59384b..40bb3aefaa5f74e5abd53ddc8d674aeed168446c 100644 (file)
@@ -1,5 +1,4 @@
 usr/include/createrepo_c /usr/include/
 usr/lib/libcreaterepo_c.so /usr/lib/
 usr/lib/pkgconfig/createrepo_c.pc /usr/lib/pkgconfig/
-usr/lib/python2.7/dist-packages/createrepo_c /usr/lib/python2.7/dist-packages/
 
index 259d2a0a289f45f938f8442f2fd0902e1c25bb5c..2b577554f9b7cc666719c66e9ce80600d4851c1d 100755 (executable)
@@ -25,7 +25,8 @@ install: build
 
        # Installing package
        make DESTDIR=$(CURDIR) sysconfdir=$(CURDIR)/etc install
-       if [ -e usr/lib64 ]; then cp -arf  usr/lib64/* usr/lib/; fi
+       mkdir -p $(CURDIR)/usr/lib
+       if [ -e usr/lib64 ]; then cp -arf  usr/lib64/* $(CURDIR)/usr/lib/; fi
        #To compatible with createrepo
        for i in createrepo mergerepo modifyrepo sqliterepo;do \
                ln -s /usr/bin/$$i\_c $(CURDIR)/usr/bin/$$i; \
@@ -44,7 +45,6 @@ binary-indep: build install
        dh_strip
        dh_compress
        dh_fixperms
-       dh_python2
        dh_installdeb
 #      dh_shlibdeps -l/$(CURDIR)/usr/lib
        dh_gencontrol
index 2ca3a9ffb6bfe49f3c57d1eb316ba1de964a2dc2..b5eea454d369eefb891e95acfb9164087c764ff3 100644 (file)
@@ -41,8 +41,8 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = u'createrepo_c'
-copyright = u'2013, Red Hat'
+project = 'createrepo_c'
+copyright = '2013, Red Hat'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
@@ -184,8 +184,8 @@ latex_elements = {
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, documentclass [howto/manual]).
 latex_documents = [
-  ('index', 'createrepo_c.tex', u'createrepo_c Documentation',
-   u'Tomas Mlcoch', 'manual'),
+  ('index', 'createrepo_c.tex', 'createrepo_c Documentation',
+   'Tomas Mlcoch', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
@@ -214,8 +214,8 @@ latex_documents = [
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    ('index', 'createrepo_c', u'createrepo_c Documentation',
-     [u'Tomas Mlcoch'], 1)
+    ('index', 'createrepo_c', 'createrepo_c Documentation',
+     ['Tomas Mlcoch'], 1)
 ]
 
 # If true, show URL addresses after external links.
@@ -228,8 +228,8 @@ man_pages = [
 # (source start file, target name, title, author,
 #  dir menu entry, description, category)
 texinfo_documents = [
-  ('index', 'createrepo_c', u'createrepo_c Documentation',
-   u'Tomas Mlcoch', 'createrepo_c', 'One line description of project.',
+  ('index', 'createrepo_c', 'createrepo_c Documentation',
+   'Tomas Mlcoch', 'createrepo_c', 'One line description of project.',
    'Miscellaneous'),
 ]
 
index b39b2d1d9522fe3c1e94987d4012b24899aa2271..d6bc66ce4a58688b9f3f7dd1b024a89d013056db 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 6df99a1b297cb4736193d2d588ac3e9608847089..98b716f0afb9c09b044405e0ce1df156dd83ebd9 100755 (executable)
@@ -11,59 +11,59 @@ 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(( "    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(("    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(("    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(("  %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(("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:")
@@ -81,7 +81,7 @@ def first_method():
     """Use of this method is discouraged."""
     md = cr.Metadata()
     md.locate_and_load_xml(REPO_PATH)
-    for key in md.keys():
+    for key in list(md.keys()):
         pkg = md.get(key)
         print_package_info(pkg)
 
@@ -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()
@@ -208,7 +208,7 @@ def second_method():
                        newpkgcb=newpkgcb,
                        warningcb=warningcb)
 
-    for pkg in packages.itervalues():
+    for pkg in packages.values():
         print_package_info(pkg)
 
 
index b0a0c40e6b2ac6d96aaf61125d1fd0fbb9e2b174..73e2f7c912c8ee0868e18075534839849a287743 100755 (executable)
@@ -9,27 +9,27 @@ 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
+        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(("Db version:", rec.db_ver))
         print()
 
 if __name__ == "__main__":
index 748db3a1fd986f37ae867b598bf196881d19d772..3cd74b86cd5242fb14a517ee489aa5482f8fd10e 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 451801adede09b0ea4804fbfcfe10c12921c879f..3929f0110bd54621bb1e4d3c2b0a0a6630b73bc1 100755 (executable)
@@ -27,7 +27,7 @@ def modifyrepo(filename, repodata):
 
 if __name__ == '__main__':
     # Generate the updateinfo.xml
-    execfile('updateinfo_gen_02.py')
+    exec(compile(open('updateinfo_gen_02.py', "rb").read(), 'updateinfo_gen_02.py', 'exec'))
     #OUT_FILE is defined in updateinfo_gen_02.py, it will be OK at runtime.
     modifyrepo(OUT_FILE, REPO_PATH) #pylint: disable=undefined-variable
 
index dcd61b9cd3a5706d52ebcc1255ea19602b9d2dd0..e1b30c249ac6c6dca8eac86f7d6ac12d8cda661d 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 f99f9e2cb395e976a7178200bfe007572db206dc..5ad8fc937d83d3a307c9e8911663b3577b702111 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 02e5aab1d0d0f38a550d2d573bd9022c47660ea2..f45daa8cbfa39ecf91b0c6fe502c9a89a17eef02 100755 (executable)
@@ -10,44 +10,44 @@ 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(( "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(( "  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(("  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(("    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( "==============================")
 
index b7a6a869d52dcbb9909cee6ddef4689fec668a25..1d8445a910d45dc08f8e9375e5d73d467c247176 100644 (file)
@@ -7,7 +7,7 @@ Group:          System/Base
 Source:         %{name}-%{version}.tar.gz
 Source1001:     createrepo_c.manifest
 BuildRequires:  libbz2-devel cmake libexpat-devel file-devel
-BuildRequires:  libcurl-devel libxml2-devel python-devel gcc-c++
+BuildRequires:  libcurl-devel libxml2-devel python3-devel gcc-c++
 BuildRequires:  rpm-devel openssl-devel sqlite-devel doxygen
 BuildRequires:  glib2-devel xz-devel
 
@@ -72,7 +72,7 @@ done
 %{_libdir}/libcreaterepo_c.so
 %{_libdir}/pkgconfig/createrepo_c.pc
 %{_includedir}/createrepo_c
-%{python_sitearch}/createrepo_c
+#%{python3_sitearch}/createrepo_c
 
 %files -n libcreaterepo_c0
 %defattr(-, root, root,-)
index b493e2a186282ee40b382a9e315cbcfd2dbf25a9..c754834fc674f3825bba1ab4fc7e191a6dd3147a 100644 (file)
@@ -14,7 +14,7 @@ VERSION_MINOR = _createrepo_c.VERSION_MINOR  #: Minor version
 VERSION_PATCH = _createrepo_c.VERSION_PATCH  #: Patch version
 
 #: Version string
-VERSION = u"%d.%d.%d" % (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
+VERSION = "%d.%d.%d" % (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
 
 UNKNOWN_CHECKSUM    = _createrepo_c.CHECKSUM_UNKNOWN #: Checksum unknown
 CHECKSUM_UNKNOWN    = _createrepo_c.CHECKSUM_UNKNOWN #: Checksum unknown
index e12a86fc9ed1ccca329c94c0d95a65e0e079d318..2dbf20581434b4ade17a545feba321ff7aa39158 100644 (file)
@@ -12,9 +12,9 @@ class TestCaseLoadMetadata(unittest.TestCase):
         self.assertEqual(md.key, cr.HT_KEY_DEFAULT)
 
         self.assertEqual(md.len(), 0)
-        self.assertEqual(md.keys(), [])
-        self.assertFalse(md.has_key("foo"))
-        self.assertFalse(md.has_key(""))
+        self.assertEqual(list(md.keys()), [])
+        self.assertFalse("foo" in md)
+        self.assertFalse("" in md)
         self.assertFalse(md.remove("foo"))
         self.assertFalse(md.get("xxx"))
 
@@ -26,9 +26,9 @@ class TestCaseLoadMetadata(unittest.TestCase):
         self.assertEqual(md.key, cr.HT_KEY_DEFAULT)
 
         self.assertEqual(md.len(), 1)
-        self.assertEqual(md.keys(), ['152824bff2aa6d54f429d43e87a3ff3a0286505c6d93ec87692b5e3a9e3b97bf'])
-        self.assertFalse(md.has_key("foo"))
-        self.assertFalse(md.has_key(""))
+        self.assertEqual(list(md.keys()), ['152824bff2aa6d54f429d43e87a3ff3a0286505c6d93ec87692b5e3a9e3b97bf'])
+        self.assertFalse("foo" in md)
+        self.assertFalse("" in md)
         self.assertFalse(md.remove("foo"))
 
         pkg = md.get('152824bff2aa6d54f429d43e87a3ff3a0286505c6d93ec87692b5e3a9e3b97bf')
@@ -44,11 +44,11 @@ class TestCaseLoadMetadata(unittest.TestCase):
         self.assertEqual(md.key, cr.HT_KEY_DEFAULT)
 
         self.assertEqual(md.len(), 2)
-        self.assertEqual(md.keys(),
+        self.assertEqual(list(md.keys()),
             ['6d43a638af70ef899933b1fd86a866f18f65b0e0e17dcbf2e42bfd0cdd7c63c3',
              '90f61e546938a11449b710160ad294618a5bd3062e46f8cf851fd0088af184b7'])
-        self.assertFalse(md.has_key("foo"))
-        self.assertFalse(md.has_key(""))
+        self.assertFalse("foo" in md)
+        self.assertFalse("" in md)
         self.assertFalse(md.remove("foo"))
 
         pkg = md.get('152824bff2aa6d54f429d43e87a3ff3a0286505c6d93ec87692b5e3a9e3b97bf')
index 2f022010c68afeb66ecfc8146fb70dee89655ebc..78d40c7e2847a246970549dc460d7c4eba850b40 100644 (file)
@@ -68,38 +68,38 @@ class TestCaseSqlite(unittest.TestCase):
         con = sqlite3.connect(path)
         # Check tables
         self.assertEqual(con.execute("""select name from sqlite_master where type="table";""").fetchall(),
-            [(u'db_info',),
-             (u'packages',),
-             (u'files',),
-             (u'requires',),
-             (u'provides',),
-             (u'conflicts',),
-             (u'obsoletes',),
-             (u'suggests',),
-             (u'enhances',),
-             (u'recommends',),
-             (u'supplements',),
+            [('db_info',),
+             ('packages',),
+             ('files',),
+             ('requires',),
+             ('provides',),
+             ('conflicts',),
+             ('obsoletes',),
+             ('suggests',),
+             ('enhances',),
+             ('recommends',),
+             ('supplements',),
             ])
         # Check indexes
         self.assertEqual(con.execute("""select name from sqlite_master where type="index";""").fetchall(),
-            [(u'packagename',),
-             (u'packageId',),
-             (u'filenames',),
-             (u'pkgfiles',),
-             (u'pkgrequires',),
-             (u'requiresname',),
-             (u'pkgprovides',),
-             (u'providesname',),
-             (u'pkgconflicts',),
-             (u'pkgobsoletes',),
-             (u'pkgsuggests',),
-             (u'pkgenhances',),
-             (u'pkgrecommends',),
-             (u'pkgsupplements',),
+            [('packagename',),
+             ('packageId',),
+             ('filenames',),
+             ('pkgfiles',),
+             ('pkgrequires',),
+             ('requiresname',),
+             ('pkgprovides',),
+             ('providesname',),
+             ('pkgconflicts',),
+             ('pkgobsoletes',),
+             ('pkgsuggests',),
+             ('pkgenhances',),
+             ('pkgrecommends',),
+             ('pkgsupplements',),
             ])
         # Check triggers
         self.assertEqual(con.execute("""select name from sqlite_master where type="trigger";""").fetchall(),
-            [(u'removals',)])
+            [('removals',)])
 
     def test_sqlite_filelists_schema(self):
         path = os.path.join(self.tmpdir, "filelists.db")
@@ -109,13 +109,13 @@ class TestCaseSqlite(unittest.TestCase):
         con = sqlite3.connect(path)
         # Check tables
         self.assertEqual(con.execute("""select name from sqlite_master where type="table";""").fetchall(),
-            [(u'db_info',), (u'packages',), (u'filelist',)])
+            [('db_info',), ('packages',), ('filelist',)])
         # Check indexes
         self.assertEqual(con.execute("""select name from sqlite_master where type="index";""").fetchall(),
-            [(u'keyfile',), (u'pkgId',), (u'dirnames',)])
+            [('keyfile',), ('pkgId',), ('dirnames',)])
         # Check triggers
         self.assertEqual(con.execute("""select name from sqlite_master where type="trigger";""").fetchall(),
-            [(u'remove_filelist',)])
+            [('remove_filelist',)])
 
     def test_sqlite_other_schema(self):
         path = os.path.join(self.tmpdir, "other.db")
@@ -125,13 +125,13 @@ class TestCaseSqlite(unittest.TestCase):
         con = sqlite3.connect(path)
         # Check tables
         self.assertEqual(con.execute("""select name from sqlite_master where type="table";""").fetchall(),
-            [(u'db_info',), (u'packages',), (u'changelog',)])
+            [('db_info',), ('packages',), ('changelog',)])
         # Check indexes
         self.assertEqual(con.execute("""select name from sqlite_master where type="index";""").fetchall(),
-            [(u'keychange',), (u'pkgId',)])
+            [('keychange',), ('pkgId',)])
         # Check triggers
         self.assertEqual(con.execute("""select name from sqlite_master where type="trigger";""").fetchall(),
-            [(u'remove_changelogs',)])
+            [('remove_changelogs',)])
 
     def test_sqlite_primary(self):
         path = os.path.join(self.tmpdir, "primary.db")
@@ -154,55 +154,55 @@ class TestCaseSqlite(unittest.TestCase):
         # Check packages table
         res = con.execute("select * from packages").fetchall()
         self.assertEqual(res,
-            [(1, u'4e0b775220c67f0f2c1fd2177e626b9c863a098130224ff09778ede25cea9a9e',
-              u'Archer', u'x86_64', u'3.4.5', u'2', u'6', u'Complex package.',
-              u'Archer package', u'http://soo_complex_package.eu/',
-              res[0][10], 1365416480, u'GPL', u'ISIS', u'Development/Tools',
-              u'localhost.localdomain', u'Archer-3.4.5-6.src.rpm', 280, 2865,
-              u'Sterling Archer', 3101, 0, 544, None, None, u'sha256')])
+            [(1, '4e0b775220c67f0f2c1fd2177e626b9c863a098130224ff09778ede25cea9a9e',
+              'Archer', 'x86_64', '3.4.5', '2', '6', 'Complex package.',
+              'Archer package', 'http://soo_complex_package.eu/',
+              res[0][10], 1365416480, 'GPL', 'ISIS', 'Development/Tools',
+              'localhost.localdomain', 'Archer-3.4.5-6.src.rpm', 280, 2865,
+              'Sterling Archer', 3101, 0, 544, None, None, 'sha256')])
 
         # Check provides table
         self.assertEqual(con.execute("select * from provides").fetchall(),
-            [(u'bara', u'LE', u'0', u'22', None, 1),
-             (u'barb', u'GE', u'0', u'11.22.33', u'44', 1),
-             (u'barc', u'EQ', u'0', u'33', None, 1),
-             (u'bard', u'LT', u'0', u'44', None, 1),
-             (u'bare', u'GT', u'0', u'55', None, 1),
-             (u'Archer', u'EQ', u'2', u'3.4.5', u'6', 1),
-             (u'Archer(x86-64)', u'EQ', u'2', u'3.4.5', u'6', 1)])
+            [('bara', 'LE', '0', '22', None, 1),
+             ('barb', 'GE', '0', '11.22.33', '44', 1),
+             ('barc', 'EQ', '0', '33', None, 1),
+             ('bard', 'LT', '0', '44', None, 1),
+             ('bare', 'GT', '0', '55', None, 1),
+             ('Archer', 'EQ', '2', '3.4.5', '6', 1),
+             ('Archer(x86-64)', 'EQ', '2', '3.4.5', '6', 1)])
 
         # Check conflicts table
         self.assertEqual(con.execute("select * from conflicts").fetchall(),
-            [(u'bba', u'LE', u'0', u'2222', None, 1),
-             (u'bbb', u'GE', u'0', u'1111.2222.3333', u'4444', 1),
-             (u'bbc', u'EQ', u'0', u'3333', None, 1),
-             (u'bbd', u'LT', u'0', u'4444', None, 1),
-             (u'bbe', u'GT', u'0', u'5555', None, 1)])
+            [('bba', 'LE', '0', '2222', None, 1),
+             ('bbb', 'GE', '0', '1111.2222.3333', '4444', 1),
+             ('bbc', 'EQ', '0', '3333', None, 1),
+             ('bbd', 'LT', '0', '4444', None, 1),
+             ('bbe', 'GT', '0', '5555', None, 1)])
 
         # Check obsoletes table
         self.assertEqual(con.execute("select * from obsoletes").fetchall(),
-           [(u'aaa', u'LE', u'0', u'222', None, 1),
-            (u'aab', u'GE', u'0', u'111.2.3', u'4', 1),
-            (u'aac', u'EQ', u'0', u'333', None, 1),
-            (u'aad', u'LT', u'0', u'444', None, 1),
-            (u'aae', u'GT', u'0', u'555', None, 1)])
+           [('aaa', 'LE', '0', '222', None, 1),
+            ('aab', 'GE', '0', '111.2.3', '4', 1),
+            ('aac', 'EQ', '0', '333', None, 1),
+            ('aad', 'LT', '0', '444', None, 1),
+            ('aae', 'GT', '0', '555', None, 1)])
 
         # Check requires table
         self.assertEqual(con.execute("select * from requires").fetchall(),
-            [(u'fooa', u'LE', u'0', u'2', None, 1, u'FALSE'),
-             (u'foob', u'GE', u'0', u'1.0.0', u'1', 1, u'FALSE'),
-             (u'fooc', u'EQ', u'0', u'3', None, 1, u'FALSE'),
-             (u'food', u'LT', u'0', u'4', None, 1, u'FALSE'),
-             (u'fooe', u'GT', u'0', u'5', None, 1, u'FALSE'),
-             (u'foof', u'EQ', u'0', u'6', None, 1, u'TRUE')])
+            [('fooa', 'LE', '0', '2', None, 1, 'FALSE'),
+             ('foob', 'GE', '0', '1.0.0', '1', 1, 'FALSE'),
+             ('fooc', 'EQ', '0', '3', None, 1, 'FALSE'),
+             ('food', 'LT', '0', '4', None, 1, 'FALSE'),
+             ('fooe', 'GT', '0', '5', None, 1, 'FALSE'),
+             ('foof', 'EQ', '0', '6', None, 1, 'TRUE')])
 
         # Check files table
         self.assertEqual(con.execute("select * from files").fetchall(),
-            [(u'/usr/bin/complex_a', u'file', 1)])
+            [('/usr/bin/complex_a', 'file', 1)])
 
         # Check db_info table
         self.assertEqual(con.execute("select * from db_info").fetchall(),
-            [(10, u'somechecksum')])
+            [(10, 'somechecksum')])
 
     def test_sqlite_filelists(self):
         path = os.path.join(self.tmpdir, "filelists.db")
@@ -218,17 +218,17 @@ class TestCaseSqlite(unittest.TestCase):
 
         # Check packages table
         self.assertEqual(con.execute("select * from packages").fetchall(),
-            [(1, u'4e0b775220c67f0f2c1fd2177e626b9c863a098130224ff09778ede25cea9a9e')])
+            [(1, '4e0b775220c67f0f2c1fd2177e626b9c863a098130224ff09778ede25cea9a9e')])
 
         # Check files table
         self.assertEqual(set(con.execute("select * from filelist").fetchall()),
-            set([(1, u'/usr/share/doc', u'Archer-3.4.5', u'd'),
-             (1, u'/usr/bin', u'complex_a', u'f'),
-             (1, u'/usr/share/doc/Archer-3.4.5', u'README', u'f')]))
+            set([(1, '/usr/share/doc', 'Archer-3.4.5', 'd'),
+             (1, '/usr/bin', 'complex_a', 'f'),
+             (1, '/usr/share/doc/Archer-3.4.5', 'README', 'f')]))
 
         # Check db_info table
         self.assertEqual(con.execute("select * from db_info").fetchall(),
-            [(10, u'somechecksum2')])
+            [(10, 'somechecksum2')])
 
     def test_sqlite_other(self):
         path = os.path.join(self.tmpdir, "other.db")
@@ -244,14 +244,14 @@ class TestCaseSqlite(unittest.TestCase):
 
         # Check packages table
         self.assertEqual(con.execute("select * from packages").fetchall(),
-            [(1, u'4e0b775220c67f0f2c1fd2177e626b9c863a098130224ff09778ede25cea9a9e')])
+            [(1, '4e0b775220c67f0f2c1fd2177e626b9c863a098130224ff09778ede25cea9a9e')])
 
         # Check filelist table
         self.assertEqual(set(con.execute("select * from filelist").fetchall()),
-            set([(1, u'/usr/share/doc', u'Archer-3.4.5', u'd'),
-             (1, u'/usr/bin', u'complex_a', u'f'),
-             (1, u'/usr/share/doc/Archer-3.4.5', u'README', u'f')]))
+            set([(1, '/usr/share/doc', 'Archer-3.4.5', 'd'),
+             (1, '/usr/bin', 'complex_a', 'f'),
+             (1, '/usr/share/doc/Archer-3.4.5', 'README', 'f')]))
 
         # Check db_info table
         self.assertEqual(con.execute("select * from db_info").fetchall(),
-            [(10, u'somechecksum3')])
+            [(10, 'somechecksum3')])
index 90291bae9db990f718b51ad61228e442826b4404..848edd8f6a5c31c9d89739e6ec4819b3d48f87fc 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
@@ -134,7 +134,7 @@ def parse_arguments_from_c_file(filename):
         entry_match = re_single_entry.search(raw_entries_str[start:])
     # End while
 
-    print >> sys.stderr, "Loaded %2d arguments" % (i,)
+    print("Loaded %2d arguments" % (i,), file=sys.stderr)
     return args
 
 
@@ -147,7 +147,7 @@ if __name__ == "__main__":
     options, args = parser.parse_args()
 
     if len(args) < 1:
-        print >> sys.stderr, "Error: Must specify a input filename. (Example: ../src/cmd_parser.c)"
+        print("Error: Must specify a input filename. (Example: ../src/cmd_parser.c)", file=sys.stderr)
         sys.exit(1)
 
     args = parse_arguments_from_c_file(args[0])
@@ -181,7 +181,7 @@ if __name__ == "__main__":
 
     ret = info.gen_rst()
     if not ret:
-        print >> sys.stderr,"Error: Rst has not been generated"
+        print("Error: Rst has not been generated", file=sys.stderr)
         sys.exit(1)
 
     print (ret)
index 8e707e902f215c8d3dae4ed7dc45f396176f27c6..2e4aeaac87e3420a9abf56793d99e0c5f359a35b 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)