Writes grade_categories
189980
protected function write_grade_categories() {

        $this->xmlwriter->begin_tag('grade_categories');
        foreach ($this->converter->get_stash_itemids('gradebook_gradecategory') as $gradecategoryid) {
            $gradecategory = $this->converter->get_stash('gradebook_gradecategory', $gradecategoryid);
            $path = $this->calculate_category_path($gradecategoryid);
            $gradecategory['depth'] = count($path);
            $gradecategory['path']  = '/'.implode('/', $path).'/';
            $this->write_xml('grade_category', $gradecategory, array('/grade_category/id'));
        }
        $this->xmlwriter->end_tag('grade_categories');
    }
1116102
private function categories()
    {
        $package = Package::where('name', 'Core')->first();
        $core = ConfigCategory::create([
            'key' => 'core',
            'package_id' => $package->id
        ]);
        ConfigCategory::create([
            'key' => 'core_mail',
            'parent_id' => $core->id,
            'package_id' => $core->package_id
        ]);
        ConfigCategory::create([
            'key' => 'core_general',
            'parent_id' => $core->id,
            'package_id' => $core->package_id
        ]);
        $this->general();
        $this->mail();
    }
340275
public static final String formatCategoryMap(Map<String, Integer> categories) {

        StringBuffer result = new StringBuffer(256);
        result.append("Total categories: ");
        result.append(categories.size());
        result.append('\n');
        Iterator<Map.Entry<String, Integer>> i = categories.entrySet().iterator();
        while (i.hasNext()) {
            Map.Entry<String, Integer> entry = i.next();
            result.append(CmsStringUtil.padRight(entry.getKey(), 30));
            result.append(entry.getValue().intValue());
            result.append('\n');
        }
        return result.toString();
    }
649960
protected function setDataCategoriesEditCategory()
    {
        $category_id = $this->getData('category.category_id');

        if (isset($category_id)) {

            $category_group_id = $this->getData('category_group.category_group_id');

            $options = array(
                'parent_id' => $category_id,
                'category_group_id' => $category_group_id
            );

            $children = $this->category->getTree($options);

            $exclude = array($category_id);
            foreach ($children as $child) {
                $exclude[] = $child['category_id'];
            }

            $categories = $this->getData('categories');
            $modified = array_diff_key($categories, array_flip($exclude));
            $this->setData('categories', $modified);
        }
    }
1074536
public function actionJsoncategories()
    {
        header('Content-type: application/json');
        $out = [];
        if(isset($_POST['depdrop_parents']))
        {
            $parents = $_POST['depdrop_parents'];
            if($parents != null)
            {
                $mod_table = $parents[0];
                $out = Categories::jsCategories($mod_table);
                echo Json::encode(['output'=>$out,'selected'=>'']);
                return;
            }
        }
        echo Json::encode(['output'=>'','selected'=>'']);
        exit;
    }
660742
public function onAfterWrite()
    {
        parent::onAfterWrite();

        // Write the parent's type to the current term
        if ($this->Parent()->exists() && $this->Parent()->Type()->exists()) {
            $this->TypeID = $this->Parent()->Type()->ID;
        }

        // Write the current term's type to all children
        foreach ($this->Children() as $term) {
            /** @var TaxonomyTerm $term */
            $term->TypeID = $this->Type()->ID;
            $term->write();
        }
    }
901099
public function cmdUpdateCategory()
    {
        $params = $this->getParam();

        if (empty($params[0]) || count($params) < 2) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        if (!is_numeric($params[0])) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        $this->setSubmitted(null, $params);
        $this->setSubmitted('update', $params[0]);
        $this->validateComponent('category');

        $this->updateCategory($params[0]);
        $this->output();
    }
