repo2json: start porting the script to python3
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
parent
1ef32c2da5
commit
89afed8844
1 changed files with 8 additions and 8 deletions
|
@ -181,7 +181,7 @@ def get_pkg_info(session, pkg_name):
|
||||||
def main():
|
def main():
|
||||||
''' Main function, does the job :) '''
|
''' Main function, does the job :) '''
|
||||||
working_dir = tempfile.mkdtemp(prefix='rhel2json-')
|
working_dir = tempfile.mkdtemp(prefix='rhel2json-')
|
||||||
print 'working dir:', working_dir
|
print('working dir:', working_dir)
|
||||||
|
|
||||||
for el in PATHS:
|
for el in PATHS:
|
||||||
|
|
||||||
|
@ -192,12 +192,12 @@ def main():
|
||||||
for dbfile_xz in dbfiles:
|
for dbfile_xz in dbfiles:
|
||||||
cur_fold = os.path.join(*dbfile_xz.rsplit(os.sep, 2)[:-2])
|
cur_fold = os.path.join(*dbfile_xz.rsplit(os.sep, 2)[:-2])
|
||||||
channel = os.path.basename(cur_fold)
|
channel = os.path.basename(cur_fold)
|
||||||
print '-', cur_fold
|
print('-', cur_fold)
|
||||||
dbfile = os.path.join(working_dir, 'primary_db_%s.sqlite' % el)
|
dbfile = os.path.join(working_dir, 'primary_db_%s.sqlite' % el)
|
||||||
decompress_primary_db(dbfile_xz, dbfile)
|
decompress_primary_db(dbfile_xz, dbfile)
|
||||||
|
|
||||||
if not os.path.isfile(dbfile):
|
if not os.path.isfile(dbfile):
|
||||||
print '%s was incorrectly decompressed -- ignoring' % dbfile
|
print('%s was incorrectly decompressed -- ignoring' % dbfile)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
db_url = 'sqlite:///%s' % dbfile
|
db_url = 'sqlite:///%s' % dbfile
|
||||||
|
@ -250,15 +250,15 @@ def main():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cnt += 1
|
cnt += 1
|
||||||
print '%s packages in %s' % (cnt, cur_fold)
|
print('%s packages in %s' % (cnt, cur_fold))
|
||||||
print '%s packages were new packages' % (new)
|
print('%s packages were new packages' % (new))
|
||||||
|
|
||||||
print '\n%s packages retrieved in %s' % (len(output['packages']), el)
|
print('\n%s packages retrieved in %s' % (len(output['packages']), el))
|
||||||
print '%s arches for in %s' % (len(output['arches']), el)
|
print('%s arches for in %s' % (len(output['arches']), el))
|
||||||
outputfile = 'pkg_%s.json' % el
|
outputfile = 'pkg_%s.json' % el
|
||||||
with open(outputfile, 'w') as stream:
|
with open(outputfile, 'w') as stream:
|
||||||
stream.write(json.dumps(output))
|
stream.write(json.dumps(output))
|
||||||
print 'Output File: %s\n' % outputfile
|
print('Output File: %s\n' % outputfile)
|
||||||
|
|
||||||
# Drop the temp directory
|
# Drop the temp directory
|
||||||
shutil.rmtree(working_dir)
|
shutil.rmtree(working_dir)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue