[pykickstart 1/4] method getattr should default to handler.url
Brian C. Lane
bcl at redhat.com
Wed Oct 16 20:30:47 UTC 2013
From: "Brian C. Lane" <bcl at redhat.com>
When setting method attributes it defaults to using the url handler when
method is None, but there was no way to retrieve them once set. This
re-factors the __getattr__ handler so that internal methods go to the
right place and all others go to the first seen handler, or to
handler.url if method is None (used for closest mirror).
---
pykickstart/commands/method.py | 39 +++++++++++++++------------------------
1 file changed, 15 insertions(+), 24 deletions(-)
diff --git a/pykickstart/commands/method.py b/pykickstart/commands/method.py
index 4046a0a..4fb78cd 100644
--- a/pykickstart/commands/method.py
+++ b/pykickstart/commands/method.py
@@ -36,30 +36,21 @@ class FC3_Method(KickstartCommand):
setattr(getattr(self.handler, method), "seen", False)
def __getattr__(self, name):
- if self.handler.cdrom.seen:
- if name == "method":
- return "cdrom"
- else:
- return getattr(self.handler.cdrom, name)
- elif self.handler.harddrive.seen:
- if name == "method":
- return "harddrive"
- else:
- return getattr(self.handler.harddrive, name)
- elif self.handler.nfs.seen:
- if name == "method":
- return "nfs"
- else:
- return getattr(self.handler.nfs, name)
- elif self.handler.url.seen:
- if name == "method":
- return "url"
- else:
- return getattr(self.handler.url, name)
- elif name == "method":
- return None
- else:
- return object.__getattribute__(self, name)
+ if name in self.internals:
+ if name == "method":
+ for method in self._methods:
+ if getattr(self.handler, method).seen:
+ return method
+ return None
+ else:
+ return object.__getattribute__(self, name)
+
+ # Return name from first seen handler, or url
+ for method in self._methods:
+ if getattr(self.handler, method).seen:
+ return getattr(getattr(self.handler, method), name)
+
+ return getattr(self.handler.url, name)
def __setattr__(self, name, value):
if name in self.internals:
--
1.8.3.1
More information about the anaconda-patches
mailing list