[PATCH] let module_loader load goodies out of __init__ files

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

 



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

Attached.

I'm doing something like this where I want some functions to hook at a
certain level while attaching packages within the same level (if that
makes sense to anyone):

netapp.vol.create
netapp.vol.status
netapp.vol.clone.create
netapp.vol.clone.split

It doesn't look like this breaks anything but wanted to get some
opinions before I go committing and possibly breaking a key part of the
core :)

- --
John Eckersberg
Production Operations
Red Hat, Inc.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFHnfY3O5VSO/Qqm+gRAhJoAJ9LY8x73ANWS6VzVdh2LUQOKd2RdgCgn8g3
wzihF5WJW2WYzApm/kA2VQQ=
=7eLo
-----END PGP SIGNATURE-----
diff --git a/func/minion/module_loader.py b/func/minion/module_loader.py
index 37bc515..3068ea8 100755
--- a/func/minion/module_loader.py
+++ b/func/minion/module_loader.py
@@ -32,9 +32,6 @@ def module_walker(topdir):
         for filename in files:
             # ASSUMPTION: all module files will end with .py, .pyc, .pyo
             if filename[-3:] == ".py" or filename[-4:] == ".pyc" or filename[-4:] == ".pyo":
-                # we don't really care about __init__ files, though we do requure them
-                if filename[:8] == "__init__":
-                    continue
                 # the normpath is important, since we eventually replace /'s with .'s
                 # in the module name, and foo..bar doesnt work -akl
                 module_files.append(os.path.normpath("%s/%s" % (root, filename)))
@@ -59,9 +56,10 @@ def load_modules(blacklist=None):
         module_name_part = fn[len(module_file_path):]
         dirname, basename = os.path.split(module_name_part)
 
-        if basename == "__init__.py":
-            continue
-        if basename[-3:] == ".py":
+        if basename[:8] == "__init__":
+            modname = dirname
+            dirname = ""
+        elif basename[-3:] == ".py":
             modname = basename[:-3]
         elif basename[-4:] in [".pyc", ".pyo"]:
             modname = basename[:-4]

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux