diff --git a/callirhoe.py b/callirhoe.py index f6fcf1c..9ad58bb 100755 --- a/callirhoe.py +++ b/callirhoe.py @@ -84,13 +84,12 @@ def import_plugin(plugin_paths, cat, longcat, longcat2, listopt, preset): for path in plugin_paths: found += available_files(path, cat, preset) if len(found) == 0: raise IOError - if found[0][1] == "/": + if found[0][1] == "resource:": m = __import__("%s.%s" % (cat,preset), globals(), locals(), [ "*" ]) else: - old = sys.path[0] - sys.path[0] = found[0][1] + sys.path.insert(0, found[0][1]) m = __import__("%s.%s" % (cat,preset), globals(), locals(), [ "*" ]) - sys.path[0] = old + sys.path.pop(0) return m except IOError: sys.exit("callirhoe: %s definition '%s' not found, use %s to see available definitions" % (longcat, diff --git a/lib/plugin.py b/lib/plugin.py index 1f287c7..76768c2 100644 --- a/lib/plugin.py +++ b/lib/plugin.py @@ -29,7 +29,7 @@ import glob try: import resources except: - pass + resources = None def available_files(parent, dir, fmatch = None): """find parent/dir/*.py files to be used for plugins @@ -43,7 +43,7 @@ def available_files(parent, dir, fmatch = None): good = False res = [] pattern = parent + "/" + dir + "/*.py" - for x in glob.glob(pattern) if parent != "/" else resources.resource_list[dir]: + for x in glob.glob(pattern) if not parent.startswith('resource:') else resources.resource_list[dir]: basex = os.path.basename(x) if basex == "__init__.py": good = True elif basex.startswith('_'): @@ -78,9 +78,6 @@ def get_plugin_paths(): @rtype: [str,str,..] """ result = [ os.path.expanduser("~/.callirhoe"), sys.path[0] if sys.path[0] else "." ] - try: - temp = resources.resource_list - result.append("/") - except: - pass + if resources: + result.append("resource:") return result diff --git a/make_pkg b/make_pkg index 49a29f3..9700886 100755 --- a/make_pkg +++ b/make_pkg @@ -2,7 +2,7 @@ # Create Callirhoe package mkdir _callirhoe -./make_resources_list > resources.py +./make_resources_list cp -R geom holidays lang layouts lib style _callirhoe cp callirhoe.py _callirhoe/__main__.py mv resources.py _callirhoe/lib