Get a kitten, either from the db, or a new one.
328962
def get_random(self):
        
        num_kittens = self.count()
        new_cutoff = (num_kittens / (num_kittens + constants.KITTEN_FRESHNESS))
        if random.random() < new_cutoff:
            return self._rand_inst()
        else:
            return self.create_new()
627807
def cats(self, cats):
        """"""
        sources = []
        for cat in coerce_to_list(cats):
            sources.extend([entry for entry in cat._entries.values() if entry._container != 'catalog'])
        self.items = sources
793305
function (transfer, cb) {

		Transfer.findOrCreate(transfer.id, transfer)
	    .exec(function (err, foundTransfer){
	      if (err) return cb(err);
	      if (foundTransfer.lastStripeEvent > transfer.lastStripeEvent) return cb(null, foundTransfer);
	      if (foundTransfer.lastStripeEvent == transfer.lastStripeEvent) return Transfer.afterStripeTransferCreated(foundTransfer, function(err, transfer){ return cb(err, transfer)});
	      Transfer.update(foundTransfer.id, transfer)
	      .exec(function(err, updatedTransfers){
	      	if (err) return cb(err);
	      	if(!updatedTransfers) return cb(null, null);
	      	Transfer.afterStripeTransferCreated(updatedTransfers[0], function(err, transfer){
	      		cb(err, transfer);
	      	});
	      });
	    });
	}
905376
def callback(self, cats):
        """"""
        enable = bool(cats)
        if not enable:
            # close search if it is visible
            self.search.visible = False
        enable_widget(self.search_widget, enable)
        enable_widget(self.remove_widget, enable)

        if self.done_callback:
            self.done_callback(cats)
1142686
def _le_from_gt(self, other):
    """"""
    op_result = self.__gt__(other)
    if op_result is NotImplemented:
        return NotImplemented
    return not op_result
260771
def do_search(self, arg=None):
        """"""
        new_cats = []
        for cat in self.cats:
            new_cat = cat.search(self.inputs.text,
                                 depth=self.inputs.depth)
            if len(list(new_cat)) > 0:
                new_cats.append(new_cat)
        if len(new_cats) > 0:
            self.done_callback(new_cats)
            self.visible = False
1284512
def dispatch(self, *args, **kwargs):
        """"""
        return super(BreedingDelete, self).dispatch(*args, **kwargs)
1083064
def get(self, key, transaction=None):
    """"""
    return self._client.get(key, transaction=transaction)
1248424
def dispatch(self, *args, **kwargs):
        """"""
        return super(AnimalCreate, self).dispatch(*args, **kwargs)
194903
function( roomID, key ) {

		var oldVal;

		if( roomData[ roomID ] === undefined ) {

			return promise.reject( 'There is no room by that id' );
		} else {

			oldVal = roomData[ roomID ][ key ];

			delete roomData[ roomID ][ key ];

			return promise.resolve( oldVal );
		}
	}
428105
function (key, cb) {
      if(!db.data) return cb(new Error('kiddb not open'))
      if(db.data[key]) cb(null, db.data[key])
      else          cb(new Error('not found'))
    }
151218
def unweaned(self):
        """"""	
        return Animal.objects.filter(Breeding=self, Weaned__isnull=True, Alive=True)
687594
def union_update(self, other, ignore_conflicts=False):
        """"""
        if not ignore_conflicts:
            ensure_compatible(self, other)
        self._objects |= other._objects
        self._properties |= other._properties
        self._pairs |= other._pairs
289146
def replaceChild(self, new_child: 'WdomElement', old_child: 'WdomElement'
                     ) -> Node:
        """"""
        if self.connected:
            self._replace_child_web(new_child, old_child)
        return self._replace_child(new_child, old_child)
823681
def _try_next(self, get_more_allowed):
        """"""
        if not len(self.__data) and not self.__killed and get_more_allowed:
            self._refresh()
        if len(self.__data):
            coll = self.__collection
            return coll.database._fix_outgoing(self.__data.popleft(), coll)
        else:
            return None
605314
def rec_new(self, val):
        
        if val not in self.things:
            for child in val.children():
                self.rec_new(child)
            self.new(val)
        return val
891132
def create(args):
  """"""

  from bob.db.utils import session_try_nolock

  dbfile = args.files[0]

  if args.recreate:
    if args.verbose and os.path.exists(dbfile):
      print('unlinking %s...' % dbfile)
    if os.path.exists(dbfile): os.unlink(dbfile)

  if not os.path.exists(os.path.dirname(dbfile)):
    os.makedirs(os.path.dirname(dbfile))

  # the real work...
  create_tables(args)
  s = session_try_nolock(args.type, dbfile, echo=(args.verbose > 2))
  add_clients(s, args.verbose)
  add_files(s, args.imagedir, args.verbose)
  add_protocols(s, args.verbose)
  s.commit()
  s.close()