コード例 #1
0
ファイル: customize.py プロジェクト: blaflamme/ptah
    def reload_package(self, pkg):
        if pkg not in tmpl.registry:
            return

        # unload
        pkg_data = tmpl.registry[pkg]

        for fn, (p,t,d,t,pkg) in pkg_data.items():
            if t.custom is not None:
                t.setCustom(None)

        # re-initialize layers
        _Manager.initialize(pkg)

        # load global custom
        path = os.path.join(self.directory, pkg)

        if os.path.isdir(path):
            pkg_data = tmpl.registry[pkg]
            try:
                items = dict((f, 1) for f in os.listdir(path))
            except os.OSError: # pragma: no cover
                return

            for fn, (p,t,d,t,pkg) in pkg_data.items():
                if fn in items and t.custom is None:
                    t.setCustom(tmpl.getRenderer(os.path.join(path, fn)))
                else:
                    if t.custom is not None:
                        t.setCustom(None) # pragma: no cover
コード例 #2
0
ファイル: customize.py プロジェクト: blaflamme/ptah
    def load(self):
        for dir in os.listdir(self.directory):
            if dir not in tmpl.registry:
                continue

            path = os.path.join(self.directory, dir)

            if os.path.isdir(path):
                pkg_data = tmpl.registry[dir]
                for item in os.listdir(path):
                    if item in pkg_data:
                        pkg_data[item][3].setCustom(
                            tmpl.getRenderer(os.path.join(path, item)))
コード例 #3
0
ファイル: customize.py プロジェクト: blaflamme/ptah
    def initialize(self, filter=None):
        layers = self.layers

        for pkg, pkg_data in tmpl.registry.items():
            if pkg not in layers:
                continue

            if filter is not None and filter != pkg:
                continue # pragma: no cover

            for fn, (p,t,d,t,_pkg) in pkg_data.items():

                for pkgname, abspath, path in layers[pkg]:
                    tpath = os.path.join(abspath, fn)
                    if os.path.isfile(tpath):
                        t.setCustom(tmpl.getRenderer(tpath))
                        break