Get attribute(s) information.

    Args:
      attributes: Dict representing user attributes and values which need to be recorded.

    Returns:
      List consisting of valid attributes for the user. Empty otherwise.
12373
def _get_attributes(self, attributes):
    

    params = []

    if isinstance(attributes, dict):
      for attribute_key in attributes.keys():
        attribute_value = attributes.get(attribute_key)
        # Omit attribute values that are not supported by the log endpoint.
        if validator.is_attribute_valid(attribute_key, attribute_value):
          attribute_id = self.config.get_attribute_id(attribute_key)
          if attribute_id:
            params.append({
              'entity_id': attribute_id,
              'key': attribute_key,
              'type': self.EventParams.CUSTOM,
              'value': attribute_value
            })

    # Append Bot Filtering Attribute
    bot_filtering_value = self._get_bot_filtering()
    if isinstance(bot_filtering_value, bool):
      params.append({
          'entity_id': enums.ControlAttributes.BOT_FILTERING,
          'key': enums.ControlAttributes.BOT_FILTERING,
          'type': self.EventParams.CUSTOM,
          'value': bot_filtering_value
      })

    return params
242024
def get_attributes(element)
      attribute_hash = {}
      attributes = element.attributes
      for i in 0...attributes.length
         attribute_hash[attributes.item(i).name] =  attributes.item(i).value
       end
      attribute_hash
    end
384269
def attributes
      attrs = Hash.new
      attribute_list.each do |attribute|
        value = self.send(attribute)
        attrs[attribute] = value unless value.nil?
      end
      attrs
    end
188209
public AttributeList getAttributes(String[] attributes) {
    final AttributeList result = new AttributeList();
    for (String attributeName : attributes) {
      result.add(new Attribute(attributeName, getAttributeInternal(attributeName)));
    }
    return result;
  }
19674
def list_attributes(self, name):
        
        result = self.client.service.getListAttributes(name, self.proxy_id)
        if isinstance(result, list) and len(result) == 1:
            return result[0]
        return result
328876
def get_enabled_features(self, user_id, attributes=None):
    

    enabled_features = []
    if not self.is_valid:
      self.logger.error(enums.Errors.INVALID_DATAFILE.format('get_enabled_features'))
      return enabled_features

    if not isinstance(user_id, string_types):
      self.logger.error(enums.Errors.INVALID_INPUT_ERROR.format('user_id'))
      return enabled_features

    if not self._validate_user_inputs(attributes):
      return enabled_features

    for feature in self.config.feature_key_map.values():
      if self.is_feature_enabled(feature.key, user_id, attributes):
        enabled_features.append(feature.key)

    return enabled_features
98287
def get_meta_attributes(self, **kwargs):
        """"""
        superuser = kwargs.get('superuser', False)
        if (self.untl_object.qualifier == 'recordStatus'
                or self.untl_object.qualifier == 'system'):
            if superuser:
                self.editable = True
                self.repeatable = True
            else:
                self.editable = False
            self.view_type = 'qualified-input'
        elif self.untl_object.qualifier == 'hidden':
            self.label = 'Object Hidden'
            self.view_type = 'radio'
        else:
            self.editable = False
            self.view_type = 'qualified-input'
1285602
def GetAttributes(self):
    
    for attribute_name, attribute_value in iter(self.__dict__.items()):
      # Not using startswith to improve performance.
      if attribute_name[0] == '_' or attribute_value is None:
        continue

      yield attribute_name, attribute_value
1169394
def _extract_user_info(user):
    

    temp_user = User()
    copy_attributes = [
        'antennas', 'name', 'night_start', 'night_end', 'weekend', 'home']

    for attr in copy_attributes:
        setattr(temp_user, attr, getattr(user, attr))

    return temp_user
