当前位置: 首页>>代码示例>>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;未经允许,请勿转载。