[PATCH pykickstart] Add lineno to BaseData and derived classes

[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                |    7 +++++--
 pykickstart/commands/device.py     |    2 +-
 pykickstart/commands/dmraid.py     |    2 +-
 pykickstart/commands/driverdisk.py |    2 +-
 pykickstart/commands/fcoe.py       |    2 +-
 pykickstart/commands/group.py      |    2 +-
 pykickstart/commands/iscsi.py      |    2 +-
 pykickstart/commands/logvol.py     |    2 +-
 pykickstart/commands/multipath.py  |    2 +-
 pykickstart/commands/network.py    |    2 +-
 pykickstart/commands/partition.py  |    2 +-
 pykickstart/commands/raid.py       |    2 +-
 pykickstart/commands/repo.py       |    2 +-
 pykickstart/commands/sshpw.py      |    2 +-
 pykickstart/commands/user.py       |    2 +-
 pykickstart/commands/volgroup.py   |    2 +-
 pykickstart/commands/zfcp.py       |    2 +-
 17 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/pykickstart/base.py b/pykickstart/base.py
index aa4e9d8..3c1237a 100644
--- a/pykickstart/base.py
+++ b/pykickstart/base.py
@@ -157,7 +157,9 @@ class KickstartCommand(KickstartObject):
     # useful to call this from KickstartCommand subclasses that handle lists
     # of objects (like partitions, network devices, etc.) and need to populate
     # a Data object.
-    def _setToObj(self, optParser, opts, obj):
+    def _setToObj(self, optParser, opts, obj, lineno=None):
+        if lineno:
+            obj.lineno = lineno
         for key in filter (lambda k: getattr(opts, k) != None, optParser.keys()):
             setattr(obj, key, getattr(opts, key))
 
@@ -431,13 +433,14 @@ class BaseData(KickstartObject):
     removedAttrs = []
 
     def __init__(self, *args, **kwargs):
-        """Create a new BaseData instance.  There are no attributes."""
+        """Create a new BaseData instance.  The only attribute is lineno."""
 
         # 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..9a608aa 100644
--- a/pykickstart/commands/device.py
+++ b/pykickstart/commands/device.py
@@ -111,7 +111,7 @@ class F8_Device(FC3_Device):
             raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("%s command requires a single argument: %s") % ("device", "module name"))
 
         dd = F8_DeviceData()
