Given a category name, find a forum by name. Create the category and forum either doesn't exist.
182041
def find_or_create_forum(category_name, forum_name, options={ })
      category = self.find_or_create_category(category_name, options)
      if category
        self.forums.detect { |f| f['category_id'] == category['id'] && f['name'] == forum_name } || post_forum(category['id'], forum_name)
      end
    end
1061377
def network_exists(project_id, network_name,**kwargs):
    
    try:
        db.DBSession.query(Network.id).filter(func.lower(Network.name).like(network_name.lower()), Network.project_id == project_id).one()
        return 'Y'
    except NoResultFound:
        return 'N'
1346020
def add_category
      category_name = self.name.to_s.split('.').first
      # if one word then add to general category
      category_name = self.name.to_s.split('.').size == 1 ? 'general' : self.name.to_s.split('.').first
      self.category = TranslationCenter::Category.where(name: category_name).first_or_create
      self.last_accessed = Time.now
    end
385536
def forum_create_topic(self, subject, author, message, tags=""):
        """"""

        params = {'subject': subject, 'author': author, 'message': message, 'tags': tags}

        return self._request('ebuio/forum/', postParams=params, verb='POST')
1070196
public static function missing(string $category, $message, string $language)
    {
        return new static(static::MISSING, $category, $message, $language);
    }
1053972
def get(self, request, pk):
        
        self.forum = get_object_or_404(Forum, pk=pk)
        return super().get(request, pk)
835680
def absent(name, **connection_args):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': ''}

    #check if db exists and remove it
    if __salt__['mysql.db_exists'](name, **connection_args):
        if __opts__['test']:
            ret['result'] = None
            ret['comment'] = \
                'Database {0} is present and needs to be removed'.format(name)
            return ret
        if __salt__['mysql.db_remove'](name, **connection_args):
            ret['comment'] = 'Database {0} has been removed'.format(name)
            ret['changes'][name] = 'Absent'
            return ret
        else:
            err = _get_mysql_error()
            if err is not None:
                ret['comment'] = 'Unable to remove database {0} ' \
                                 '({1})'.format(name, err)
                ret['result'] = False
                return ret
    else:
        err = _get_mysql_error()
        if err is not None:
            ret['comment'] = err
            ret['result'] = False
            return ret

    # fallback
    ret['comment'] = ('Database {0} is not present, so it cannot be removed'
            ).format(name)
    return ret
849671
def clean(self):
        
        super().clean()

        if self.parent and self.parent.is_link:
            raise ValidationError(_('A forum can not have a link forum as parent'))

        if self.is_category and self.parent and self.parent.is_category:
            raise ValidationError(_('A category can not have another category as parent'))

        if self.is_link and not self.link:
            raise ValidationError(_('A link forum must have a link associated with it'))
570794
def find_in_registry(category = None, namespace = None, name = None):
    
    selected_registry = registry
    if category is not None:
        selected_registry = [re for re in selected_registry if re.category==category]
    if namespace is not None:
        selected_registry = [re for re in selected_registry if re.namespace==namespace]
    if name is not None:
        selected_registry = [re for re in selected_registry if re.name==name]
    if len(selected_registry)>0:
        return [sr.cls for sr in selected_registry]

    return None
905747
function(category, name, desc) {

            if(used[name]) return;
            used[name]= 1;

            if(!items[category]) items[category] = [];
            
           items[category].push({
               name: name,
               desc: desc
           });
        }
1272604
def get(self, *args, **kwargs):
        """"""
        self.initial = {"category_name":  kwargs.get('category_name', None)}
        return super(CategoryFormView, self).get(*args, **kwargs)
888662
def exists_dimension(dimension_name,**kwargs):
    
    try:
        dimension = db.DBSession.query(Dimension).filter(Dimension.name==dimension_name).one()
        # At this point the dimension exists
        return True
    except NoResultFound:
        # The dimension does not exist
        raise False
894134
public static String getKey(String category, String name)
    {
        if(category != null && name != null)
            return category+":"+name;
        return null;
    }
348124
def get_object(self, *args, **kwargs):
        
        self.category_instance = get_object_or_404(Category, slug=self.kwargs['category_slug'])
        return get_object_or_404(Post, thread__id=self.kwargs['thread_id'], thread__category=self.category_instance, pk=self.kwargs['post_id'])
82713
public static function isExistByNameCategoryId( $name, $categoryId ) {

		$option = self::findByNameCategoryId( $name, $categoryId );

		return isset( $option );
	}
566580
def absent(name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}

    exists = __salt__['boto_elb.exists'](name, region, key, keyid, profile)
    if exists:
        if __opts__['test']:
            ret['comment'] = 'ELB {0} is set to be removed.'.format(name)
            ret['result'] = None
            return ret
        deleted = __salt__['boto_elb.delete'](name, region, key, keyid,
                                              profile)
        if deleted:
            ret['changes']['old'] = {'elb': name}
            ret['changes']['new'] = {'elb': None}
            ret['comment'] = 'ELB {0} deleted.'.format(name)
        else:
            ret['result'] = False
            ret['comment'] = 'Failed to delete {0} ELB.'.format(name)
    else:
        ret['comment'] = '{0} ELB does not exist.'.format(name)
    return ret
1320364
def get_activity_by_name(self, activity, category_id = None, resurrect = True):
        
        category_id = category_id or 0
        return self.conn.GetActivityByName(activity, category_id, resurrect)