Skip to content

Commit 25349e8

Browse files
KSmanismgorny
authored andcommitted
Fix GRUB2._autogen AttributeError
GRUB2._autogen should and can be determined on initialization, rather than when retrieving the list of kernels (which may or may not happen before the attribute is accessed). Signed-off-by: Konstantinos Smanis <[email protected]> Closes: #6 Signed-off-by: Michał Górny <[email protected]>
1 parent b0cace4 commit 25349e8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ecleankernel/bootloader/grub2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ class GRUB2(GRUB):
2020
kernel_re = r'^\s*linux\s*(\([^)]+\))?(?P<path>\S+)'
2121
def_path = ('/boot/grub/grub.cfg', '/boot/grub2/grub.cfg')
2222

23+
def __init__(self) -> None:
24+
super().__init__()
25+
self._autogen = self._content.startswith(grub2_autogen_header)
26+
2327
def _get_kernels(self,
2428
content: str
2529
) -> typing.Iterable[str]:
26-
self._autogen = content.startswith(grub2_autogen_header)
27-
2830
if self._autogen:
2931
logging.debug('Config is autogenerated, ignoring')
3032
return ()

0 commit comments

Comments
 (0)