Return a single person
333722
def _get(id, type):
    '''  '''
    result = query("{0}/{1}/{2}/".format(
        settings.BASE_URL,
        type,
        str(id))
    )
    return result
1337477
def get_one(self):
        """"""
        self.default_val = None
        o = self.default_val
        d = self._query('get_one')
        if d:
            o = self.orm_class(d, hydrate=True)
        return o
1009657
def run_one(self, name, migrator, fake=True, downgrade=False, force=False):
        """"""
        try:
            migrate, rollback = self.read(name)
            if fake:
                with mock.patch('peewee.Model.select'):
                    with mock.patch('peewee.Query._execute'):
                        migrate(migrator, self.database, fake=fake)

                if force:
                    self.model.create(name=name)
                    self.logger.info('Done %s', name)

                migrator.clean()
                return migrator

            with self.database.transaction():
                if not downgrade:
                    self.logger.info('Migrate "%s"', name)
                    migrate(migrator, self.database, fake=fake)
                    migrator.run()
                    self.model.create(name=name)
                else:
                    self.logger.info('Rolling back %s', name)
                    rollback(migrator, self.database, fake=fake)
                    migrator.run()
                    self.model.delete().where(self.model.name == name).execute()

                self.logger.info('Done %s', name)

        except Exception:
            self.database.rollback()
            operation = 'Migration' if not downgrade else 'Rollback'
            self.logger.exception('%s failed: %s', operation, name)
            raise
507532
def returner(load):
    '''
    
    '''
    for returner_ in __opts__[CONFIG_KEY]:
        _mminion().returners['{0}.returner'.format(returner_)](load)
1046473
def get_user_if_exists(strategy, details, user=None, *args, **kwargs):
    """"""
    if user:
        return {'is_new': False}
    try:
        username = details.get('username')

        # Return the user if it exists
        return {
            'is_new': False,
            'user': User.objects.get(username=username)
        }
    except User.DoesNotExist:
        # Fall to the default return value
        pass

    # Nothing to return since we don't have a user
    return {}
1057275
def start_single(self, typ, scol):
        """"""
        self.starting_single = True
        single = self.single = Single(typ=typ, group=self, indent=(scol - self.level))
        self.singles.append(single)
        return single
1243649
def returner(ret):
    '''
    
    '''
    try:
        with _get_serv(ret, commit=True) as cur:
            sql = '''INSERT INTO salt_returns
                    (fun, jid, return, id, success, full_ret)
                    VALUES (%s, %s, %s, %s, %s, %s)'''
            cur.execute(
                sql, (
                    ret['fun'],
                    ret['jid'],
                    salt.utils.json.dumps(ret['return']),
                    ret['id'],
                    ret.get('success', False),
                    salt.utils.json.dumps(ret)))
    except salt.exceptions.SaltMasterError:
        log.critical('Could not store return with postgres returner. PostgreSQL server unavailable.')
1040725
def clean_account(self):
        """"""
        account = self.cleaned_data['account']
        if not account:
            return

        if account.type != Account.TYPES.income:
            raise ValidationError('Account must be an income account')

        try:
            account.housemate
        except Housemate.DoesNotExist:
            pass
        else:
            raise ValidationError('Account already has a housemate')

        return account
796745
def find_one(self, cls, id):
        """"""
        found = self.find_by_index(cls, 'id', id)
        return found[0] if found else None
841837
def _get_one(self, id):
        
        try:
            return self._to_dict(models.User.objects.get(pk=id))
        except models.User.DoesNotExist:
            raise errors.NotFound()
289711
function (subject) {
    var t = kb.findTypeURIs(subject)
    if (t[ns.vcard('Individual').uri]) return 'Contact'
    if (t[ns.vcard('Organization').uri]) return 'contact'
    if (t[ns.foaf('Person').uri]) return 'Person'
    if (t[ns.schema('Person').uri]) return 'Person'
    if (t[ns.vcard('Group').uri]) return 'Group'
    if (t[ns.vcard('AddressBook').uri]) return 'Address book'
    return null // No under other circumstances
  }
958783
def _unwrap_response_single(cls, obj, wrapper=None):
        

        if wrapper is not None:
            return obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST][wrapper]

        return obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST]
857563
def from_person(person):
        
        p = Person()
        p.id = person.id
        p.sitting = person.sitting
        return p
1027983
function single (url, options = {}) {
  let tries = 1

  // Execute the request and retry if there are errors (and the
  // retry decider decided that we should try our luck again)
  const callRequest = () => request(url, options).catch(err => {
    if (internalRetry(++tries, err)) {
      return wait(callRequest, internalRetryWait(tries))
    }

    throw err
  })

  return callRequest()
}
907822
function(decoded, request, callback) {
    // do your checks to see if the person is valid
    if (!people[decoded.id]) {
        return callback(null, false);
    }
    return callback(null, true, people[decoded.id]);
}
981920
def get_or_create_person(self, row):
        
        person, created = entity.Person.objects.get_or_create(
            first_name=row["first"], last_name=row["last"]
        )

        return person
620781
def get_one(self, schema, query=None, **kwargs):
        
        ret = self._get_query(self._get_one, schema, query, **kwargs)
        if not ret: ret = {}
        return ret