Convenience method for subclasses to access factory attributes.
436364
protected String getAttribute(String attributeName) {
    String factoryAttribute = contextName + "." + attributeName;
    return (String) factory.getAttribute(factoryAttribute);  
  }
1315926
public void getAttributes(int symbol, Set<Attribute> internal, Set<Attribute> synthesized, Set<Attribute> inherited) {
        int i;
        int max;
        Attribute a;

        for (AttributionBuffer ab : attributions) {
            a = ab.result.attr;
            if (a.symbol == symbol) {
                if (ab.result.ofs == -1) {
                    synthesized.add(a);
                } else {
                    inherited.add(a);
                }
            }
        }
        max = internals.size();
        for (i = 0; i < max; i += 2) {
            a = (Attribute) internals.get(i);
            if (a.symbol == symbol) {
                internal.add(a);
            }
        }
    }
208041
def modelresource_factory(model, resource_class=ModelResource):
    
    attrs = {'model': model}
    Meta = type(str('Meta'), (object,), attrs)

    class_name = model.__name__ + str('Resource')

    class_attrs = {
        'Meta': Meta,
    }

    metaclass = ModelDeclarativeMetaclass
    return metaclass(class_name, (resource_class,), class_attrs)
1187874
protected void handleNodeAttributes(Object node, Map attributes) {
        // first, short circuit
        if (node == null) {
            return;
        }

        for (Closure attrDelegate : getProxyBuilder().getAttributeDelegates()) {
            FactoryBuilderSupport builder = this;
            if (attrDelegate.getOwner() instanceof FactoryBuilderSupport) {
                builder = (FactoryBuilderSupport) attrDelegate.getOwner();
            } else if (attrDelegate.getDelegate() instanceof FactoryBuilderSupport) {
                builder = (FactoryBuilderSupport) attrDelegate.getDelegate();
            }

            attrDelegate.call(builder, node, attributes);
        }

        if (getProxyBuilder().getCurrentFactory().onHandleNodeAttributes(getProxyBuilder().getChildBuilder(), node, attributes)) {
            getProxyBuilder().setNodeAttributes(node, attributes);
        }
    }
1250869
def get_complex_attrs(self):
        ''''''
        return [getattr(self, attr_name) for attr_name in self._attributes if
                isinstance(getattr(self, attr_name), ComplexSchemaItem)]
1023926
def _onInstanceAttribute(self, name, line, pos, absPosition, level):
        """"""
        # Instance attributes may appear in member functions only so we already
        # have a function on the stack of objects. To get the class object one
        # more step is required so we -1 here.
        attributes = self.objectsStack[level - 1].instanceAttributes
        for item in attributes:
            if item.name == name:
                return
        attributes.append(InstanceAttribute(name, line, pos, absPosition))
339165
def make(cls, **kwargs):
    
    cls_attrs = {f.name: f for f in attr.fields(cls)}

    unknown = {k: v for k, v in kwargs.items() if k not in cls_attrs}
    if len(unknown) > 0:
        _LOGGER.warning(
            "Got unknowns for %s: %s - please create an issue!", cls.__name__, unknown
        )

    missing = [k for k in cls_attrs if k not in kwargs]

    data = {k: v for k, v in kwargs.items() if k in cls_attrs}

    # initialize missing values to avoid passing default=None
    # for the attrs attribute definitions
    for m in missing:
        default = cls_attrs[m].default
        if isinstance(default, attr.Factory):
            if not default.takes_self:
                data[m] = default.factory()
            else:
                raise NotImplementedError
        else:
            _LOGGER.debug("Missing key %s with no default for %s", m, cls.__name__)
            data[m] = None

    # initialize and store raw data for debug purposes
    inst = cls(**data)
    setattr(inst, "raw", kwargs)

    return inst
1088524
private List<String> extractBeanAttributes(Object pValue) {
        List<String> attrs = new ArrayList<String>();
        for (Method method : pValue.getClass().getMethods()) {
            if (!Modifier.isStatic(method.getModifiers()) &&
                !IGNORE_METHODS.contains(method.getName()) &&
                !isIgnoredType(method.getReturnType()) &&
                !hasAnnotation(method, "java.beans.Transient")) {
                addAttributes(attrs, method);
            }
        }
        return attrs;
    }
426413
def get_factory_kwargs(self):
        
        kwargs = {}
        kwargs.update({
            'can_delete': self.can_delete,
            'extra': self.extra,
            'exclude': self.exclude,
            'fields': self.fields,
            'formfield_callback': self.formfield_callback,
            'fk_name': self.fk_name,
        })
        if self.formset_class:
            kwargs['formset'] = self.formset_class

        if self.child_form:
            kwargs['form'] = self.child_form
        return kwargs
906045
def get_factory_by_class(self, klass):
        
        for check, factory in self._factories.items():
            if klass is check:
                return factory(self, klass)
        for check, factory in self._factories.items():
            if issubclass(klass, check):
                return factory(self, klass)
        return klass
