示例#1
0
    def add(self, base_path, section, pkg_dir):
        """
        Add all plugins in one filesystem path/packages.
        e.g.: (PYLUCID_BASE_PATH, "pylucid_project", "pylucid_plugins")
        """
        if not self._isdir(base_path):
            return

        pkg_path = os.path.join(base_path, pkg_dir)
        if not self._isdir(pkg_path):
            return

        if not has_init_file(pkg_path):
            if self.verbose:
                warnings.warn(
                    "plugin path %r doesn't contain a __init__.py file, skip."
                    % pkg_path)
            return

        if pkg_path not in sys.path:  # settings imported more than one time!
            #            print "append to sys.path: %r" % pkg_path
            sys.path.append(pkg_path)

        for plugin_name in os.listdir(pkg_path):
            if plugin_name.startswith(".") or plugin_name.startswith(
                    "_"):  # e.g. svn dir or __init__.py file
                continue

            if plugin_name in self:
                warnings.warn("Plugin %r exist more than one time." %
                              plugin_name)
                continue

            plugin_pkg = ".".join([section, pkg_dir, plugin_name])

            if not has_init_file(os.path.join(pkg_path, plugin_name)):
                if self.verbose:
                    warnings.warn(
                        "plugin '%s' doesn't contain a __init__.py file, skip."
                        % plugin_pkg)
                continue

            if self.verbose:
                print "add plugin %r" % plugin_pkg

            self.installed_plugins.append(plugin_pkg)

            abs_template_path = os.path.join(pkg_path, plugin_name,
                                             "templates")
            if os.path.isdir(abs_template_path):
                self.template_dirs.append(abs_template_path)

            additional_settings_path = os.path.join(pkg_path, plugin_name,
                                                    "additional_settings.py")
            if os.path.isfile(additional_settings_path):
                self.additional_settings.append("%s.additional_settings" %
                                                plugin_name)

            self[plugin_name] = (pkg_path, section, pkg_dir)
示例#2
0
    def add(self, base_path, section, pkg_dir):
        """
        Add all plugins in one filesystem path/packages.
        e.g.: (PYLUCID_BASE_PATH, "pylucid_project", "pylucid_plugins")
        """
        if not self._isdir(base_path):
            return

        pkg_path = os.path.join(base_path, pkg_dir)
        if not self._isdir(pkg_path):
            return

        if not has_init_file(pkg_path):
            if self.verbose:
                warnings.warn("plugin path %r doesn't contain a __init__.py file, skip." % pkg_path)
            return

        if pkg_path not in sys.path: # settings imported more than one time!
#            print "append to sys.path: %r" % pkg_path
            sys.path.append(pkg_path)

        for plugin_name in os.listdir(pkg_path):
            if plugin_name.startswith(".") or plugin_name.startswith("_"): # e.g. svn dir or __init__.py file
                continue

            if plugin_name in self:
                warnings.warn("Plugin %r exist more than one time." % plugin_name)
                continue

            plugin_pkg = ".".join([section, pkg_dir, plugin_name])

            if not has_init_file(os.path.join(pkg_path, plugin_name)):
                if self.verbose:
                    warnings.warn("plugin '%s' doesn't contain a __init__.py file, skip." % plugin_pkg)
                continue

            if self.verbose:
                print "add plugin %r" % plugin_pkg

            self.installed_plugins.append(plugin_pkg)

            abs_template_path = os.path.join(pkg_path, plugin_name, "templates")
            if os.path.isdir(abs_template_path):
                self.template_dirs.append(abs_template_path)

            additional_settings_path = os.path.join(pkg_path, plugin_name, "additional_settings.py")
            if os.path.isfile(additional_settings_path):
                self.additional_settings.append("%s.additional_settings" % plugin_name)

            self[plugin_name] = (pkg_path, section, pkg_dir)
示例#3
0
    def __init__(self, pkg_path, section, pkg_dir, plugin_name):
        # e.g.: "PYLUCID_BASE_PATH/pylucid_project/pylucid_plugins", "pylucid_project", "pylucid_plugins", "PluginName"
        self.name = plugin_name

        self.fs_path = os.path.join(pkg_path, plugin_name)
        assert os.path.isdir(self.fs_path), "path %r is not a directory or doesn't exist." % self.fs_path
        assert has_init_file(self.fs_path), "%r contains no __init__.py file!" % self.fs_path

        self.pkg_string = ".".join([pkg_dir, plugin_name])
        self.installed_apps_string = ".".join([section, self.pkg_string])

        template_dir = os.path.join(self.fs_path, "templates")
        if os.path.isdir(template_dir):
            self.template_dir = template_dir
        else:
            self.template_dir = None
示例#4
0
    def __init__(self, pkg_path, section, pkg_dir, plugin_name):
        # e.g.: "PYLUCID_BASE_PATH/pylucid_project/pylucid_plugins", "pylucid_project", "pylucid_plugins", "PluginName"
        self.name = plugin_name

        self.fs_path = os.path.join(pkg_path, plugin_name)
        assert os.path.isdir(
            self.fs_path
        ), "path %r is not a directory or doesn't exist." % self.fs_path
        assert has_init_file(
            self.fs_path), "%r contains no __init__.py file!" % self.fs_path

        self.pkg_string = ".".join([pkg_dir, plugin_name])
        self.installed_apps_string = ".".join([section, self.pkg_string])

        template_dir = os.path.join(self.fs_path, "templates")
        if os.path.isdir(template_dir):
            self.template_dir = template_dir
        else:
            self.template_dir = None