[releng/abderrahim/refactor: 5/5] convert-to-tarballs: simplify versions file generation
- From: Abderrahim Kitouni <akitouni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [releng/abderrahim/refactor: 5/5] convert-to-tarballs: simplify versions file generation
- Date: Tue, 7 Apr 2020 16:12:26 +0000 (UTC)
commit 7b65abaee823fb75029a7f7bd107f1531bfbb90c
Author: Abderrahim Kitouni <akitouni gnome org>
Date: Tue Apr 7 14:22:59 2020 +0100
convert-to-tarballs: simplify versions file generation
tools/smoketesting/convert-to-tarballs.py | 57 ++++++++++++-------------------
1 file changed, 22 insertions(+), 35 deletions(-)
---
diff --git a/tools/smoketesting/convert-to-tarballs.py b/tools/smoketesting/convert-to-tarballs.py
index 0a6b65e..7be5026 100755
--- a/tools/smoketesting/convert-to-tarballs.py
+++ b/tools/smoketesting/convert-to-tarballs.py
@@ -28,6 +28,7 @@ import os
from xml.dom import minidom, Node
from ruamel import yaml
from tqdm import tqdm
+from collections import defaultdict
from downloadsites import SITE_KINDS
@@ -35,8 +36,7 @@ from downloadsites import SITE_KINDS
class Options:
def __init__(self, filename):
self.filename = filename
- self.release_sets = []
- self.release_set = []
+ self.release_sets = defaultdict(list)
self.version_limit = {}
self.real_name = {}
self.default_site = None
@@ -100,15 +100,7 @@ class Options:
release_set = 'Other'
# Add it to the lists
- try:
- index = self.release_sets.index(release_set)
- except:
- index = None
- if index is not None:
- self.release_set[index].append(name)
- else:
- self.release_sets.append(release_set)
- self.release_set.append([ name ])
+ self.release_sets[release_set].append(name)
else:
sys.stderr.write('Bad whitelist node\n')
sys.exit(1)
@@ -247,30 +239,25 @@ class ConvertToTarballs:
self._write_bst_file(fullpath, element, location, checksum)
def create_versions_file(self):
- print('**************************************************')
- versions = open('versions', 'w')
- done = {}
- for idx in range(len(self.options.release_sets)):
- release_set = self.options.release_sets[idx]
- if release_set != 'Other':
- versions.write('## %s\n' % release_set.upper())
- modules_sorted = self.options.release_set[idx]
- modules_sorted.sort()
- for module in modules_sorted:
- try:
- real_module = self.options.get_real_name(module)
- index = self.all_tarballs.index(module)
- version = self.all_versions[index]
- triplet = '%s:%s:%s:\n' % (release_set, real_module, version)
- if not triplet in done:
- versions.write(triplet)
- done[triplet] = True
- except:
- print('FATAL: module %s missing from BuildStream projects' % module)
- os.remove('versions')
- sys.exit(1)
- versions.write('\n')
- versions.close()
+ versions = []
+
+ for release_set, modules in self.options.release_sets.items():
+ if release_set == 'Other':
+ continue
+
+ versions.append('## %s\n' % release_set.upper())
+
+ for module in sorted(modules):
+ real_module, _, _ = self.options.get_module_info(module)
+ index = self.all_tarballs.index(module)
+ version = self.all_versions[index]
+
+ triplet = '%s:%s:%s:\n' % (release_set, real_module, version)
+ if triplet not in versions:
+ versions.append(triplet)
+
+ with open('versions', 'w') as f:
+ f.writelines(versions)
def main(args):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]