コード例 #1
0
ファイル: FileConfiguration.py プロジェクト: arsfeld/conduit
    def _item_name_data_func(self, column, cell_renderer, tree_model, rowref):
        """
        If the user has set a descriptive name for the folder the display that,
        otherwise display the filename. 
        """
        path = self.model.get_path(rowref)
        uri = self.model[path][URI_IDX]

        if self.model[path][GROUP_NAME_IDX] != "":
            displayName = self.model[path][GROUP_NAME_IDX]
        else:
            displayName = Vfs.uri_format_for_display(uri)

        cell_renderer.set_property("text", displayName)
        cell_renderer.set_property("ellipsize", True)

        #Can not edit the group name of a file
        if self.model[path][TYPE_IDX] == FileDataProvider.TYPE_FILE:
            cell_renderer.set_property("editable", False)
        else:
            cell_renderer.set_property("editable", True)
コード例 #2
0
ファイル: TestCoreVfs.py プロジェクト: arsfeld/conduit
    #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

    t1 = stm.make_thread("file:///tmp", False, False, prog, done)
    t2 = stm.make_thread("file://"+tmpdiruri, False, False, prog, done)
    stm.join_all_threads()

    ok("Scanned /tmp ok - found %s" % fileuri, "file://"+fileuri in t1.get_uris())