def add_node(self, node): """Adding node to node list if asList=True or putting item into Xbmc directory * @attention: broken, Raise exception if user has canceled progress """ if self.Progress.iscanceled(): raise Qerror(who=self, what="build_down_canceled") return False if self.asList: self.nodes.append(node) self.total_put += 1 return True return self.__add_node(node)
def add(self, **ka): '''Add menu entry Parameters: path: string, <section>/<id> (id juste need to be unique) cmd: string, xbmc command to run color: string, override default color pos: int, position in menu ''' for key in ['label', 'cmd']: if not key in ka: raise Qerror(who=self, what='missing_parameter', additional=key) section, path = self.get_section_path(**ka) root = self.data pos = 0 if 'pos' in ka: pos = ka['pos'] cmd = '' if 'cmd' in ka: cmd = ka['cmd'] color = '' if 'color' in ka: color = ka['color'] if not section in root: root[section] = { 'label': section, 'childs': [], 'pos': pos, 'cmd': cmd, 'color': color } if not path: root[section]['label'] = ka['label'] root[section]['cmd'] = cmd root[section]['pos'] = pos root[section]['color'] = color else: item = { 'label': ka['label'], 'cmd': cmd, 'pos': pos, 'color': color } root[section]['childs'].append(item) return root
def populating(self, Dir, lvl=1, whiteFlag=None, blackFlag=None, gData=None): if Dir.Progress.iscanceled(): return False if not gData: gData = {'count': 0, 'total': 100, 'startedOn': time()} if lvl != -1 and lvl < 1: return False Dir.update(gData, 'Fetching', '', '') if not (self.nt & blackFlag == self.nt): if not self.fetch(Dir, lvl, whiteFlag, blackFlag): return False else: self.__add_pagination(self.data) self.populate(Dir, lvl, whiteFlag, blackFlag) """ Recursive mode dont't decrement level """ if lvl != -1: lvl -= 1 label = self.get_label() gData['count'] = 0 gData['total'] = len(self.childs) self.__add_pagination_node(Dir, lvl, whiteFlag) Dir.update(gData, 'Working', label, '') for child in self.childs: if Dir.is_canceled(): return False """ Only white Flagged added to the listing """ if child.nt & whiteFlag == child.nt: if not Dir.add_node(child): warn(self, "Something went wrong... aborting") self.childs = [] raise Qerror(who=self, what='build_down_abort') gData['count'] += 1 Dir.update(gData, "Working", label, child.get_label()) else: log(self, "Skipping node: %s" % (Flag.to_s(child.nt))) """ Calling builiding down on child """ child.populating(Dir, lvl, whiteFlag, blackFlag, gData) return gData['count']
def gui_remove(self): qnt, qid = int(self.get_parameter('qnt')), self.get_parameter('qid') node = getNode(qnt, {'nid': qid}) ret = None if qnt & Flag.TRACK == Flag.TRACK: ret = self.del_track(node.nid) elif qnt & Flag.ALBUM == Flag.ALBUM: ret = self.del_album(node.nid) elif qnt & Flag.ARTIST == Flag.ARTIST: ret = self.del_artist(node.nid) else: raise Qerror(who=self, what='invalid_node_type', additional=self.nt) if not ret: notifyH(dialogHeading, 'Cannot remove item: %s' % (node.get_label())) return False notifyH(dialogHeading, 'Item successfully removed: %s' % (node.get_label())) url = self.make_url(nt=self.nt, nid='', nm='') executeBuiltin(containerUpdate(url, True)) return True
def content_type(self, kind): if kind not in ['songs', 'albums', 'files', 'artists']: raise Qerror(who=self, what='invalid_type', additional=kind) self._content_type = kind