Re: [PATCH 04/22] Network.__str__() little cleanup (#520146)

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

 



Brian C. Lane wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/27/2010 01:49 AM, Radek Vykydal wrote:
Have line formatting only at one place, common for all
keys (at the end of __str__ method)
---
 network.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/network.py b/network.py
index 0a90800..e353a79 100644
--- a/network.py
+++ b/network.py
@@ -253,12 +253,12 @@ class NetworkDevice(IfcfgFile):
def __str__(self):
         s = ""
-        s = s + "DEVICE=" + self.info["DEVICE"] + "\n"
         keys = self.info.keys()
         keys.sort()
         keys.remove("DEVICE")
         if "DESC" in keys:
             keys.remove("DESC")
+        keys.insert(0, "DEVICE")
         if "KEY" in keys:
             keys.remove("KEY")
         if iutil.isS390() and ("HWADDR" in keys):

for multiple removes I'd use a loop:

for k in ["KEY","DESC"]:
    if k in keys:
        keys.remove(k)

Yes, but (you can't know) I am trying to get rid of special handling
of DESC (in one of next patches) and KEY parameters
(in a patch I am working on now) from this place so,
for the moment I just left them untouched.

And for DEVICE I think this is better than doing a remove and then an
insert:

if "DEVICE" not in keys:
    keys.insert(0, "DEVICE")

The point of DEVICE juggling before the patch was to
have it at the beginning of the string (and then ifcfg file),
I just kept this goal while having line formatting at one
place of the function (at the end), that is - not doing it
by removed (-) line, but by moving the 'DEVICE' key at
the beginning of the list.


Radek

_______________________________________________
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