made some adjustmenets now we have two classes that handle most of the stuff
This commit is contained in:
parent
c967967fbc
commit
9b4d4ac46c
11 changed files with 7 additions and 63352 deletions
|
@ -1,6 +1,7 @@
|
|||
from launchpadlib.launchpad import Launchpad
|
||||
from collections import defaultdict
|
||||
import httplib2
|
||||
from meta_release_to_json import MetaRelease, SourceMetaRelease, MetaReleaseJsons
|
||||
|
||||
class UbuntuDistroLaunchpad:
|
||||
"""
|
||||
|
@ -118,6 +119,8 @@ class UbuntuPackageHistory:
|
|||
return sorted(d.items())
|
||||
|
||||
if __name__ == '__main__':
|
||||
meta_release = SourceMetaRelease().meta_release_parse()
|
||||
meta_release_jsons = MetaReleaseJsons(meta_release).build()
|
||||
|
||||
upa = UbuntuPackageArchive()
|
||||
udl = UbuntuDistroLaunchpad()
|
|
@ -1,31 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# export job that will use existing class code to export to json
|
||||
|
||||
import json
|
||||
from package_version_history import PackageVersionHistory as pvh
|
||||
|
||||
# start with just ubuntu 22.04
|
||||
distro_version = '22.04'
|
||||
|
||||
source_pkgs_filepath = './package_data/ubuntu_22.04_source_packages.container'
|
||||
|
||||
source_file = open(source_pkgs_filepath, 'r')
|
||||
lines = source_file.readlines()
|
||||
|
||||
results = []
|
||||
|
||||
for source_pkgname in lines:
|
||||
pkg = source_pkgname.strip()
|
||||
print(pkg)
|
||||
name_and_versions = pvh(
|
||||
pkg, distro_version).package_name_and_version_history()
|
||||
results.append(name_and_versions)
|
||||
print(name_and_versions)
|
||||
|
||||
# create json of the results
|
||||
json_obj = json.dumps(results)
|
||||
json_arr = json.loads(json_obj)
|
||||
|
||||
# write to a file
|
||||
with open('./version_history_data/ubuntu_latest_source_package_version_history.container', 'w') as outfile:
|
||||
json.dump(json_arr, outfile, indent=4)
|
|
@ -67,11 +67,11 @@ class MetaRelease:
|
|||
|
||||
class MetaReleaseJsons:
|
||||
def __init__(self, meta_release):
|
||||
self.meta_relesae = meta_release
|
||||
self.meta_release = meta_release
|
||||
|
||||
def build(self):
|
||||
jsons = []
|
||||
for d in meta_release:
|
||||
for d in self.meta_release:
|
||||
keys = d.keys()
|
||||
|
||||
meta_release_obj = MetaRelease(
|
||||
|
@ -96,6 +96,7 @@ if __name__ == '__main__':
|
|||
|
||||
meta_release = SourceMetaRelease().meta_release_parse()
|
||||
meta_release_jsons = MetaReleaseJsons(meta_release).build()
|
||||
|
||||
|
||||
# print jsons to stdout
|
||||
for release_info in meta_release_jsons:
|
||||
print(release_info)
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,45 +0,0 @@
|
|||
from launchpadlib.launchpad import Launchpad
|
||||
from collections import defaultdict
|
||||
|
||||
class PackageVersionHistory:
|
||||
"""
|
||||
Use launchpadlib api to query for the package history tree
|
||||
of a target source_package_name + distro_series
|
||||
"""
|
||||
def __init__(self, name, distro_series):
|
||||
self.name = name
|
||||
self.distro_series = distro_series
|
||||
self.launchpad = self.login()
|
||||
|
||||
def login(self):
|
||||
return Launchpad.login_anonymously('package_version_history_lookup', 'production')
|
||||
|
||||
def set_ubuntu(self):
|
||||
return self.launchpad.distributions['ubuntu']
|
||||
|
||||
def set_distro_series(self):
|
||||
ubuntu = self.set_ubuntu()
|
||||
return ubuntu.getSeries(name_or_version=self.distro_series)
|
||||
|
||||
def set_archive(self):
|
||||
ubuntu = self.set_ubuntu()
|
||||
return ubuntu.main_archive
|
||||
|
||||
def get_published_sources(self):
|
||||
archive = self.set_archive()
|
||||
series = self.set_distro_series()
|
||||
return archive.getPublishedSources(source_name=self.name, distro_series=series)
|
||||
|
||||
def package_name_and_version_history(self):
|
||||
sources = self.get_published_sources()
|
||||
results = []
|
||||
for source in sources:
|
||||
name = source.source_package_name
|
||||
version = source.source_package_version
|
||||
results.append((name, version))
|
||||
|
||||
d = defaultdict(list)
|
||||
for k, v in results:
|
||||
d[k].append(v)
|
||||
|
||||
return sorted(d.items())
|
Loading…
Add table
Reference in a new issue