Ensures :attr:`subject` has an attribute *attr*.
511358
def has_attribute(self, attr):
        
        if not hasattr(self._subject, attr):
            raise self._error_factory(_format("Expected {} to have attribute {}", self._subject, attr))
        return ReferenceInspector(getattr(self._subject, attr))
152689
def assign(A, attr, B, lock=False):
    '''
    '''
    class NoAttr(object): pass

    context = threading.Lock if lock else null_context
    with context():
        if not hasattr(A, attr):
            tmp = NoAttr
        else:
            tmp = getattr(A, attr)

        setattr(A, attr, B)

        try:
            yield B

        finally:
            if tmp is NoAttr:
                delattr(A, attr)
            else:
                setattr(A, attr, tmp)
57639
def raise_on_duplicate(self, attrname):
        
        if getattr(self, attrname):
            with transaction.atomic():
                error_msg = (
                    'Cannot {{action}} registered subject with a duplicate '
                    '\'{}\'. Got {}.'.format(attrname, getattr(self, attrname)))
                try:
                    obj = self.__class__.objects.exclude(
                        **{'pk': self.pk} if self.id else {}).get(
                            **{attrname: getattr(self, attrname)})
                    if not self.id:
                        raise RegisteredSubjectError(
                            error_msg.format(action='insert'))
                    elif self.subject_identifier_is_set() and obj.id != self.id:
                        raise RegisteredSubjectError(
                            error_msg.format(action='update'))
                    else:
                        raise RegisteredSubjectError(
                            error_msg.format(action='update'))
                except self.__class__.DoesNotExist:
                    pass
468815
public static boolean inAttributes(String attrName, Attributes attrs) {
        for (NamingEnumeration<String> neu = attrs.getIDs(); neu.hasMoreElements();) {
            String attrId = neu.nextElement();
            if (attrId.equalsIgnoreCase(attrName)) {
                return true;
            }
        }
        return false;
    }
483033
def preserve_attr_data(A, B):
    '''
    '''
    for attr, B_data in B.items(): # defined object attrs
        if getattr(B_data, 'override_parent', True):
            continue
        if attr in A:
            A_data = A[attr]
            for _attr in getattr(A_data, '_attrs', []): # Attr attrs, like type, default, & doc
                if hasattr(A_data, _attr):
                    if getattr(B_data, _attr, None) is not None:
                        if _attr in getattr(B_data, '_set_by_default', []):
                            setattr(B_data, _attr, getattr(A_data, _attr))
                    else:
                        setattr(B_data, _attr, getattr(A_data, _attr))
10515
def norm_attr(self):
        
        if not self.HAS_ATTR:
            return

        self.HAS_ATTR = False
        self.emit('call', 'COPY_ATTR', 0)
        backend.REQUIRES.add('copy_attr.asm')
950956
def _set_subject(self, subject):
        
        # if not subject:
        #     self.subject =
        def test_uri(value):
            """ test to see if the value is a uri or bnode

            Returns: Uri or Bnode """
            # .__wrapped__
            if not isinstance(value, (Uri, BlankNode)):
                try:
                    if value.startswith("_:"):
                        return BlankNode(value)
                    else:
                        return Uri(value)
                except:
                    return BlankNode()
            else:
                return value

        if isinstance(subject, dict):
            self.subject = test_uri(subject['s'])
            if isinstance(subject['o'], list):
                for item in subject['o']:
                    self.add_property(subject['p'],
                                      item)
            else:
                self.add_property(subject['p'],
                                  subject['o'])
        else:
            self.subject = test_uri(subject)
224557
def _validate_empty_attributes(self, attributes):
        """"""
        attrs_to_check = set(self._required) & set(attributes)
        for attr in attrs_to_check:
            value = getattr(self, attr)  # We should always have a value here
            if value is None or value == "":
                raise ValueError(
                    "Attribute %s cannot be None or an empty string since it is required." % attr
                )
784
def setattrdeep(obj, attr, val):
    ''
    attrs = attr.split('.')

    for a in attrs[:-1]:
        obj = getattr(obj, a)
    setattr(obj, attrs[-1], val)
870090
def p_attr(self,t):
    
    # careful: sqex.infer_columns relies on AttrX not containing anything but a name
    t[0] = AttrX(NameX(t[1]), AsterX() if t[3]=='*' else NameX(t[3]))
785459
def attr(aid):
    '''
    
    '''
    def _attr(ctx):
        return ctx.current_link[ATTRIBUTES].get(aid)
    return _attr
118996
def setAttribute(self, attr: str, value: _AttrValueType) -> None:
        """"""
        self._set_attribute(attr, value)
121821
def Set(self,
          subject,
          attribute,
          value,
          timestamp=None,
          replace=True,
          sync=True):
    """"""
    subject = utils.SmartUnicode(subject)

    _ = sync
    attribute = utils.SmartUnicode(attribute)

    if timestamp is None or timestamp == self.NEWEST_TIMESTAMP:
      timestamp = time.time() * 1000000

    if subject not in self.subjects:
      self.subjects[subject] = {}

    if replace or attribute not in self.subjects[subject]:
      self.subjects[subject][attribute] = []

    encoded_value = self._value_converter.Encode(attribute, value)
    self.subjects[subject][attribute].append([encoded_value, int(timestamp)])
    self.subjects[subject][attribute].sort(key=lambda x: x[1])
99090
def subject=(subject)
      validator = EnumAttributeValidator.new('String', ["english/language arts", "math", "science", "social studies", "language", "homeroom/advisory", "interventions/online learning", "technology and engineering", "PE and health", "arts and music", "other"])
      unless validator.valid?(subject)
        fail ArgumentError, "invalid value for 'subject', must be one of #{validator.allowable_values}."
      end
      @subject = subject
    end
919353
def add_attr(self, name, value):
        """"""
        setattr(self, name, value)
        self.attrs.append(name)
1275554
def use_model_attr(attr):
    """"""

    def use_model_validator(instance, attribute, value):
        getattr(instance, attr)(instance, attribute, value)
    return use_model_validator
1361001
def get(self, attr, default=None):
        """"""

        attrs = self.body.get('attributes') or {}
        return attrs.get(attr, default)