-        self._setToObj(self.op, opts, dd)
+        self._setToObj(self.op, opts, dd, 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..6136cb9 100644
--- a/pykickstart/commands/dmraid.py
+++ b/pykickstart/commands/dmraid.py
@@ -78,7 +78,7 @@ class FC6_DmRaid(KickstartCommand):
         dm = FC6_DmRaidData()
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
         dm.name = dm.name.split('/')[-1]
-        self._setToObj(self.op, opts, dm)
+        self._setToObj(self.op, opts, dm, 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..0b85796 100644
--- a/pykickstart/commands/driverdisk.py
+++ b/pykickstart/commands/driverdisk.py
@@ -95,7 +95,7 @@ class FC3_DriverDisk(KickstartCommand):
             raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --source or partition must be specified for driverdisk command."))
 
         ddd = self.handler.DriverDiskData()
-        self._setToObj(self.op, opts, ddd)
+        self._setToObj(self.op, opts, ddd, self.lineno)
         if len(extra) == 1:
             ddd.partition = extra[0]
 
diff --git a/pykickstart/commands/fcoe.py b/pykickstart/commands/fcoe.py
index 3e85b1b..d95ed9d 100644
--- a/pykickstart/commands/fcoe.py
+++ b/pykickstart/commands/fcoe.py
@@ -92,7 +92,7 @@ class F12_Fcoe(KickstartCommand):
             mapping = {"command": "fcoe", "options": extra}
             raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
 
-        self._setToObj(self.op, opts, zd)
+        self._setToObj(self.op, opts, zd, 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..5e59465 100644
--- a/pykickstart/commands/group.py
+++ b/pykickstart/commands/group.py
@@ -75,7 +75,7 @@ class F12_Group(KickstartCommand):
     def parse(self, args):
         gd = self.handler.GroupData()
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
-        self._setToObj(self.op, opts, gd)
+        self._setToObj(self.op, opts, gd, 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..044e676 100644
--- a/pykickstart/commands/iscsi.py
+++ b/pykickstart/commands/iscsi.py
@@ -113,7 +113,7 @@ class FC6_Iscsi(KickstartCommand):
             raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
 
         dd = self.handler.IscsiData()
-        self._setToObj(self.op, opts, dd)
+        self._setToObj(self.op, opts, dd, self.lineno)
         return dd
 
     def dataList(self):
diff --git a/pykickstart/commands/logvol.py b/pykickstart/commands/logvol.py
index a030fc9..948f183 100644
--- a/pykickstart/commands/logvol.py
+++ b/pykickstart/commands/logvol.py
@@ -210,7 +210,7 @@ class FC3_LogVol(KickstartCommand):
             raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "logvol")
 
         lvd = self.handler.LogVolData()
-        self._setToObj(self.op, opts, lvd)
+        self._setToObj(self.op, opts, lvd, 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..e910677 100644
--- a/pykickstart/commands/multipath.py
+++ b/pykickstart/commands/multipath.py
@@ -85,7 +85,7 @@ class FC6_MultiPath(KickstartCommand):
     def parse(self, args):
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
         dd = FC6_MpPathData()
-        self._setToObj(self.op, opts, dd)
+        self._setToObj(self.op, opts, dd, self.lineno)
         dd.mpdev = dd.mpdev.split('/')[-1]
 
         parent = None
diff --git a/pykickstart/commands/network.py b/pykickstart/commands/network.py
index 6962de2..3eb5548 100644
--- a/pykickstart/commands/network.py
+++ b/pykickstart/commands/network.py
@@ -205,7 +205,7 @@ class FC3_Network(KickstartCommand):
     def parse(self, args):
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
         nd = self.handler.NetworkData()
-        self._setToObj(self.op, opts, nd)
+        self._setToObj(self.op, opts, nd, 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..ed0f85e 100644
--- a/pykickstart/commands/partition.py
+++ b/pykickstart/commands/partition.py
@@ -241,7 +241,7 @@ class FC3_Partition(KickstartCommand):
             raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "partition")
 
         pd = self.handler.PartData()
-        self._setToObj(self.op, opts, pd)
+        self._setToObj(self.op, opts, pd, 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..d2c8f2e 100644
--- a/pykickstart/commands/raid.py
+++ b/pykickstart/commands/raid.py
@@ -233,7 +233,7 @@ class FC3_Raid(KickstartCommand):
             raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Partitions required for %s") % "raid")
 
         rd = self.handler.RaidData()
-        self._setToObj(self.op, opts, rd)
+        self._setToObj(self.op, opts, rd, 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..1e9b14b 100644
--- a/pykickstart/commands/repo.py
+++ b/pykickstart/commands/repo.py
@@ -148,7 +148,7 @@ class FC6_Repo(KickstartCommand):
             raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --baseurl or --mirrorlist must be specified for repo command."))
 
         rd = self.handler.RepoData()
-        self._setToObj(self.op, opts, rd)
+        self._setToObj(self.op, opts, rd, 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..ec2cc31 100644
--- a/pykickstart/commands/sshpw.py
+++ b/pykickstart/commands/sshpw.py
@@ -89,7 +89,7 @@ class F13_SshPw(KickstartCommand):
     def parse(self, args):
         ud = self.handler.SshPwData()
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
-        self._setToObj(self.op, opts, ud)
+        self._setToObj(self.op, opts, ud, 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..7961720 100644
--- a/pykickstart/commands/user.py
+++ b/pykickstart/commands/user.py
@@ -143,7 +143,7 @@ class FC6_User(KickstartCommand):
     def parse(self, args):
         ud = self.handler.UserData()
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
-        self._setToObj(self.op, opts, ud)
+        self._setToObj(self.op, opts, ud, 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..c1c3446 100644
--- a/pykickstart/commands/volgroup.py
+++ b/pykickstart/commands/volgroup.py
@@ -88,7 +88,7 @@ class FC3_VolGroup(KickstartCommand):
     def parse(self, args):
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
         vg = self.handler.VolGroupData()
-        self._setToObj(self.op, opts, vg)
+        self._setToObj(self.op, opts, vg, self.lineno)
         vg.vgname = extra[0]
         vg.physvols = extra[1:]
 
diff --git a/pykickstart/commands/zfcp.py b/pykickstart/commands/zfcp.py
index 060cd39..9c32f4e 100644
--- a/pykickstart/commands/zfcp.py
+++ b/pykickstart/commands/zfcp.py
@@ -95,7 +95,7 @@ class FC3_ZFCP(KickstartCommand):
     def parse(self, args):
         zd = self.handler.ZFCPData()
         (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
-        self._setToObj(self.op, opts, zd)
+        self._setToObj(self.op, opts, zd, 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