Return or change the karma value for some(one|thing)
504795
def karma(nick, rest):
	""
	karmee = rest.strip('++').strip('--').strip('~~')
	if '++' in rest:
		Karma.store.change(karmee, 1)
	elif '--' in rest:
		Karma.store.change(karmee, -1)
	elif '~~' in rest:
		change = random.choice([-1, 0, 1])
		Karma.store.change(karmee, change)
		if change == 1:
			return "%s karma++" % karmee
		elif change == 0:
			return "%s karma shall remain the same" % karmee
		elif change == -1:
			return "%s karma--" % karmee
	elif '==' in rest:
		t1, t2 = rest.split('==')
		try:
			Karma.store.link(t1, t2)
		except SameName:
			Karma.store.change(nick, -1)
			return "Don't try to link a name to itself!"
		except AlreadyLinked:
			return "Those names were previously linked."
		score = Karma.store.lookup(t1)
		return "%s and %s are now linked and have a score of %s" % (t1, t2, score)
	else:
		karmee = rest or nick
		score = Karma.store.lookup(karmee)
		return "%s has %s karmas" % (karmee, score)
287526
def emer_comp(rest):
	""
	comps = util.load_emergency_compliments()
	compliment = random.choice(comps)
	if rest:
		complimentee = rest.strip()
		karma.Karma.store.change(complimentee, 1)
		return "%s: %s" % (complimentee, compliment)
	return compliment
775442
def get_and_save_value(self, name, default=None):
        """"""
        if getattr(self, name, None):
            return getattr(self, name)

        value = self.get_session_value(name, default)
        value = self.request.POST.get(name, value)
        self.save_value(name, value)
        return value
438268
def ones_like(self, name, data, **kwargs):
        """"""
        return self._write_op(self._ones_like_nosync, name, data, **kwargs)
302176
def coerce(self, value):
        """"""
        if self._coerce is not None:
            value = self._coerce(value)
        return value
1155085
function setReturnUrl() {
    return function(req, res, next) {
        if( req.session ) {
            req.session.returnTo = req.originalUrl || req.url;
        }
    };
}
4244
def override(self, value):
        """"""
        if self._value is not value:
            return _ScopedValueOverrideContext(self, value)
        else:
            return empty_context
120149
def coerce(cls, key, value):
        """"""
        if not isinstance(value, MutationList):
            if isinstance(value, list):
                return MutationList(value)

            # this call will raise ValueError
            return Mutable.coerce(key, value)
        else:
            return value
701522
def ne_(self, value):
        ''' 
        '''
        if isinstance(value, QueryField):
            return self.__cached_id != value.__cached_id
        return self.__comparator('$ne', value)
11490
def use_value(self, value):
        """"""
        if self.check_value(value):
            return value
        return self.convert_value(value)
728188
def coerce(self, value, **kwargs):
        """"""

        if value is None:
            return None
        return self._coercion.coerce(value, **kwargs)
878605
def toggle_value(request, name):
    
    obj = service.system.namespace.get(name, None)
    if not obj or service.read_only:
        raise Http404
    new_status = obj.status = not obj.status
    if service.redirect_from_setters:
        return HttpResponseRedirect(reverse('set_ready', args=(name, new_status)))
    else:
        return set_ready(request, name, new_status)
506655
def choose_one(things):
    """"""
    choice = SystemRandom().randint(0, len(things) - 1)
    return things[choice].strip()
5017
def _GetValue(self, name):
    """"""
    for value in self.values:
      if value.name == name:
        return value
1187595
def use(self, key, value):
        
        old_value = self[key]
        try:
            self[key] = value
            yield self
        finally:
            self[key] = old_value
910161
def fix_return_value(v, method_name, method=None, checker=None):
    
    # remove common check prefix
    method_name = (method_name or method.__func__.__name__).replace("check_","")
    if v is None or not isinstance(v, Result):
        v = Result(value=v, name=method_name)

    v.name         = v.name or method_name

    v.checker      = checker
    v.check_method = method

    return v
400208
def _maybe_update(self, user, attribute, new_value):
        
        old_value = getattr(user, attribute)
        if new_value != old_value:
            self.stderr.write(
                _('Setting {attribute} for user "{username}" to "{new_value}"').format(
                    attribute=attribute, username=user.username, new_value=new_value
                )
            )
            setattr(user, attribute, new_value)