Index: channels/_generic.py ================================================================== --- channels/_generic.py +++ channels/_generic.py @@ -56,10 +56,11 @@ config = [] has_search = False # categories categories = ["empty", ] + catmap = {} current = "" default = "empty" shown = None # last selected entry in stream list, also indicator if notebook tab has been selected once / stream list of current category been displayed yet # gui + data @@ -131,10 +132,14 @@ self.streams = cache # categories cache = conf.load("cache/categories_" + self.module) if (cache): self.categories = cache + # catmap (optional) + cache = conf.load("cache/catmap_" + self.module) + if (cache): + self.catmap = cache pass # initialize Gtk widgets / data objects def gui(self, parent): @@ -374,11 +379,14 @@ # update categories, save, and display def reload_categories(self): # get data and save self.update_categories() - conf.save("cache/categories_"+self.module, self.categories) + if self.categories: + conf.save("cache/categories_"+self.module, self.categories) + if self.catmap: + conf.save("cache/catmap_" + self.module, self.catmap); # display outside of this non-main thread mygtk.do(self.display_categories) # insert content into gtk category list @@ -462,10 +470,15 @@ return xml.sax.saxutils.unescape(s) # convert special characters to &xx; escapes def xmlentities(self, s): return xml.sax.saxutils.escape(s) + + # Extracts integer from string + def to_int(self, s): + i = re.findall("\d+", s) or [0] + return int(i[0])