[blivet:master 22/25] Put module level code in a method
mulhern
amulhern at redhat.com
Wed Apr 16 21:54:43 UTC 2014
To avoid having unnecessary global variables.
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/pyudev.py | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/blivet/pyudev.py b/blivet/pyudev.py
index 5d9dbf8..d57c8a9 100644
--- a/blivet/pyudev.py
+++ b/blivet/pyudev.py
@@ -23,16 +23,17 @@ def find_library(name, somajor=0):
return None
-# find the udev library
-name = "udev"
-somajor = 1
-libudev = find_library(name=name, somajor=somajor)
+def get_library():
+ name = "udev"
+ somajor = 1
+ libudev = find_library(name=name, somajor=somajor)
-if not libudev or not os.path.exists(libudev):
- raise ImportError("No library named %s.%d" % (name, somajor))
+ if not libudev or not os.path.exists(libudev):
+ raise ImportError("No library named %s.%d" % (name, somajor))
+ return libudev
# load the udev library
-libudev = CDLL(libudev)
+libudev = CDLL(get_library())
# create aliases for needed functions and set the return types where needed
--
1.8.3.1
More information about the anaconda-patches
mailing list