summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovanni Mascellani <mascellani@poisson.phc.unipi.it>2011-08-02 15:08:34 +0200
committerSean Finney <seanius@htpc-l.(none)>2011-09-17 13:28:46 +0200
commitf25edd7952621ac334a79042c850c6c6a1d22ab5 (patch)
treefe7fa2d0e323da03dcd3adea81fd0a29544ea6a9
parenta03f98d63b0ada2c5dfe804ecad8bd79b591f15c (diff)
downloadpatch-tracker-master.tar.gz
Add cache for export_for_udd.py.HEADmaster
export_for_udd.py reads the file listed on the command lines, assuming that are JSON files generated by previous run of export_for_udd.py. The patches for packages listed in such files are not computed again.
-rwxr-xr-xexport_for_udd.py54
1 files changed, 35 insertions, 19 deletions
diff --git a/export_for_udd.py b/export_for_udd.py
index 8f331ca..86171a6 100755
--- a/export_for_udd.py
+++ b/export_for_udd.py
@@ -8,6 +8,18 @@ import json
def main():
db = PatchTrackerDB()
packages = []
+ previous = {}
+
+ # Load data from previous calculations
+ for fn in sys.argv[1:]:
+ with open(fn) as f:
+ data = json.load(f)
+ for line in data:
+ previous[(line['package'], line['version'])] = \
+ {'series_type': line['series_type'],
+ 'nondebian': line['nondebian'],
+ 'patches': line['patches']}
+
try:
i = 0
for package, suite, version in db.enumerate_packages():
@@ -20,29 +32,33 @@ def main():
print >> sys.stderr, "%d %s %s %s" % (i, package, suite, version)
i += 1
- try:
- dh = db.makeDiffHandler(package, version)
- series = dh.series(ghost=True)
- if series:
- series_type = series.style
- else:
- series_type = "no_series"
+ if (package, version) not in previous:
+ prev_package = previous[(package, version)] = {}
try:
- nondebian_diff = dh.nondebiandir(ghost=True)
- nondebian = nondebian_diff.diffstat().lines()
- except AttributeError:
- # This means that the handler is a DebTarHandler
- nondebian = [0, 0, 0]
- except PackageWithoutDiffException:
- # The package is native
- series_type = "native"
- nondebian = [0, 0, 0]
+ dh = db.makeDiffHandler(package, version)
+ series = dh.series(ghost=True)
+ if series:
+ prev_package['series_type'] = series.style
+ else:
+ prev_package['series_type'] = "no_series"
+ try:
+ nondebian_diff = dh.nondebiandir(ghost=True)
+ prev_package['nondebian'] = nondebian_diff.diffstat().lines()
+ except AttributeError:
+ # This means that the handler is a DebTarHandler
+ prev_package['nondebian'] = [0, 0, 0]
+ except PackageWithoutDiffException:
+ # The package is native
+ prev_package['series_type'] = "native"
+ prev_package['nondebian'] = [0, 0, 0]
- patches = [(patch, patch_data.diffstat().lines()) for (patch, patch_data) in series]
+ prev_package['patches'] = [(patch, patch_data.diffstat().lines()) for (patch, patch_data) in series]
+ prev_package = previous[(package, version)]
packages.append({'package': package, 'suite': suite, 'version': version,
- 'series_type': series_type, 'nondebian': nondebian,
- 'patches': patches})
+ 'series_type': prev_package['series_type'],
+ 'nondebian': prev_package['nondebian'],
+ 'patches': prev_package['patches']})
# This is mainly intended for debugging: if you want to interrupt the
# process, you still can obtain the JSON with the packages processed so far.