Esempio n. 1
0
 def testExtractUris(self):
     uri_list_text = "# urn:isbn:0-201-08372-8\n" + \
                     "http://www.huh.org/books/foo.html\n" + \
                     "http://www.huh.org/books/foo.pdf\n" + \
                     "ftp://ftp.foo.org/books/foo.txt\n"
     uri_list = glib.uri_list_extract_uris(uri_list_text)
     assert uri_list[0] == "http://www.huh.org/books/foo.html"
     assert uri_list[1] == "http://www.huh.org/books/foo.pdf"
     assert uri_list[2] == "ftp://ftp.foo.org/books/foo.txt"
Esempio n. 2
0
 def testExtractUris(self):
     uri_list_text = "# urn:isbn:0-201-08372-8\n" + \
                     "http://www.huh.org/books/foo.html\n" + \
                     "http://www.huh.org/books/foo.pdf\n" + \
                     "ftp://ftp.foo.org/books/foo.txt\n"
     uri_list = glib.uri_list_extract_uris(uri_list_text)
     assert uri_list[0] == "http://www.huh.org/books/foo.html"
     assert uri_list[1] == "http://www.huh.org/books/foo.pdf"
     assert uri_list[2] == "ftp://ftp.foo.org/books/foo.txt"
    def widget_drag_data_received_event(self, w, context, x, y, data, info, time, type_check):
        if not data:
            return False
        if data.get_length() < 0:
            return False

        if (info == DRAG_INFO_0 or
            info == DRAG_INFO_1 or 
            info == DRAG_INFO_2):
            try:
                files = glib.uri_list_extract_uris(str(data.data).strip())
            except:
                files = str(data.data).split("\n")[:-1]
            files_list = []
            paths_list = []
            ldmp_list  = []
            for file in files:
                if len(file) > 0:
                    file = urllib.unquote(file)
                    # 转换字符格式.
                    if file.startswith("file:///"):
                        file = file[7:]
                    else:
                        file = file.decode("unicode-escape")
                    # 判断这个目录是否存在.
                    if os.path.exists(file):
                        # 判断是否为目录.
                        if os.path.isdir(file):
                            file = urllib.unquote(file)
                            path = file
                            paths_list.append(str(path))
                        else:
                            # 判断是字幕文件还是播放文件.
                            file = urllib.unquote(file)
                            files_list.append(str(file))
                    if file.endswith("ldmp"):
                        ldmp_list.append(file)
            # type: 是屏幕窗口还是播放列表.
            if files_list:
                self.this.files_to_play_list(files_list, type_check)
            if paths_list:
                self.this.dirs_to_play_list(paths_list, type_check)
            if ldmp_list:
                self.this.ldmp_to_play_list(ldmp_list, type_check)

        return True
Esempio n. 4
0
    def widget_drag_data_received_event(self, w, context, x, y, data, info,
                                        time, type_check):
        if not data:
            return False
        if data.get_length() < 0:
            return False

        if (info == DRAG_INFO_0 or info == DRAG_INFO_1 or info == DRAG_INFO_2):
            try:
                files = glib.uri_list_extract_uris(str(data.data).strip())
            except:
                files = str(data.data).split("\n")[:-1]
            files_list = []
            paths_list = []
            ldmp_list = []
            for file in files:
                if len(file) > 0:
                    file = urllib.unquote(file)
                    # 转换字符格式.
                    if file.startswith("file:///"):
                        file = file[7:]
                    else:
                        file = file.decode("unicode-escape")
                    # 判断这个目录是否存在.
                    if os.path.exists(file):
                        # 判断是否为目录.
                        if os.path.isdir(file):
                            file = urllib.unquote(file)
                            path = file
                            paths_list.append(str(path))
                        else:
                            # 判断是字幕文件还是播放文件.
                            file = urllib.unquote(file)
                            files_list.append(str(file))
                    if file.endswith("ldmp"):
                        ldmp_list.append(file)
            # type: 是屏幕窗口还是播放列表.
            if files_list:
                self.this.files_to_play_list(files_list, type_check)
            if paths_list:
                self.this.dirs_to_play_list(paths_list, type_check)
            if ldmp_list:
                self.this.ldmp_to_play_list(ldmp_list, type_check)

        return True