]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ukify: drop dots from exception messages
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 3 Feb 2025 09:38:01 +0000 (10:38 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 4 Mar 2025 09:07:38 +0000 (10:07 +0100)
In Python, exception messages are often embedded in surrounding text, so in
general they should not contain punctuation.

Also, no need to instantiate the exception object if no arguments are used.

src/ukify/ukify.py

index 097a7ee0c66810aa38bf7fbdca0abecd7fa4b2c2..fb3912f9021930bd1ee20e27279523f08acbf590 100755 (executable)
@@ -489,11 +489,11 @@ class UKI:
 class SignTool:
     @staticmethod
     def sign(input_f: str, output_f: str, opts: UkifyConfig) -> None:
-        raise NotImplementedError()
+        raise NotImplementedError
 
     @staticmethod
     def verify(opts: UkifyConfig) -> bool:
-        raise NotImplementedError()
+        raise NotImplementedError
 
     @staticmethod
     def from_string(name: str) -> type['SignTool']:
@@ -1028,7 +1028,7 @@ def pe_add_sections(opts: UkifyConfig, uki: UKI, output: str) -> None:
         for i, s in enumerate(pe.sections[:n_original_sections]):
             if pe_strip_section_name(s.Name) == section.name and section.name != '.dtbauto':
                 if new_section.Misc_VirtualSize > s.SizeOfRawData:
-                    raise PEError(f'Not enough space in existing section {section.name} to append new data.')
+                    raise PEError(f'Not enough space in existing section {section.name} to append new data')
 
                 padding = bytes(new_section.SizeOfRawData - new_section.Misc_VirtualSize)
                 pe.__data__ = (
@@ -1081,9 +1081,8 @@ def pe_add_sections(opts: UkifyConfig, uki: UKI, output: str) -> None:
                 encoded = json.dumps(j).encode()
                 if len(encoded) > section.SizeOfRawData:
                     raise PEError(
-                        f'Not enough space in existing section .pcrsig of size {section.SizeOfRawData} to append new data of size {len(encoded)}.'  # noqa: E501
+                        f'Not enough space in existing section .pcrsig of size {section.SizeOfRawData} to append new data of size {len(encoded)}'  # noqa: E501
                     )
-
                 section.Misc_VirtualSize = len(encoded)
                 # bytes(n) results in an array of n zeroes
                 padding = bytes(section.SizeOfRawData - len(encoded))
@@ -1242,12 +1241,12 @@ def parse_hwid_dir(path: Path) -> bytes:
 
 def parse_efifw_dir(path: Path) -> bytes:
     if not path.is_dir():
-        raise ValueError(f'{path} is not a directory or it does not exist.')
+        raise ValueError(f'{path} is not a directory or it does not exist')
 
     # only one firmware image must be present in the directory
     # to uniquely identify that firmware with its ID.
     if len(list(path.glob('*'))) != 1:
-        raise ValueError(f'{path} must contain exactly one firmware image file.')
+        raise ValueError(f'{path} must contain exactly one firmware image file')
 
     payload_blob = b''
     for fw in path.iterdir():