1025096
def GetUcsPropertyMetaAttributeList(classId):
		
		if classId in _ManagedObjectMeta:
			attrList = _ManagedObjectMeta[classId].keys()
			attrList.remove("Meta")
			return attrList
		if classId in _MethodFactoryMeta:
			attrList = _MethodFactoryMeta[classId].keys()
			attrList.remove("Meta")
			return attrList

		# If the case of classId is not as in Meta
		nci = UcsUtils.FindClassIdInMoMetaIgnoreCase(classId)
		if (nci != None):
			attrList = _ManagedObjectMeta[nci].keys()
			attrList.remove("Meta")
			return attrList

		nci = UcsUtils.FindClassIdInMethodMetaIgnoreCase(classId)
		if (nci != None):
			attrList = _MethodFactoryMeta[nci].keys()
			attrList.remove("Meta")
			return attrList

		return None
1006445
protected
  void parseCategoryFactory(Element factoryElement) {
    String className = subst(factoryElement.getAttribute(CLASS_ATTR));

    if(EMPTY_STR.equals(className)) {
      LogLog.error("Category Factory tag " + CLASS_ATTR + " attribute not found.");
      LogLog.debug("No Category Factory configured.");
    }
    else {
      LogLog.debug("Desired category factory: ["+className+']');
      Object factory = OptionConverter.instantiateByClassName(className,
                                                                 LoggerFactory.class, 
                                                                 null);
      if (factory instanceof LoggerFactory) {
          catFactory = (LoggerFactory) factory;
      } else {
          LogLog.error("Category Factory class " + className + " does not implement org.apache.log4j.LoggerFactory");
      }
      PropertySetter propSetter = new PropertySetter(factory);

      Element  currentElement = null;
      Node     currentNode    = null;
      NodeList children       = factoryElement.getChildNodes();
      final int length        = children.getLength();

      for (int loop=0; loop < length; loop++) {
        currentNode = children.item(loop);
	if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
	  currentElement = (Element)currentNode;
	  if (currentElement.getTagName().equals(PARAM_TAG)) {
	    setParameter(currentElement, propSetter);
	  } else {
           quietParseUnrecognizedElement(factory, currentElement, props);
      }
	}
      }
    }
  }
1007564
def factory(cls, **kwargs):
    
    for name, obj in inspect.getmembers(sys.modules[__name__]):
        if inspect.isclass(obj) and issubclass(obj, UserAuthnMethod):
            try:
                if obj.__name__ == cls:
                    return obj(**kwargs)
            except AttributeError:
                pass
420613
def get_all_fields(cls, class_obj=None, fields=None):
        

        def return_fields(obj):

            internal_fields = fields
            if internal_fields is None:
                internal_fields = {}

            for attribute in dir(obj):

                try:
                    attr_val = getattr(obj, attribute)
                    attr_cls = attr_val.__class__

                    # If it is a model field, call on init
                    if issubclass(attr_cls, ModelField):
                        internal_fields[attribute] = attr_val
                except:
                    pass

            return internal_fields

        if class_obj is None:
            class_obj = cls

            fields = return_fields(class_obj)
            for parent_class in cls.__bases__:
                parent_fields = cls.get_all_fields(parent_class, fields)
                for field_name, field_value in list(parent_fields.items()):
                    if not field_name in fields:
                        fields[field_name] = field_value

            return fields

        else:
            if not isinstance(class_obj, CollectionModel):
                return fields
593251
public static Method getCallableFactoryForParams(final Class<?> type, final Class<?>... params) {
        for (Method m : type.getMethods()) {
            if ((m.getModifiers() & PUBLIC_STATIC_MODIFIER) != PUBLIC_STATIC_MODIFIER) {
                continue;
            }
            if (!type.isAssignableFrom(m.getReturnType())) {
                continue;
            }
            if (!Arrays.equals(m.getParameterTypes(), params)) {
                continue;
            }
            if (!VALID_FACTORY_METHOD_NAMES.matcher(m.getName()).matches()) {
                continue;
            }
            return m;
        }
        return null;
    }
1259912
def is_model_factory(node):
    """"""
    try:
        parent_classes = node.expr.inferred()
    except:  # noqa: E722, pylint: disable=bare-except
        return False

    parents = ('factory.declarations.LazyFunction',
               'factory.declarations.SubFactory',
               'factory.django.DjangoModelFactory')

    for parent_class in parent_classes:
        try:
            if parent_class.qname() in parents:
                return True

            if node_is_subclass(parent_class, *parents):
                return True
        except AttributeError:
            continue

    return False
131378
def _find_relation_factory(module):
    
    if not module:
        return None

    # All the RelationFactory subclasses
    candidates = [o for o in (getattr(module, attr) for attr in dir(module))
                  if (o is not RelationFactory and
                      o is not RelationBase and
                      isclass(o) and
                      issubclass(o, RelationFactory))]

    # Filter out any factories that are superclasses of another factory
    # (none of the other factories subclass it). This usually makes
    # the explict check for RelationBase and RelationFactory unnecessary.
    candidates = [c1 for c1 in candidates
                  if not any(issubclass(c2, c1) for c2 in candidates
                             if c1 is not c2)]

    if not candidates:
        hookenv.log('No RelationFactory found in {}'.format(module.__name__),
                    hookenv.WARNING)
        return None

    if len(candidates) > 1:
        raise RuntimeError('Too many RelationFactory found in {}'
                           ''.format(module.__name__))

    return candidates[0]