示例#1
0
文件: Module.py 项目: arsfeld/conduit
    def load_all(self, whitelist, blacklist):
        """
        Loads all classes in the configured paths.

        If whitelist and blacklist are supplied then the name of the file
        is tested against them. Default policy is to load all modules unless
        """
        for f in self.filelist:
            name, ext = Vfs.uri_get_filename_and_extension(f)
            if whitelist:
                if name in whitelist:
                    self._load_modules_in_file(f)
            elif blacklist:
                if name not in blacklist: 
                    self._load_modules_in_file(f)
            else:            
                self._load_modules_in_file(f)

        for i in self.dataproviderFactories:
            i.connect("dataprovider-removed", self._on_dynamic_dataprovider_removed)
            i.connect("dataprovider-added", self._on_dynamic_dataprovider_added)
            i.probe()

        self.emit('all-modules-loaded')
示例#2
0
for impl in ("GIO", "GnomeVfs",):
    conduit.FILE_IMPL = impl
    reload(Vfs)
    reload(Utils)

    ok("--- TESTING VFS WITH FILE IMPL: %s" % impl, True)
    #print Vfs.FolderScanner

    safe = '/&=:@'
    unsafe = ' !<>#%()[]{}'
    safeunsafe = '%20%21%3C%3E%23%25%28%29%5B%5D%7B%7D'

    ok("Dont escape path characters",Vfs.uri_escape(safe+unsafe) == safe+safeunsafe)
    ok("Unescape back to original",Vfs.uri_unescape(safe+safeunsafe) == safe+unsafe)
    ok("Get protocol", Vfs.uri_get_protocol("file:///foo/bar") == "file://")
    name, ext = Vfs.uri_get_filename_and_extension("file:///foo/bar.ext")
    ok("Get filename (%s,%s)" % (name,ext), name == "bar" and ext == ".ext")
    ok("file:///home exists", Vfs.uri_exists("file:///home") == True)
    ok("/home exists", Vfs.uri_exists("/home") == True)
    ok("/home is folder", Vfs.uri_is_folder("/home") == True)
    ok("/foo/bar does not exist", Vfs.uri_exists("/foo/bar") == False)
    ok("format uri", Vfs.uri_format_for_display("file:///foo") == "/foo")

    tmpdiruri = Utils.new_tempdir()

    # Test the folder scanner theading stuff
    fileuri = Utils.new_tempfile("bla").get_local_uri()
    stm = Vfs.FolderScannerThreadManager(maxConcurrentThreads=1)

    def prog(*args): pass
    def done(*args): pass