Add search_package utility function.
authorRadek Brich <radek.brich@devl.cz>
Thu, 11 Jul 2013 15:20:35 +0200
changeset 6 bb7742f924d7
parent 5 055f7dfb3e4f
child 7 776ba4914dfc
Add search_package utility function.
pycolib/syspath.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pycolib/syspath.py	Thu Jul 11 15:20:35 2013 +0200
@@ -0,0 +1,15 @@
+import sys
+import os.path
+
+
+def search_package(package_name):
+    """Add package name to all paths in sys.path.
+
+    This allows the program to be installed inside some package,
+    but leave the imports as they are.
+
+    Just add `search_package` before any imports.
+
+    """
+    sys.path += [os.path.join(path, package_name) for path in sys.path]
+