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

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

 



-----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)

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")

- -- 
Brian C. Lane <bcl@xxxxxxxxxx>
Red Hat / Port Orchard, WA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEVAwUBS9cwSBF+jBaO/jp/AQIxNQgAgKcBdimj7YTS6buVRnRD0Ggnadmoo16i
kaaujUgN92rYz575hstMKcKKnZzOrWMqP9oKBnSk3cXHK7P9uy2Wt03lqoWIBrDY
IxLEV65/RpX31ufMLlwiAF320lkcZzznbCjeEXxk34OTxaNG3HVl0Y553ZQLgL/e
c1pRRahFJ5OMNGJJDUmMKSkJx2EZAw9Zc5SCjnAwrPzfLqw/0EcGbF163i/bO+FD
u++Yj778Tjqnp8jYbwX9qQSE4he6lQOrAyjDWtmf3WmXVlzxJ55hPfNlWKO9E5W+
WXD8kc4f2QvbORVnS6HLr5IP9pbsQ4uBlVuidYeorZ1oSvIsu7umzA==
=rXcV
-----END PGP SIGNATURE-----

_______________________________________________
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