當前位置: 首頁>>代碼示例>>Python>>正文


Python model.FModel類代碼示例

本文整理匯總了Python中foobnix.gui.model.FModel的典型用法代碼示例。如果您正苦於以下問題:Python FModel類的具體用法?Python FModel怎麽用?Python FModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FModel類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: simple_scanner

def simple_scanner(path, level):
    try:
        path = path.encode("utf-8")
    except:
        pass

    results = []
    if not os.path.exists(path):
        return
    dir = os.path.abspath(path)

    list = sort_by_name(path, os.listdir(dir))

    for file in list:
        full_path = os.path.join(path, file)

        if os.path.isfile(full_path):
            if file_extension(file) not in FC().all_support_formats:
                continue;

        if os.path.isdir(full_path):
            if is_dir_with_music(full_path):
                b_bean = FModel(file, full_path).add_parent(level).add_is_file(False)
                results.append(b_bean)
                results.extend(simple_scanner(full_path, b_bean.get_level()))
        elif os.path.isfile(full_path):
            results.append(FModel(file, full_path).add_parent(level).add_is_file(True))

    return results
開發者ID:zavlab1,項目名稱:foobnix,代碼行數:29,代碼來源:music_service.py

示例2: task

                def task(user):
                    logging.debug(user)
                    name = user['first_name'] + " " + user['last_name']

                    parent = FModel(name)
                    parent.user_id = user['uid']
                    bean = FDModel(_("loading...")).parent(parent).add_is_file(True)
                    self.append(parent)
                    self.append(bean)
開發者ID:foobnix,項目名稱:foobnix,代碼行數:9,代碼來源:vk_integration_tree.py

示例3: auto_add_user_station

    def auto_add_user_station(self):
        if os.path.isfile(CACHE_RADIO_FILE) and os.path.getsize(CACHE_RADIO_FILE) > 0:
            with open(CACHE_RADIO_FILE, 'r') as f:
                list = f.readlines()
                parent_level_for_depth = {}
                previous = {"bean": None, "depth": 0, "name": '', "url": ''}
                for line in list:
                    depth = self.simbol_counter(line, '-')
                    try:
                        name = line[depth : line.index('#')]
                    except ValueError, e:
                        logging.warning('\'#\' ' + str(e) + ' in line \"' + line + '\"')
                        continue
                    url = line[line.index('#') + 1 : -1]
                    bean = FModel(name)
                    if url:
                        bean.add_is_file(True).add_path(url).add_type(FTYPE_RADIO)
                    if previous["depth"] < depth:
                        bean.add_parent(previous["bean"].level)
                    elif previous["depth"] > depth:
                        bean.add_parent(parent_level_for_depth[depth])
                    else:
                        if previous["bean"]:
                            bean.add_parent(previous["bean"].parent_level)

                    self.append(bean)
                    parent_level_for_depth[depth] = bean.parent_level
                    previous = {"bean": bean, "depth": depth, "name": name, "url": url}
開發者ID:Andresteve07,項目名稱:foobnix,代碼行數:28,代碼來源:radio_tree.py

示例4: create_playlist

 def create_playlist(self):
     name = one_line_dialog(_("Create new playlist"), self.controls.main_window, message_text1=_("Enter playlist name"))
     if not name:
         return
     bean = self.get_selected_bean()
     folder_bean = FModel(name)
     if bean:
         if bean.is_file:
             folder_bean.add_parent(bean.parent_level)
         else:
             folder_bean.add_parent(bean.level)
     self.append(folder_bean)
開發者ID:zablotski,項目名稱:foobnix,代碼行數:12,代碼來源:virtual_tree.py

示例5: create_folder

 def create_folder(self, a):
     model, tree_path, row = a # @UnusedVariable
     file_path = row[self.path[0]]
     new_folder_path = create_folder_dialog(file_path)
     bean = FModel(os.path.basename(new_folder_path), new_folder_path).add_is_file(False)
     if os.path.isfile(file_path):
         bean.add_parent(row[self.parent_level[0]])
     elif os.path.isdir(file_path):
         bean.add_parent(row[self.level[0]])
     else:
         logging.error("So path doesn't exist")
     self.tree_append(bean)
     self.save_tree()
開發者ID:strogo,項目名稱:foobnix,代碼行數:13,代碼來源:navigation_tree.py

示例6: on_add_station

 def on_add_station(self):
     name, url = two_line_dialog(_("Add New Radio Station"),
                                 parent = self.controls.main_window,
                                 message_text1 = _("Enter station name and URL"),
                                 message_text2 = None,
                                 entry_text1 = None,
                                 entry_text2 = "http://")
     if not name or not url:
         return
     bean = self.get_selected_bean()
     new_bean = FModel(name, url).add_type(FTYPE_RADIO).add_is_file(True)
     if bean:
         if bean.is_file:
             new_bean.add_parent(bean.parent_level)
         else:
             new_bean.add_parent(bean.level)
     self.append(new_bean)