380009
def draw_categories(self):
        """"""
        for label in self._category_labels.values():
            label.destroy()
        self._category_labels.clear()
        canvas_width = 0
        for category in (sorted(self._categories.keys() if isinstance(self._categories, dict) else self._categories)
                         if not isinstance(self._categories, OrderedDict)
                         else self._categories):
            kwargs = self._categories[category] if isinstance(self._categories, dict) else {"text": category}
            kwargs["background"] = kwargs.get("background", self._background)
            kwargs["justify"] = kwargs.get("justify", tk.LEFT)
            label = ttk.Label(self._frame_categories, **kwargs)
            width = label.winfo_reqwidth()
            canvas_width = width if width > canvas_width else canvas_width
            self._category_labels[category] = label
        self._canvas_categories.create_window(0, 0, window=self._frame_categories, anchor=tk.NW)
        self._canvas_categories.config(width=canvas_width + 5, height=self._height)
1319983
def use_all_categories(self):
		'''
		
		'''
		term_df = self.term_ranker.get_ranks()
		self.priors += term_df.sum(axis=1).fillna(0.)
		return self
49204
def _category_slugs(self, category):
        """"""
        key = self._category_key(category)
        slugs = self.r.smembers(key)
        return slugs
910097
public void addCategory(String category) throws JSONException {
		logger.debug("Adding category [" + category + "]");
		put("category", category, this.apsDictionary, true);
	}
737524
def _folder_item_category(self, analysis_brain, item):
        
        if not self.show_categories:
            return

        cat = analysis_brain.getCategoryTitle
        item["category"] = cat
        cat_order = self.analysis_categories_order.get(cat)
        if (cat, cat_order) not in self.categories:
            self.categories.append((cat, cat_order))
116021
def _to_add_with_category(self, catid):
        '''
        
        '''

        catinfo = MCategory.get_by_uid(catid)
        kwd = {
            'uid': self._gen_uid(),
            'userid': self.userinfo.user_name if self.userinfo else '',
            'gcat0': catid,
            'parentname': MCategory.get_by_uid(catinfo.pid).name,
            'catname': MCategory.get_by_uid(catid).name,
        }

        self.render('autogen/add/add_{0}.html'.format(catid),
                    userinfo=self.userinfo,
                    kwd=kwd)
642998
public function on_question_category_end() {
        // make sure that the category data were written by {@link self::process_question()}
        // if not, write it now. this may happen when the current category does not contain any
        // questions so the subpaths is missing completely
        if (empty($this->currentcategorywritten)) {
            $this->write_xml('question_category', $this->currentcategory, array('/question_category/id'));
        } else {
            $this->xmlwriter->end_tag('question_category');
        }
        $this->converter->set_stash('question_categories', $this->currentcategory, $this->currentcategory['id']);
    }
554955
def write(self, output_io):
        ''''''
        for name, tax in self.taxonomy.items():
            output_io.write("%s\t%s\n" % (name, '; '.join(tax)))
786767
public void setCategories(int i, String v) { 
    if (GOMention_Type.featOkTst && ((GOMention_Type)jcasType).casFeat_categories == null)
      jcasType.jcas.throwFeatMissing("categories", "de.julielab.jules.types.GOMention");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((GOMention_Type)jcasType).casFeatCode_categories), i);
    jcasType.ll_cas.ll_setStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((GOMention_Type)jcasType).casFeatCode_categories), i, v);}
1029965
def render_category_averages(obj, normalize_to=100):
    """"""
    context = {'reviewed_item': obj}
    ctype = ContentType.objects.get_for_model(obj)
    reviews = models.Review.objects.filter(
        content_type=ctype, object_id=obj.id)
    category_averages = {}
    for review in reviews:
        review_category_averages = review.get_category_averages(normalize_to)
        if review_category_averages:
            for category, average in review_category_averages.items():
                if category not in category_averages:
                    category_averages[category] = review_category_averages[
                        category]
                else:
                    category_averages[category] += review_category_averages[
                        category]
    if reviews and category_averages:
        for category, average in category_averages.items():
            category_averages[category] = \
                category_averages[category] / models.Rating.objects.filter(
                    category=category, value__isnull=False,
                    review__content_type=ctype,
                    review__object_id=obj.id).exclude(value='').count()
    else:
        category_averages = {}
        for category in models.RatingCategory.objects.filter(
                counts_for_average=True):
            category_averages[category] = 0.0
    context.update({'category_averages': category_averages})
    return context