]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add extension() method to OutputFormat
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 9 Nov 2023 11:52:16 +0000 (12:52 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 9 Nov 2023 14:46:06 +0000 (15:46 +0100)
mkosi/config.py

index 37851bf01088562ca60e81ebe16892712062cbeb..93be0eb0c7bee071d7128ffeef7edfc159929b52 100644 (file)
@@ -106,6 +106,14 @@ class OutputFormat(StrEnum):
     uki       = enum.auto()
     none      = enum.auto()
 
+    def extension(self) -> str:
+        return {
+            OutputFormat.disk: ".raw",
+            OutputFormat.cpio: ".cpio",
+            OutputFormat.tar:  ".tar",
+            OutputFormat.uki:  ".efi",
+        }.get(self, "")
+
 
 class ManifestFormat(StrEnum):
     json      = enum.auto()  # the standard manifest in json format
@@ -938,16 +946,7 @@ class MkosiConfig:
 
     @property
     def output_with_format(self) -> str:
-        output = self.output_with_version
-
-        output += {
-            OutputFormat.disk: ".raw",
-            OutputFormat.cpio: ".cpio",
-            OutputFormat.tar:  ".tar",
-            OutputFormat.uki:  ".efi",
-        }.get(self.output_format, "")
-
-        return output
+        return self.output_with_version + self.output_format.extension()
 
     @property
     def output_with_compression(self) -> str: