Search database for given key and user pattern.
182802
def search(self, key_pattern: str, user_pattern: str) -> List[Entry]:
        """"""
        # normalize key
        key_pattern = _normalized_key(key_pattern)

        # search
        results = []
        for entry in self.entries:
            if key_pattern in entry.key and user_pattern in entry.user:
                results.append(entry)

        # sort results according to key (stability of sorted() ensures that the order of accounts for any given key remains untouched)
        return sorted(results, key=lambda e: e.key)
167232
def get_database_users(self):
        """"""
        url = "db/{0}/users".format(self._database)

        response = self.request(
            url=url,
            method='GET',
            expected_response_code=200
        )

        return response.json()
278544
def search(query)
        clause = query.blank? ? nil : "%" + query.downcase + "%"
        base = ::User.where(*base_query)
        base = base.where("#{Hydra.config.user_key_field} like lower(?) OR display_name like lower(?)", clause, clause) if clause.present?
        base.registered
            .where("#{Hydra.config.user_key_field} not in (?)",
                   [::User.batch_user_key, ::User.audit_user_key])
            .references(:trophies)
            .order(sort_value)
            .page(params[:page]).per(10)
      end
1291067
def find_users(session, *usernames):
    """"""
    user_string = ','.join(usernames)
    return _make_request(session, FIND_USERS_URL, user_string)
708947
def _get_users(self, user_base):
        """""""
        results = self._search(
            getattr(self, '_%s_user_base' % user_base),
            '(objectClass=*)',
            ['*'],
            scope=ldap.SCOPE_ONELEVEL
        )
        for dn, attrs in results:
            uid = attrs.get('uid')[0].decode('utf-8', 'ignore')
            getattr(self, '_%s_users' % user_base)[uid] = FreeIPAUser(dn, attrs)
            # print(attrs)
        log.debug('%s users: %s' % (user_base.capitalize(), len(getattr(self, '_%s_users' % user_base))))
736987
def keys():
    """"""
    for admin in current_app.config['ADMIN_USERS']:
        try:
            db.get_db()  # init db on global app context
            keys = ApiKey.find_by_user(admin)
        except Exception as e:
            click.echo('ERROR: {}'.format(e))
        else:
            for key in keys:
                click.echo('{:40} {}'.format(key.key, key.user))
126650
def get_entry(self, key, column=None, table=None):
        """"""
        if table is None:  table  = self.main_table
        if column is None: column = "id"
        if isinstance(key, basestring): key = key.replace("'","''")
        query = 'SELECT * from "%s" where "%s"=="%s" LIMIT 1;'
        query = query % (table, column, key)
        self.own_cursor.execute(query)
        return self.own_cursor.fetchone()
746878
def lookup(source, keys, fallback = None):
  """"""
  try:
    for key in keys:
      source = source[key]
    return source
  except (KeyError, AttributeError, TypeError):
    return fallback
674649
def _get_string_match(self, key):
        

        expression = r'(?:\s*)'.join([
            '^',
            'define',
            r'\(',
            '\'{}\''.format(key),
            ',',
            r'\'(.*)\'',
            r'\)',
            ';'
        ])

        pattern = re.compile(expression, re.MULTILINE)
        return pattern.search(self._content)
883245
def LDAP_search(pattern_search, attribute):
    
    connection, ldap_base = _get_LDAP_connection()

    connection.search(
        search_base=ldap_base,
        search_filter=pattern_search,
        attributes=[attribute]
    )
    return connection.response
563452
def query(name):
    """"""
    collection = Collection.query.filter_by(name=name).one()
    click.echo(collection.dbquery)
1219970
function search(user, pass, userArray) {
      return _.findWhere(userArray, { user: user, pass: pass });
    }
690519
def search(query)
      regex = Regexp.new(query, 'i')
      _cookbooks.collect do |_, v|
        v[v.keys.first] if regex.match(v[v.keys.first].name)
      end.compact
    end
1117938
def search(pkg_name, **kwargs):
    '''
    
    '''

    pkglist = {}
    pkgin = _check_pkgin()
    if not pkgin:
        return pkglist

    if _supports_regex():
        pkg_name = '^{0}$'.format(pkg_name)

    out = __salt__['cmd.run'](
        [pkgin, 'se', pkg_name],
        output_loglevel='trace'
    )
    for line in out.splitlines():
        if line:
            match = _splitpkg(line.split()[0])
            if match:
                pkglist[match[0]] = match[1]

    return pkglist
1246078
def get_user_by_key(app, key):
    
    user = ses.query(um.User).join(um.UserKey).filter(um.UserKey.key==key).first()
    return user
592017
def search(self, query, _options={}, products=None):
        '''
        
        '''
        options = _options or {}

        return self.client.post_public_key('/institutions/search', {
            'query': query,
            'products': products,
            'options': options,
        })
298235
def search(cls, args):
        """"""
        safe_shell_pat = re.escape(args['<pattern>']).replace(r'\*', '.*')
        pat_str = '.*{}.*'.format(safe_shell_pat)
        pattern = re.compile(pat_str, re.IGNORECASE)
        remote_json = NAppsManager.search(pattern)
        remote = set()
        for napp in remote_json:
            # WARNING: This will be changed in future versions, when 'author'
            # will be removed.
            username = napp.get('username', napp.get('author'))
            remote.add(((username, napp.get('name')), napp.get('description')))

        cls._print_napps(remote)