開發者ID:Andresteve07,項目名稱:foobnix,代碼行數:17,代碼來源:radio_tree.py

示例7: find_tracks_by_url

    def find_tracks_by_url(self, url):
        logging.debug("Search By URL")

        index = url.rfind("#")
        if index > 0:
            url = url[:index]
        index = url.find("id=")
        if index < 0:
            return None

        id = url[index + 3:]
        id = int(id)
        if id > 0:
            results = self.get_result('audio.get', "uid=" + str(id))
        else:
            results = self.get_result('audio.get', "gid=" + str(abs(id)))

        childs = []
        for line in results:
            bean = FModel(line['artist'] + ' - ' + line['title'])
            bean.aritst = line['artist']
            bean.title = line['title']
            bean.time = convert_seconds_to_text(line['duration'])
            bean.path = line['url'].replace("https://", "http://")
            bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
            childs.append(bean)

        return childs
開發者ID:Cgruppo,項目名稱:foobnix,代碼行數:28,代碼來源:vk_service.py

示例8: get_user_tracks_as_beans

 def get_user_tracks_as_beans(self, user_id):
     beans = []
     result = self.controls.vk_service.get_result('audio.get', "uid=" + user_id)
     if not result:
         beans = [FDModel(_("No results found")).add_is_file(True)]
     else:
         for line in result:
             bean = FModel(line['artist'] + ' - ' + line['title'])
             bean.aritst = line['artist']
             bean.title = line['title']
             bean.time = convert_seconds_to_text(line['duration'])
             bean.path = line['url']
             bean.aid = line['aid']
             bean.oid = line['owner_id']
             bean.is_file = True
             bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
             beans.append(bean)
     return beans
開發者ID:foobnix,項目名稱:foobnix,代碼行數:18,代碼來源:vk_integration_tree.py

示例9: find_track_by_id

 def find_track_by_id(self, id):
     result = self.get_result("audio.get", "audios=" + str(id))
     if not result:
         return None
     line = result[0]
     bean = FModel(line['artist'] + ' - ' + line['title'])
     bean.aritst = line['artist']
     bean.title = line['title']
     bean.time = convert_seconds_to_text(line['duration'])
     bean.path = line['url']
     bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
     return bean
開發者ID:Andresteve07,項目名稱:foobnix,代碼行數:12,代碼來源:vk_service.py

示例10: find_track_by_id

 def find_track_by_id(self, id):
     if id is not None:
         parts = id.split("_")
         result = self.get_result("audio.get", "owner_id=%s&audio_ids=%s" % (str(parts[0]), str(parts[1])))
         line = result[1]
     else:
         result = self.get_result("audio.get", "audios=" + str(id))
         line = result[0]
     if not result:
         return None
     bean = FModel(line['artist'] + ' - ' + line['title'])
     bean.aritst = line['artist']
     bean.title = line['title']
     bean.time = convert_seconds_to_text(line['duration'])
     bean.path = line['url'].replace("https://", "http://")
     bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
     return bean
開發者ID:Cgruppo,項目名稱:foobnix,代碼行數:17,代碼來源:vk_service.py

示例11: find_tracks_by_query

    def find_tracks_by_query(self, query):
        logging.info("start search songs " + query)
        query = urllib.quote(query.encode("utf-8"))

        list = self.get_result("audio.search", "q=" + query)
        childs = []

        if not list:
            return childs

        for line in list[1:]:
            bean = FModel(line['artist'] + ' - ' + line['title'])
            bean.aritst = line['artist']
            bean.title = line['title']
            bean.time = convert_seconds_to_text(line['duration'])
            bean.path = line['url'].replace("https://", "http://")
            bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
            childs.append(bean)

        return childs
開發者ID:Cgruppo,項目名稱:foobnix,代碼行數:20,代碼來源:vk_service.py

示例12: get_common_beans

    def get_common_beans(self):
        beans = []
        cue = self.parse()
        if not self.is_cue_valid():
            return []
        for i, track  in enumerate(cue.tracks):
            bean = FModel(text=track.performer + " - " + track.title, path=track.path)
            bean.artist = track.performer
            bean.tracknumber = i + 1
            bean.title = track.title
            bean.album = self.cue_file.title
            bean.name = bean.text
            bean.start_sec = track.get_start_time_sec()
            bean.duration_sec = track.duration
            bean.time = convert_seconds_to_text(track.duration)
            bean.is_file = True
            try:
                bean.info = foobnix.util.id3_util.normalized_info(get_mutagen_audio(track.path).info, bean)
            except Exception, e:
                logging.warn(str(e) + " " + bean.path)
                bean.info = ""

            if not bean.title or not bean.artist:
                bean = udpate_id3(bean)

            beans.append(bean)
開發者ID:Andresteve07,項目名稱:foobnix,代碼行數:26,代碼來源:cue_reader.py


注:本文中的foobnix.gui.model.FModel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。