From e03cafa99a59fc5d94a1ea8bd4b1d3562ac48b8c Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Wed, 12 Oct 2022 14:01:38 +0200 Subject: [PATCH] Add core.File.from_xml_node() class method --- osc/core.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/osc/core.py b/osc/core.py index fd7a1cee..ba176e48 100644 --- a/osc/core.py +++ b/osc/core.py @@ -264,6 +264,18 @@ class File: def __str__(self): return self.name + @classmethod + def from_xml_node(cls, node): + assert node.tag == "entry" + kwargs = { + "name": node.get("name"), + "md5": node.get("md5"), + "size": int(node.get("size")), + "mtime": int(node.get("mtime")), + "skipped": "skipped" in node, + } + return cls(**kwargs) + class Serviceinfo: """Source service content