[PATCH pykickstart] Add lineno to BaseData and derived classes (version 2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a lineno to BaseData derived classes, so that execute methods
in anaconda's kickstart.py can get the line no a data list entry comes from
for error reporting.
---
 pykickstart/base.py                |    6 +++++-
 pykickstart/commands/device.py     |    1 +
 pykickstart/commands/dmraid.py     |    1 +
 pykickstart/commands/driverdisk.py |    1 +
 pykickstart/commands/fcoe.py       |    1 +
 pykickstart/commands/group.py      |    1 +
 pykickstart/commands/iscsi.py      |    1 +
 pykickstart/commands/logvol.py     |    1 +
 pykickstart/commands/multipath.py  |    1 +
 pykickstart/commands/network.py    |    1 +
 pykickstart/commands/partition.py  |    1 +
 pykickstart/commands/raid.py       |    1 +
 pykickstart/commands/repo.py       |    1 +
 pykickstart/commands/sshpw.py      |    1 +
 pykickstart/commands/user.py       |    1 +
 pykickstart/commands/volgroup.py   |    1 +
 pykickstart/commands/zfcp.py       |    1 +
 17 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/pykickstart/base.py b/pykickstart/base.py
index aa4e9d8..4944617 100644
--- a/pykickstart/base.py
+++ b/pykickstart/base.py
@@ -431,13 +431,17 @@ class BaseData(KickstartObject):
     removedAttrs = []
 
     def __init__(self, *args, **kwargs):
-        """Create a new BaseData instance.  There are no attributes."""
+        """Create a new BaseData instance.
+        
+           lineno -- Line number in the ks-file where this object was defined
+        """
 
         # We don't want people using this class by itself.
         if self.__class__ is BaseData:
             raise TypeError, "BaseData is an abstract class."
 
         KickstartObject.__init__(self, *args, **kwargs)
+        self.lineno = 0
 
     def __str__(self):
         """Return a string formatted for output to a kickstart file."""
diff --git a/pykickstart/commands/device.py b/pykickstart/commands/device.py
index 8ed4f4b..321410e 100644
--- a/pykickstart/commands/device.py
+++ b/pykickstart/commands/device.py
@@ -112,6 +112,7 @@ class F8_Device(FC3_Device):
 
         dd = F8_DeviceData()
         self._setToObj(self.op, opts, dd)
+        dd.lineno = self.lineno
         dd.moduleName = extra[0]
 
         # Check for duplicates in the data list.
diff --git a/pykickstart/commands/dmraid.py b/pykickstart/commands/dmraid.py
index daf8ee5..993575a 100644
--- a/pykickstart/commands/dmraid.py
+++ b/pykickstart/commands/dmraid.py
@@ -79,6 +79,7 @@ class FC6_DmRaid(KickstartCommand):
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
         dm.name = dm.name.split('/')[-1]
         self._setToObj(self.op, opts, dm)
+        dm.lineno = self.lineno
 
         # Check for duplicates in the data list.
         if dm in self.dataList():
diff --git a/pykickstart/commands/driverdisk.py b/pykickstart/commands/driverdisk.py
index dd5d1bb..f280303 100644
--- a/pykickstart/commands/driverdisk.py
+++ b/pykickstart/commands/driverdisk.py
@@ -96,6 +96,7 @@ class FC3_DriverDisk(KickstartCommand):
 
         ddd = self.handler.DriverDiskData()
         self._setToObj(self.op, opts, ddd)
+        ddd.lineno = self.lineno
         if len(extra) == 1:
             ddd.partition = extra[0]
 
diff --git a/pykickstart/commands/fcoe.py b/pykickstart/commands/fcoe.py
index 3e85b1b..3320849 100644
--- a/pykickstart/commands/fcoe.py
+++ b/pykickstart/commands/fcoe.py
@@ -93,6 +93,7 @@ class F12_Fcoe(KickstartCommand):
             raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
 
         self._setToObj(self.op, opts, zd)
+        zd.lineno = self.lineno
 
         # Check for duplicates in the data list.
         if zd in self.dataList():
diff --git a/pykickstart/commands/group.py b/pykickstart/commands/group.py
index 92fe796..80ba5bd 100644
--- a/pykickstart/commands/group.py
+++ b/pykickstart/commands/group.py
@@ -76,6 +76,7 @@ class F12_Group(KickstartCommand):
         gd = self.handler.GroupData()
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
         self._setToObj(self.op, opts, gd)
+        gd.lineno = self.lineno
 
         # Check for duplicates in the data list.
         if gd in self.dataList():
diff --git a/pykickstart/commands/iscsi.py b/pykickstart/commands/iscsi.py
index ff63401..da5a544 100644
--- a/pykickstart/commands/iscsi.py
+++ b/pykickstart/commands/iscsi.py
@@ -114,6 +114,7 @@ class FC6_Iscsi(KickstartCommand):
 
         dd = self.handler.IscsiData()
         self._setToObj(self.op, opts, dd)
+        dd.lineno = self.lineno
         return dd
 
     def dataList(self):
diff --git a/pykickstart/commands/logvol.py b/pykickstart/commands/logvol.py
index a030fc9..a7ccabc 100644
--- a/pykickstart/commands/logvol.py
+++ b/pykickstart/commands/logvol.py
@@ -211,6 +211,7 @@ class FC3_LogVol(KickstartCommand):
 
         lvd = self.handler.LogVolData()
         self._setToObj(self.op, opts, lvd)
+        lvd.lineno = self.lineno
         lvd.mountpoint=extra[0]
 
         # Check for duplicates in the data list.
diff --git a/pykickstart/commands/multipath.py b/pykickstart/commands/multipath.py
index 2a80197..3941c89 100644
--- a/pykickstart/commands/multipath.py
+++ b/pykickstart/commands/multipath.py
@@ -86,6 +86,7 @@ class FC6_MultiPath(KickstartCommand):
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
         dd = FC6_MpPathData()
         self._setToObj(self.op, opts, dd)
+        dd.lineno = self.lineno
         dd.mpdev = dd.mpdev.split('/')[-1]
 
         parent = None
diff --git a/pykickstart/commands/network.py b/pykickstart/commands/network.py
index 6962de2..e2a3101 100644
--- a/pykickstart/commands/network.py
+++ b/pykickstart/commands/network.py
@@ -206,6 +206,7 @@ class FC3_Network(KickstartCommand):
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
         nd = self.handler.NetworkData()
         self._setToObj(self.op, opts, nd)
+        nd.lineno = self.lineno
 
         # Check for duplicates in the data list.
         if nd in self.dataList():
diff --git a/pykickstart/commands/partition.py b/pykickstart/commands/partition.py
index 2104aa9..70b2283 100644
--- a/pykickstart/commands/partition.py
+++ b/pykickstart/commands/partition.py
@@ -242,6 +242,7 @@ class FC3_Partition(KickstartCommand):
 
         pd = self.handler.PartData()
         self._setToObj(self.op, opts, pd)
+        pd.lineno = self.lineno
         pd.mountpoint=extra[0]
 
         # Check for duplicates in the data list.
diff --git a/pykickstart/commands/raid.py b/pykickstart/commands/raid.py
index 13ac6d3..c9d4342 100644
--- a/pykickstart/commands/raid.py
+++ b/pykickstart/commands/raid.py
@@ -234,6 +234,7 @@ class FC3_Raid(KickstartCommand):
 
         rd = self.handler.RaidData()
         self._setToObj(self.op, opts, rd)
+        rd.lineno = self.lineno
 
         # --device can't just take an int in the callback above, because it
         # could be specificed as "mdX", which causes optparse to error when
diff --git a/pykickstart/commands/repo.py b/pykickstart/commands/repo.py
index f1263e5..521aeb3 100644
--- a/pykickstart/commands/repo.py
+++ b/pykickstart/commands/repo.py
@@ -149,6 +149,7 @@ class FC6_Repo(KickstartCommand):
 
         rd = self.handler.RepoData()
         self._setToObj(self.op, opts, rd)
+        rd.lineno = self.lineno
 
         # Check for duplicates in the data list.
         if rd in self.dataList():
diff --git a/pykickstart/commands/sshpw.py b/pykickstart/commands/sshpw.py
index 9d48e22..e7867eb 100644
--- a/pykickstart/commands/sshpw.py
+++ b/pykickstart/commands/sshpw.py
@@ -90,6 +90,7 @@ class F13_SshPw(KickstartCommand):
         ud = self.handler.SshPwData()
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
         self._setToObj(self.op, opts, ud)
+        ud.lineno = self.lineno
 
         if len(extra) != 1:
             raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "sshpw")
