[elbe-devel] [PATCH 1/7] elbepack: elbexml: access subnodes on demand

Thomas Weißschuh thomas.weissschuh at linutronix.de
Mon Aug 19 16:50:13 CEST 2024


These properties are not needed every time, only compute them when they are.
This is also makes the ElbeXML easier to pickle, which is a requisite
for its usage with multiprocessing.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/elbexml.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/elbepack/elbexml.py b/elbepack/elbexml.py
index a64ef98e66fb..53e82657e138 100644
--- a/elbepack/elbexml.py
+++ b/elbepack/elbexml.py
@@ -3,6 +3,7 @@
 # SPDX-FileCopyrightText: 2014-2017 Linutronix GmbH
 # SPDX-FileCopyrightText: 2015 Ferdinand Schwenk <ferdinand.schwenk at emtrion.de>
 
+import functools
 import os
 import re
 import socket
@@ -72,8 +73,6 @@ class ElbeXML:
                 raise ValidationError(validation)
 
         self.xml = etree(fname)
-        self.prj = self.xml.node('/project')
-        self.tgt = self.xml.node('/target')
 
         if buildtype:
             pass
@@ -100,6 +99,14 @@ class ElbeXML:
     def all(self, path):
         return self.xml.all(path)
 
+    @functools.cached_property
+    def prj(self):
+        return self.xml.node('/project')
+
+    @functools.cached_property
+    def tgt(self):
+        return self.xml.node('/target')
+
     def is_cross(self, host_arch):
 
         target = self.text('project/buildimage/arch', key='arch')

-- 
2.46.0



More information about the elbe-devel mailing list