[elbe-devel] [PATCH 2/4] cdroms: Add class SrcMananager
Olivier Dion
dion at linutronix.de
Mon Mar 23 19:53:54 CET 2020
The source manager manage a dictionary of package with their version and
components. It also provide a generator for iterating over a set of
tuples of the form (pkg, version, component).
Signed-off-by: Olivier Dion <dion at linutronix.de>
---
elbepack/cdroms.py | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/elbepack/cdroms.py b/elbepack/cdroms.py
index 669c3c78..827ddf88 100644
--- a/elbepack/cdroms.py
+++ b/elbepack/cdroms.py
@@ -25,6 +25,28 @@ from elbepack.isooptions import get_iso_options
CDROM_SIZE = 640 * 1000 * 1000
+class SrcManager(object):
+
+ def __init__(self):
+ self.pkgs = {}
+
+ def __iter__(self):
+ return self.gen()
+
+ def gen(self):
+ for pkg in self.pkgs:
+ for version in self.pkgs[pkg]:
+ for component in self.pkgs[pkg][version]:
+ yield (pkg, version, component)
+
+ def add_pkg(self, name, version, component):
+ if name in self.pkgs:
+ if version not in self.pkgs[name]:
+ self.pkgs[name][version] = [component]
+ else:
+ self.pkgs[name][version].append(component)
+ else:
+ self.pkgs[name] = {version: [component]}
def mk_source_cdrom(rfs, arch, codename, init_codename, target,
cdrom_size=CDROM_SIZE, xml=None):
--
2.25.1
More information about the elbe-devel
mailing list