Return the identities from an item
333968
def get_identities(self, item):
        """"""

        user = self.get_sh_identity(item, self.get_field_author())
        yield user
266249
def _get_genestr(self, itemid):
        """"""
        if itemid in self.id2symbol:
            symbol = self.id2symbol[itemid]
            if symbol is not None:
                return symbol
        if isinstance(itemid, int):
            return str(itemid)
        return itemid
924077
def get_identities(self, item):
        
        identities = []

        if 'data' not in item:
            return identities
        if 'revisions' not in item['data']:
            return identities

        revisions = item['data']['revisions']

        for revision in revisions:
            user = self.get_sh_identity(revision)
            yield user
125206
def extract_table_identifiers(token_stream):
    """"""

    for item in token_stream:
        if isinstance(item, IdentifierList):
            for identifier in item.get_identifiers():
                # Sometimes Keywords (such as FROM ) are classified as
                # identifiers which don't have the get_real_name() method.
                try:
                    schema_name = identifier.get_parent_name()
                    real_name = identifier.get_real_name()
                except AttributeError:
                    continue
                if real_name:
                    yield (schema_name, real_name, identifier.get_alias())
        elif isinstance(item, Identifier):
            real_name = item.get_real_name()
            schema_name = item.get_parent_name()

            if real_name:
                yield (schema_name, real_name, item.get_alias())
            else:
                name = item.get_name()
                yield (None, name, item.get_alias() or name)
        elif isinstance(item, Function):
            yield (None, item.get_name(), item.get_name())
611763
def getItemLocals(item):
    '''
    

    '''
    for name in dir(item):
        try:
            valu = getattr(item, name, None)
            yield name, valu
        except Exception:
            pass
486296
def _get_id2children(id2children, item_id, item_obj):
    """"""
    if item_id in id2children:
        return id2children[item_id]
    child_ids = set()
    for child_obj in item_obj.children:
        child_id = child_obj.item_id
        child_ids.add(child_id)
        child_ids |= _get_id2children(id2children, child_id, child_obj)
    id2children[item_id] = child_ids
    return child_ids
940367
def _drop_id_prefixes(self, item):
        
        if isinstance(item, list):
            return [self._drop_id_prefixes(i) for i in item]
        if isinstance(item, dict):
            return {
                'id' if k.endswith('id') else k: self._drop_id_prefixes(v)
                for k, v in item.items()
            }
        return item
795815
def get_ids(self, start=0, rows=1000, **query_dict):
        """"""
        resp_dict = self._get_query(start=start, rows=rows, **query_dict)
        return {
            'matches': resp_dict['response']['numFound'],
            'start': start,
            'ids': [d['id'] for d in resp_dict['response']['docs']],
        }
712589
def get_sh_identity(self, item, identity_field=None):
        

        def fill_list_identity(identity, user_list_data):
            """ Fill identity with user data in first item in list """
            identity['username'] = user_list_data[0]['__text__']
            if '@' in identity['username']:
                identity['email'] = identity['username']
            if 'name' in user_list_data[0]:
                identity['name'] = user_list_data[0]['name']
            return identity

        identity = {}
        for field in ['name', 'email', 'username']:
            # Basic fields in Sorting Hat
            identity[field] = None

        user = item  # by default a specific user dict is used
        if 'data' in item and type(item) == dict:
            user = item['data'][identity_field]

        identity = fill_list_identity(identity, user)

        return identity
475079
def _get_id2parents(id2parents, item_id, item_obj):
    """"""
    if item_id in id2parents:
        return id2parents[item_id]
    parent_ids = set()
    for parent_obj in item_obj.parents:
        parent_id = parent_obj.item_id
        parent_ids.add(parent_id)
        parent_ids |= _get_id2parents(id2parents, parent_id, parent_obj)
    id2parents[item_id] = parent_ids
    return parent_ids
390598
def item_id(response):
    
    dict_keys = ['item_0', 'item_1', 'item_2',
                 'item_3', 'item_4', 'item_5']
    new_keys = ['item_0_name', 'item_1_name', 'item_2_name',
                'item_3_name', 'item_4_name', 'item_5_name']

    for player in response['players']:
        for key, new_key in zip(dict_keys, new_keys):
            for item in items['items']:
                if item['id'] == player[key]:
                    player[new_key] = item['localized_name']

    return response
379409
def get_identities(self, item):
        """"""

        for rol in self.roles:
            if rol in item['data']:
                user = self.get_sh_identity(item["data"][rol])
                yield user

        if 'activity' in item["data"]:
            for event in item["data"]['activity']:
                event_user = [{"__text__": event['Who']}]
                user = self.get_sh_identity(event_user)
                yield user

        if 'long_desc' in item["data"]:
            for comment in item["data"]['long_desc']:
                user = self.get_sh_identity(comment['who'])
                yield user
1126978
def get_id2children(objs):
    """"""
    id2children = {}
    for obj in objs:
        _get_id2children(id2children, obj.item_id, obj)
    return id2children
718780
def get_by(self, name):
    """"""
    return next((item for item in self if item.name == name), None)
1169495
def get_identities(self, item):
        """"""

        item = item['data']
        if 'owner' in item:
            owner = self.get_sh_identity(item['owner'])
            yield owner
        if 'user' in item:
            user = self.get_sh_identity(item['user'])
            yield user
        if 'mentor' in item:
            mentor = self.get_sh_identity(item['mentor'])
            yield mentor
466635
def key_list(items=None):
    '''
    
    '''
    if items is None:
        items = []

    ret = {}
    if items and isinstance(items, list):
        for item in items:
            if 'name' in item:
                # added for consistency with old code
                if 'id' not in item:
                    item['id'] = item['name']
                ret[item['name']] = item
    return ret
263193
def get_obj_id(self, item):
        
        if item is not None:
            if isinstance(item, six.string_types):
                return item
            elif hasattr(item, 'id'):
                return item.id