1243162
def get_attributes(file, *, attributes=None, mime_type=None,
                   force_document=False, voice_note=False, video_note=False,
                   supports_streaming=False):
    
    # Note: ``file.name`` works for :tl:`InputFile` and some `IOBase` streams
    name = file if isinstance(file, str) else getattr(file, 'name', 'unnamed')
    if mime_type is None:
        mime_type = mimetypes.guess_type(name)[0]

    attr_dict = {types.DocumentAttributeFilename:
        types.DocumentAttributeFilename(os.path.basename(name))}

    if is_audio(file):
        m = _get_metadata(file)
        if m:
            attr_dict[types.DocumentAttributeAudio] = \
                types.DocumentAttributeAudio(
                    voice=voice_note,
                    title=m.get('title') if m.has('title') else None,
                    performer=m.get('author') if m.has('author') else None,
                    duration=int(m.get('duration').seconds
                                 if m.has('duration') else 0)
                )

    if not force_document and is_video(file):
        m = _get_metadata(file)
        if m:
            doc = types.DocumentAttributeVideo(
                round_message=video_note,
                w=m.get('width') if m.has('width') else 0,
                h=m.get('height') if m.has('height') else 0,
                duration=int(m.get('duration').seconds
                             if m.has('duration') else 0),
                supports_streaming=supports_streaming
            )
        else:
            doc = types.DocumentAttributeVideo(
                0, 1, 1, round_message=video_note,
                supports_streaming=supports_streaming)

        attr_dict[types.DocumentAttributeVideo] = doc

    if voice_note:
        if types.DocumentAttributeAudio in attr_dict:
            attr_dict[types.DocumentAttributeAudio].voice = True
        else:
            attr_dict[types.DocumentAttributeAudio] = \
                types.DocumentAttributeAudio(0, voice=True)

    # Now override the attributes if any. As we have a dict of
    # {cls: instance}, we can override any class with the list
    # of attributes provided by the user easily.
    if attributes:
        for a in attributes:
            attr_dict[type(a)] = a

    # Ensure we have a mime type, any; but it cannot be None
    # 'The "octet-stream" subtype is used to indicate that a body
    # contains arbitrary binary data.'
    if not mime_type:
        mime_type = 'application/octet-stream'

    return list(attr_dict.values()), mime_type
26629
def get_attribute(self, instance):
        
        try:
            return get_attribute(instance, self.source_attrs)
        except (KeyError, AttributeError) as exc:
            if not self.required and self.default is empty:
                raise SkipField()
            msg = (
                'Got {exc_type} when attempting to get a value for field '
                '`{field}` on serializer `{serializer}`.\nThe serializer '
                'field might be named incorrectly and not match '
                'any attribute or key on the `{instance}` instance.\n'
                'Original exception text was: {exc}.'.format(
                    exc_type=type(exc).__name__,
                    field=self.field_name,
                    serializer=self.parent.__class__.__name__,
                    instance=instance.__class__.__name__,
                    exc=exc
                )
            )
            raise type(exc)(msg)
427352
def get_attributes(self):
        
        attr = ['chr', 'start', 'stop']
        if self.strandPos is not None:
            attr.append('strand')
        if self.otherPos:
            for i, o in enumerate(self.otherPos):
                attr.append(o[1])

        return attr
1250504
def getAttributeValueData(self, index):
        
        offset = self._get_attribute_offset(index)
        return self.m_attributes[offset + const.ATTRIBUTE_IX_VALUE_DATA]
1325702
def attributes(self, source=None, relation=None, target=None):
        
        attrmatch = lambda a: (
            (source is None or source == a.source) and
            (relation is None or relation == a.relation) and
            (target is None or target == a.target)
        )
        variables = self.variables()
        attrs = [t for t in self.triples() if t.target not in variables]
        return list(filter(attrmatch, attrs))
708801
def default_attributes(self):
        """"""
        if self._default_attributes is None:
            self._default_attributes = {
                name: attr
                for name, attr in self.attributes.items()
                if attr.default is True
            }
        return self._default_attributes
1089317
def update_user_attributes(self, id, old_attrs, new_attrs):
        
        from alerta.utils.collections import merge
        merge(old_attrs, new_attrs)
        attrs = {k: v for k, v in old_attrs.items() if v is not None}
        update = {
            '$set': {'attributes': attrs}
        }
        response = self.get_db().users.update_one({'_id': {'$regex': '^' + id}}, update=update)
        return response.matched_count > 0
782846
def get_attributes(self, name_list):
        
        properties = {}
        for name in name_list:
            value = self.get_attribute(name)
            if value is not None:
                properties[name] = value
        return properties