Skip to content

Commit 2df9e0a

Browse files
committed
black format, don't _log_init by default
Signed-off-by: Zen <[email protected]>
1 parent 84f9f25 commit 2df9e0a

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

src/ugrd/fs/cpio.py

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
__author__ = 'desultory'
2-
__version__ = '3.4.3'
1+
__author__ = "desultory"
2+
__version__ = "3.5.0"
33

44

55
from zenlib.util import contains
66

77

8-
@contains('check_cpio')
8+
@contains("check_cpio")
99
def check_cpio_deps(self) -> None:
10-
""" Checks that all dependenceis are in the generated CPIO file. """
11-
for dep in self['dependencies']:
10+
"""Checks that all dependenceis are in the generated CPIO file."""
11+
for dep in self["dependencies"]:
1212
_check_in_cpio(self, dep)
1313
return "All dependencies found in CPIO."
1414

1515

16-
@contains('check_cpio')
16+
@contains("check_cpio")
1717
def check_cpio_funcs(self) -> None:
18-
""" Checks that all included functions are in the profile included in the generated CPIO file. """
19-
bash_func_names = [func + '() {' for func in self.included_functions]
20-
_check_in_cpio(self, 'etc/profile', bash_func_names)
18+
"""Checks that all included functions are in the profile included in the generated CPIO file."""
19+
bash_func_names = [func + "() {" for func in self.included_functions]
20+
_check_in_cpio(self, "etc/profile", bash_func_names)
2121
return "All functions found in CPIO."
2222

2323

24-
@contains('check_in_cpio')
25-
@contains('check_cpio')
24+
@contains("check_in_cpio")
25+
@contains("check_cpio")
2626
def check_in_cpio(self) -> None:
27-
""" Checks that all required files and lines are in the generated CPIO file. """
28-
for file, lines in self['check_in_cpio'].items():
27+
"""Checks that all required files and lines are in the generated CPIO file."""
28+
for file, lines in self["check_in_cpio"].items():
2929
_check_in_cpio(self, file, lines)
3030
return "All files and lines found in CPIO."
3131

3232

3333
def _check_in_cpio(self, file, lines=[]):
34-
""" Checks that the file is in the CPIO archive, and it contains the specified lines. """
34+
"""Checks that the file is in the CPIO archive, and it contains the specified lines."""
3535
cpio = self._cpio_archive
36-
file = str(file).lstrip('/') # Normalize as it may be a path
36+
file = str(file).lstrip("/") # Normalize as it may be a path
3737
if file not in cpio.entries:
38-
self.logger.warning("CPIO entries:\n%s" % '\n'.join(cpio.entries.keys()))
38+
self.logger.warning("CPIO entries:\n%s" % "\n".join(cpio.entries.keys()))
3939
raise FileNotFoundError("File not found in CPIO: %s" % file)
4040
else:
4141
self.logger.debug("File found in CPIO: %s" % file)
@@ -50,20 +50,22 @@ def _check_in_cpio(self, file, lines=[]):
5050

5151

5252
def get_archive_path(self) -> str:
53-
""" Determines the filename for the output CPIO archive based on the current configuration. """
54-
if out_file := self.get('out_file'):
53+
"""Determines the filename for the output CPIO archive based on the current configuration."""
54+
if out_file := self.get("out_file"):
5555
self.logger.info("Using specified out_file: %s" % out_file)
5656
else:
57-
if self.get('kmod_init'):
57+
if self.get("kmod_init"):
5858
out_file = f"ugrd-{self['kernel_version']}.cpio"
5959
else:
6060
out_file = "ugrd.cpio"
6161

62-
if compression_type := self['cpio_compression']:
63-
if compression_type.lower() != 'false': # The variable is a string, so we need to check for the string 'false'
62+
if compression_type := self["cpio_compression"]:
63+
if (
64+
compression_type.lower() != "false"
65+
): # The variable is a string, so we need to check for the string 'false'
6466
out_file += f".{compression_type}"
6567

66-
self['_archive_out_path'] = self.out_dir / out_file
68+
self["_archive_out_path"] = self.out_dir / out_file
6769

6870

6971
def make_cpio(self) -> None:
@@ -74,24 +76,24 @@ def make_cpio(self) -> None:
7476
Raises FileNotFoundError if the output directory does not exist.
7577
"""
7678
cpio = self._cpio_archive
77-
cpio.append_recursive(self._get_build_path('/'), relative=True)
79+
cpio.append_recursive(self._get_build_path("/"), relative=True)
7880

79-
if self.get('mknod_cpio'):
80-
for node in self['nodes'].values():
81+
if self.get("mknod_cpio"):
82+
for node in self["nodes"].values():
8183
self.logger.debug("Adding CPIO node: %s" % node)
82-
cpio.add_chardev(name=node['path'], mode=node['mode'], major=node['major'], minor=node['minor'])
84+
cpio.add_chardev(name=node["path"], mode=node["mode"], major=node["major"], minor=node["minor"])
8385

84-
out_cpio = self['_archive_out_path']
86+
out_cpio = self["_archive_out_path"]
8587
if not out_cpio.parent.exists():
8688
self._mkdir(out_cpio.parent, resolve_build=False)
8789

8890
if out_cpio.exists():
89-
if self['cpio_rotate']:
91+
if self["cpio_rotate"]:
9092
self._rotate_old(out_cpio)
91-
elif self['clean']:
93+
elif self["clean"]:
9294
self.logger.warning("Removing existing file: %s" % out_cpio)
9395
out_cpio.unlink()
9496
else:
9597
raise FileExistsError("File already exists, and cleaning/rotation are disabled: %s" % out_cpio)
9698

97-
cpio.write_cpio_file(out_cpio, compression=self['cpio_compression'], _log_bump=-10, _log_init=False)
99+
cpio.write_cpio_file(out_cpio, compression=self["cpio_compression"], _log_bump=-10)

0 commit comments

Comments
 (0)