[elbe-devel] [PATCH 20/25] pylint: fstab: setup geometry in new function, and init attrs in __init__()

Torben Hohn torben.hohn at linutronix.de
Wed Aug 22 10:42:21 CEST 2018


pylint complains:
-------------------------------------------------------------------------------------------------------------------
elbepack/fstab.py:128: [E1101(no-member), fstabentry.losetup] Instance of 'fstabentry' has no 'offset' member
elbepack/fstab.py:128: [E1101(no-member), fstabentry.losetup] Instance of 'fstabentry' has no 'size' member
elbepack/fstab.py:128: [E1101(no-member), fstabentry.losetup] Instance of 'fstabentry' has no 'filename' member
-------------------------------------------------------------------------------------------------------------------

These attributes are set from elbepack.hdimg.
They are not initialized in the constructor.

Init them in constructor, and implement fstabentry.set_geometry()
to move the code into fstabentry class.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/fstab.py | 16 ++++++++++++++++
 elbepack/hdimg.py |  8 +-------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/elbepack/fstab.py b/elbepack/fstab.py
index 7d5f792c..db887587 100644
--- a/elbepack/fstab.py
+++ b/elbepack/fstab.py
@@ -91,6 +91,14 @@ class fstabentry(object):
         else:
             self.passno = "0"
 
+        # These attributes are filled later
+        # using set_geometry()
+        self.size = 0
+        self.offset = 0
+        self.filename = ''
+        self.partnum = 0
+        self.number = ''
+
         self.id = str(id)
 
     def get_str(self):
@@ -123,6 +131,14 @@ class fstabentry(object):
 
         return ""
 
+    def set_geometry(self, ppart, disk):
+        sector_size = 512
+        self.offset = ppart.geometry.start * sector_size
+        self.size = ppart.getLength() * sector_size
+        self.filename = disk.device.path
+        self.partnum = ppart.number
+        self.number = '{}{}'.format(disk.type, ppart.number)
+
     def losetup(self, outf, loopdev):
         outf.do('losetup -o%d --sizelimit %d /dev/%s "%s"' %
                 (self.offset, self.size, loopdev, self.filename))
diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
index fb7e7922..26dcce50 100644
--- a/elbepack/hdimg.py
+++ b/elbepack/hdimg.py
@@ -400,14 +400,8 @@ def create_label(outf, disk, part, ppart, fslabel, target, grub):
 
     # pylint: disable=too-many-arguments
 
-    sector_size = 512
-    partition_number = ppart.number
     entry = fslabel[part.text("label")]
-    entry.offset = ppart.geometry.start * sector_size
-    entry.size = ppart.getLength() * sector_size
-    entry.filename = disk.device.path
-    entry.partnum = partition_number
-    entry.number = '{}{}'.format(disk.type, partition_number)
+    entry.set_geometry(ppart, disk)
 
     if entry.mountpoint == "/":
         grub.set_root_entry(entry)
-- 
2.11.0




More information about the elbe-devel mailing list