diff --git a/pykickstart/commands/user.py b/pykickstart/commands/user.py
index b84c555..093dada 100644
--- a/pykickstart/commands/user.py
+++ b/pykickstart/commands/user.py
@@ -144,6 +144,7 @@ class FC6_User(KickstartCommand):
         ud = self.handler.UserData()
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
         self._setToObj(self.op, opts, ud)
+        ud.lineno = self.lineno
 
         # Check for duplicates in the data list.
         if ud in self.dataList():
diff --git a/pykickstart/commands/volgroup.py b/pykickstart/commands/volgroup.py
index 3b6d089..929052e 100644
--- a/pykickstart/commands/volgroup.py
+++ b/pykickstart/commands/volgroup.py
@@ -89,6 +89,7 @@ class FC3_VolGroup(KickstartCommand):
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
         vg = self.handler.VolGroupData()
         self._setToObj(self.op, opts, vg)
+        vg.lineno = self.lineno
         vg.vgname = extra[0]
         vg.physvols = extra[1:]
 
diff --git a/pykickstart/commands/zfcp.py b/pykickstart/commands/zfcp.py
index 060cd39..b455a81 100644
--- a/pykickstart/commands/zfcp.py
+++ b/pykickstart/commands/zfcp.py
@@ -96,6 +96,7 @@ class FC3_ZFCP(KickstartCommand):
         zd = self.handler.ZFCPData()
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
         self._setToObj(self.op, opts, zd)
+        zd.lineno = self.lineno
 
         # Check for duplicates in the data list.
         if zd in self.dataList():
-- 
1.6.5.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux