:param username: if given, restrict to it
    :returns: the last calculation in the database or the datastore
766727
def get_last_calc_id(username=None):
    
    if config.dbserver.multi_user:
        job = dbcmd('get_job', -1, username)  # can be None
        return getattr(job, 'id', 0)
    else:  # single user
        return datastore.get_last_calc_id()
1191246
def last(conf):
    """"""
    try:
        v2ex = V2ex(conf.config)
        v2ex.login()
        last_date = v2ex.get_last()
        click.echo(last_date)
    except KeyError:
        click.echo('Keyerror, please check your config file.')
    except IndexError:
        click.echo('Please check your username and password.')
931418
function username(value, fromIndex) {
  var index = fromIndex
  var length = value.length
  var size

  /* First character of username cannot be a dash. */
  if (value.charCodeAt(index) === CC_DASH) {
    return -1
  }

  while (index < length) {
    if (!usernameCharacter(value.charCodeAt(index))) {
      break
    }

    index++
  }

  size = index - fromIndex

  /* Last character of username can no longer be a dash, but could be (GH-13). */
  if (!size || size > MAX_USER_LENGTH) {
    return -1
  }

  return index
}
434576
def show(self, username):
        """"""
        filter = ['(objectclass=posixAccount)', "(uid={})".format(username)]
        return self.client.search(filter)
1140224
function findByUsername(username, cb) {
  db.getClient(function(err, client, done) {
    client.query(SELECT_USERNAME, [username], function(err, r) {
      var result = r && r.rows[0];
      if(!err && !result) { err = new exceptions.NotFound(); }
      if(err) {
        cb(err);
        done(err);
      } else {
        cb(null, result);
        done();
      }
    });
  });
}
601932
def get(self, user_name: str) -> User:
        
        user = current_user()
        if user.is_admin or user.name == user_name:
            return self._get_or_abort(user_name)
        else:
            abort(403)
248720
def release_name(self, username):
        
        self.temp_names.append(username)
        if self.is_username_used(username):
            self.registered_names.remove(username)
905623
def user_is_superadmin(self, username=None):
        
        if username is None:
            username = self.session_username()

        return username in self._superadmins
216961
def get_user(self, username):
        

        sql = '''SELECT * FROM user WHERE username = ?'''
        self._db_curs.execute(sql, (username, ))
        user = self._db_curs.fetchone()
        return user
590761
def user_exists(self, username):
        

        response = self._get(self.rest_url + "/user",
                             params={"username": username})

        if not response.ok:
            return None

        return True
1083511
def username(self):
        
        username = self.config.get("username")
        if not username:
            username = self.userinfo__preferred_username
        return username
643540
def _last_values(self):
        
        if not self.session.get('last_request_uri'):
            self.session.last_request_uri = None
        self.session.last_request_at = self.session.get('last_request_at', 0)
167533
def get_user(self, username):
        
        User = get_user_model()  # noqa
        try:
            user = User.objects.get(**{
                User.USERNAME_FIELD: username,
                'is_active': False
            })
            return user
        except User.DoesNotExist:
            return None
873289
def db_user_exists(username):
    
    qry = u"""SELECT COUNT(*) FROM pg_roles where rolname = \'{username}\';"""
    output = StringIO()
    excute_query(
        qry.format(username=username),
        flags="-Aqt",
        use_sudo=True,
        stdout=output
    )
    # FIXME: is there a way to get fabric to not clutter the output
    # with "[127.0.0.1] out:" on each line?
    lines = output.getvalue().splitlines()
    return lines and lines[0].endswith('out: 1')
531775
def current_user_was_last_verifier(analysis):
    
    verifiers = analysis.getVerificators()
    return verifiers and verifiers[:-1] == api.get_current_user().getId()
693866
def get_member_details(self, username):
        
        members = self.get_members()
        for member in members:
            if member.username == username:
                return member
1245533
def get_last_user(self, refresh=False):
        """"""
        if refresh:
            self.refresh_complex_value('sl_UserCode')
        val = self.get_complex_value("sl_UserCode")
        # Syntax string: UserID="<pin_slot>" UserName="<pin_code_name>"
        # See http://wiki.micasaverde.com/index.php/Luup_UPnP_Variables_and_Actions#DoorLock1

        try:
            # Get the UserID="" and UserName="" fields separately
            raw_userid, raw_username = val.split(' ')
            # Get the right hand value without quotes of UserID="<here>"
            userid = raw_userid.split('=')[1].split('"')[1]
            # Get the right hand value without quotes of UserName="<here>"
            username = raw_username.split('=')[1].split('"')[1]
        except Exception as ex:
            logger.error('Got unsupported user string {}: {}'.format(val, ex))
            return None

        return ( userid, username )