Commits

Michał Górny  committed eb8da55

Bootloaders: check validity already in __init__().

  • Participants
  • Parent commits e333a9b

Comments (0)

Files changed (2)

File ecleankernel/bootloader/lilo.py

 	kernel_re = r'^\s*image\s*=\s*(?P<path>.+)\s*$'
 	def_path = '/etc/lilo.conf'
 
-	def __init__(self, debug = False):
+	def __init__(self, debug = False, path = None):
 		self._debug = debug
 		self._kernel_re = re.compile(self.kernel_re,
 				re.MULTILINE | re.IGNORECASE)
 
+		with open(path or self.def_path) as f:
+			debug.print('%s found' % (path or self.def_path))
+			self._content = f.read()
+
 	def _get_kernels(self, content):
 		debug = self._debug
 
 		finally:
 			debug.outdent()
 
-	def __call__(self, path = None):
-		with open(path or self.def_path) as f:
-			self._debug.print('%s found' % (path or self.def_path))
-			return self._get_kernels(f.read())
+	def __call__(self):
+		return self._get_kernels(self._content)

File ecleankernel/bootloader/symlinks.py

 class Symlinks(object):
 	name = 'symlinks'
 
-	def __init__(self, debug = False):
+	def __init__(self, debug = False, path = None):
 		self._debug = debug
 
-	def __call__(self, path = None):
+	def __call__(self):
 		for fn in ('vmlinuz', 'vmlinux', 'kernel', 'bzImage'):
 			for suffix in ('', '.old'):
 				f = '/boot/%s%s' % (fn, suffix)