Beispiel #1
0
        def fillPluginsFrom(folder):
            """ good old plugins importer """
            for id in os.listdir(folder):
                path = folder + "/" + id
                if id[0] != "." and os.path.isdir(path):
                    namespace = path.replace("/", ".")

                    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- to be run from here ;-)
                    namespace = re.sub("\.\.+", "", namespace)
                    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- manatlan

                    old = __builtins__["_"]  # save the jbrout _()
                    try:
                        _trans = createGetText("plugin",
                                               os.path.join(path, "po"))

                        __builtins__["_"] = _trans

                        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- reset the Entry def
                        Entry.definitions = {}
                        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

                        # import the module plugin
                        module = __import__(namespace, [_], [_], ["Plugin"])

                        # create the _() for __init__ plugins
                        module.__dict__["_"] = _trans

                        # create an instance
                        instance = module.Plugin(id, path)

                        # and fill plugin contents in --> self.__plugins
                        self.__plugins[instance] = []
                        for tupl, properties in Entry.definitions.items():
                            typ, methodName = tupl

                            # define the callback (which go thru
                            # self.__caller) -> callback
                            method = getattr(instance, methodName)
                            callback = self.__caller(method, instance)

                            # correct dict of properties -> properties
                            for key, val in properties.items():
                                # make absolute path for icon
                                if key == "icon":
                                    properties[key] = val and \
                                        os.path.join(instance.path, val) or \
                                        None

                            self.__plugins[instance].append(
                                (typ, callback, properties))

                    except:
                        self.__plugError("in creation of '%s'" % (id, ))
                    finally:
                        __builtins__["_"] = old
                        pass
Beispiel #2
0
        def fillPluginsFrom(folder):
            """ good old plugins importer """
            for id in os.listdir(folder):
                path = folder + "/" + id
                if id[0] != "." and os.path.isdir(path):
                    namespace = path.replace("/", ".")

                    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- to be run from here ;-)
                    namespace = re.sub("\.\.+", "", namespace)
                    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- manatlan

                    old = __builtins__["_"]   # save the jbrout _()
                    try:
                        _trans = createGetText("plugin",
                                               os.path.join(path, "po"))

                        __builtins__["_"] = _trans

                        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- reset the Entry def
                        Entry.definitions = {}
                        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

                        # import the module plugin
                        module = __import__(namespace, [_], [_], ["Plugin"])

                        # create the _() for __init__ plugins
                        module.__dict__["_"] = _trans

                        # create an instance
                        instance = module.Plugin(id, path)

                        # and fill plugin contents in --> self.__plugins
                        self.__plugins[instance] = []
                        for tupl, properties in Entry.definitions.items():
                            typ, methodName = tupl

                            # define the callback (which go thru
                            # self.__caller) -> callback
                            method = getattr(instance, methodName)
                            callback = self.__caller(method, instance)

                            # correct dict of properties -> properties
                            for key, val in properties.items():
                                # make absolute path for icon
                                if key == "icon":
                                    properties[key] = val and \
                                        os.path.join(instance.path, val) or \
                                        None

                            self.__plugins[instance].append(
                                (typ, callback, properties))

                    except:
                        self.__plugError("in creation of '%s'" % (id,))
                    finally:
                        __builtins__["_"] = old
                        pass
Beispiel #3
0
        def myCallBack(*a,**k):

            old=__builtins__["_"]   # save the jbrout _()
            try:
                # for the .glade files
                from libs.gladeapp import GladeApp
                GladeApp.bindtextdomain("plugin",os.path.join(instance.path, 'po'))

                # for the "_()" in "window gladeapp" code
                __builtins__["_"] = createGetText("plugin",os.path.join(instance.path,"po"))

                ret=callback(*a,**k)
            finally:
                __builtins__["_"] = old # restore the jbrout _()
                pass
            return ret
Beispiel #4
0
        def myCallBack(*a, **k):

            old = __builtins__["_"]  # save the jbrout _()
            try:
                # for the .glade files
                from libs.gladeapp import GladeApp
                GladeApp.bindtextdomain("plugin",
                                        os.path.join(instance.path, 'po'))

                # for the "_()" in "window gladeapp" code
                __builtins__["_"] = createGetText(
                    "plugin", os.path.join(instance.path, "po"))

                ret = callback(*a, **k)
            finally:
                __builtins__["_"] = old  # restore the jbrout _()
                pass
            return ret
Beispiel #5
0
            cls._saveAlbum(method, "order", order)
            cls._saveAlbum(method, "alter", alter)
            cls._saveAlbum(method, "key", key)
            return cls._saveAlbum(method, "label", lbl)
        return _m


try:
    from libs.i18n import createGetText
except:
    # run from here
    # so we mock the needed object/path
    sys.path.append("..")
    createGetText = lambda a, b: lambda x: x
    __builtins__.__dict__["_"] = createGetText("", "")
    runWith = lambda x: x

    class JPlugin:
        Entry = Entry

        def __init__(self, i, p):
            self.id = i
            self.path = p


class JPlugins:
    path = "plugins"
    outputFullError = True

    def __init__(self, homePath, conf):
Beispiel #6
0
        else:
            self.exifList.append([_('Can not open file!'), ''])

    def on_winViewExif_delete_event(self, widget, *args):
        self.quit(False)

    def on_button_close_clicked(self, widget, *args):
        self.quit(False)

    def on_selector_value_changed(self, *args):
        self.setPhoto(self.selector.getValue())


def main():
    win_viewExif = WinViewExif()

    win_viewExif.loop()

if __name__ == "__main__":
    from libs.i18n import createGetText

    # make translation available in the gui/gtk
    GladeApp.bindtextdomain("jbrout", os.path.join(os.path.dirname(__file__),
                            'po'))

    # make translation available in the code
    __builtins__.__dict__["_"] = createGetText(
        "jbrout", os.path.join(os.path.dirname(__file__), 'po'))

    main()
Beispiel #7
0
            cls._saveAlbum(method, "order", order)
            cls._saveAlbum(method, "alter", alter)
            cls._saveAlbum(method, "key", key)
            return cls._saveAlbum(method, "label", lbl)

        return _m


try:
    from libs.i18n import createGetText
except:
    # run from here
    # so we mock the needed object/path
    sys.path.append("..")
    createGetText = lambda a, b: lambda x: x
    __builtins__.__dict__["_"] = createGetText("", "")
    runWith = lambda x: x

    class JPlugin:
        Entry = Entry

        def __init__(self, i, p):
            self.id = i
            self.path = p


class JPlugins:
    path = "plugins"
    outputFullError = True

    def __init__(self, homePath, conf):