Ejemplo n.º 1
0
    def update_custom_recipes(self, script_urn_map):
        script_ids = []
        for urn, title_script in iteritems(script_urn_map):
            id_ = int(urn[len('custom:'):])
            (title, script) = title_script
            script_ids.append((id_, title, script))

        update_custom_recipes(script_ids)
        self.custom_recipe_collection = get_custom_recipe_collection()
Ejemplo n.º 2
0
    def update_custom_recipes(self, script_urn_map):
        script_ids = []
        for urn, title_script in script_urn_map.iteritems():
            id_ = int(urn[len('custom:'):])
            (title, script) = title_script
            script_ids.append((id_, title, script))

        update_custom_recipes(script_ids)
        self.custom_recipe_collection = get_custom_recipe_collection()
Ejemplo n.º 3
0
    def do_refresh(self, restrict_to_urns=set([])):
        self.custom_recipe_collection = get_custom_recipe_collection()
        zf = P('builtin_recipes.zip', allow_user_override=False)

        def factory(cls, parent, *args):
            args = list(args)
            if cls is NewsItem:
                args.extend(
                    [self.default_icon, self.custom_icon, self.favicons, zf])
            args += [
                self.builtin_recipe_collection, self.custom_recipe_collection,
                self.scheduler_config, parent
            ]
            return cls(*args)

        def ok(urn):
            if restrict_to_urns is None:
                return False
            return not restrict_to_urns or urn in restrict_to_urns

        new_root = factory(NewsTreeItem, None)
        scheduled = factory(NewsCategory, new_root, _('Scheduled'))
        custom = factory(NewsCategory, new_root, _('Custom'))
        lang_map = {}
        self.all_urns = set([])
        self.showing_count = 0
        self.builtin_count = 0
        for x in self.custom_recipe_collection:
            urn = x.get('id')
            self.all_urns.add(urn)
            if ok(urn):
                factory(NewsItem, custom, urn, x.get('title'))
                self.showing_count += 1
        for x in self.builtin_recipe_collection:
            urn = x.get('id')
            self.all_urns.add(urn)
            if ok(urn):
                lang = x.get('language', 'und')
                if lang:
                    lang = lang.replace('-', '_')
                if lang not in lang_map:
                    lang_map[lang] = factory(NewsCategory, new_root, lang)
                factory(NewsItem, lang_map[lang], urn, x.get('title'))
                self.showing_count += 1
                self.builtin_count += 1
        for x in self.scheduler_config.iter_recipes():
            urn = x.get('id')
            if urn not in self.all_urns:
                self.scheduler_config.un_schedule_recipe(urn)
                continue
            if ok(urn):
                factory(NewsItem, scheduled, urn, x.get('title'))
        new_root.prune()
        new_root.sort()
        self.root = new_root
        self.reset()
Ejemplo n.º 4
0
    def do_refresh(self, restrict_to_urns=set([])):
        self.custom_recipe_collection = get_custom_recipe_collection()
        zf = P('builtin_recipes.zip', allow_user_override=False)

        def factory(cls, parent, *args):
            args = list(args)
            if cls is NewsItem:
                args.extend([self.default_icon, self.custom_icon,
                    self.favicons, zf])
            args += [self.builtin_recipe_collection,
                     self.custom_recipe_collection, self.scheduler_config,
                     parent]
            return cls(*args)

        def ok(urn):
            if restrict_to_urns is None:
                return False
            return not restrict_to_urns or urn in restrict_to_urns

        new_root = factory(NewsTreeItem, None)
        scheduled = factory(NewsCategory, new_root, _('Scheduled'))
        custom = factory(NewsCategory, new_root, _('Custom'))
        lang_map = {}
        self.all_urns = set([])
        self.showing_count = 0
        self.builtin_count = 0
        for x in self.custom_recipe_collection:
            urn = x.get('id')
            self.all_urns.add(urn)
            if ok(urn):
                factory(NewsItem, custom, urn, x.get('title'))
                self.showing_count += 1
        for x in self.builtin_recipe_collection:
            urn = x.get('id')
            self.all_urns.add(urn)
            if ok(urn):
                lang = x.get('language', 'und')
                if lang:
                    lang = lang.replace('-', '_')
                if lang not in lang_map:
                    lang_map[lang] = factory(NewsCategory, new_root, lang)
                factory(NewsItem, lang_map[lang], urn, x.get('title'))
                self.showing_count += 1
                self.builtin_count += 1
        for x in self.scheduler_config.iter_recipes():
            urn = x.get('id')
            if urn not in self.all_urns:
                self.scheduler_config.un_schedule_recipe(urn)
                continue
            if ok(urn):
                factory(NewsItem, scheduled, urn, x.get('title'))
        new_root.prune()
        new_root.sort()
        self.root = new_root
        self.reset()
Ejemplo n.º 5
0
 def remove_custom_recipes(self, urns):
     ids = [int(x[len('custom:'):]) for x in urns]
     for id_ in ids:
         remove_custom_recipe(id_)
     self.custom_recipe_collection = get_custom_recipe_collection()
Ejemplo n.º 6
0
 def add_custom_recipes(self, scriptmap):
     add_custom_recipes(scriptmap)
     self.custom_recipe_collection = get_custom_recipe_collection()
Ejemplo n.º 7
0
 def add_custom_recipe(self, title, script):
     add_custom_recipe(title, script)
     self.custom_recipe_collection = get_custom_recipe_collection()
Ejemplo n.º 8
0
 def update_custom_recipe(self, urn, title, script):
     id_ = int(urn[len('custom:'):])
     update_custom_recipe(id_, title, script)
     self.custom_recipe_collection = get_custom_recipe_collection()
Ejemplo n.º 9
0
 def remove_custom_recipes(self, urns):
     ids = [int(x[len('custom:'):]) for x in urns]
     for id_ in ids:
         remove_custom_recipe(id_)
     self.custom_recipe_collection = get_custom_recipe_collection()
Ejemplo n.º 10
0
 def add_custom_recipes(self, scriptmap):
     add_custom_recipes(scriptmap)
     self.custom_recipe_collection = get_custom_recipe_collection()
Ejemplo n.º 11
0
 def add_custom_recipe(self, title, script):
     add_custom_recipe(title, script)
     self.custom_recipe_collection = get_custom_recipe_collection()
Ejemplo n.º 12
0
 def update_custom_recipe(self, urn, title, script):
     id_ = int(urn[len('custom:'):])
     update_custom_recipe(id_, title, script)
     self.custom_recipe_collection = get_custom_recipe_collection()