path = REPO_PATH
if len(sys.argv) == 2:
path = sys.argv[1]
- print calculate_contenthash(path)
+ print (calculate_contenthash(path))
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():
the XML_WARNING_* constants.
:param message: String message.
"""
- print "PARSER WARNING: %s" % message
+ print ("PARSER WARNING: %s" % message)
return True
repomd2 = cr.Repomd()
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()
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")
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)
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])
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)
ui = cr.UpdateInfo()
ui.append(rec)
- print ui.xml_dump(),
+ print( ui.xml_dump(),)
if __name__ == "__main__":
generate()
f.add_chunk(chunk)
f.close()
- print "See the %s" % OUT_FILE
+ print ("See the %s" % OUT_FILE)
if __name__ == "__main__":
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__":
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
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")
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")
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))
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)
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)
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,
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)
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)
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,
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)
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)
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,
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
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)
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()
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)