MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / getComponentByName

Method getComponentByName

pager_lib/pyasn1/type/univ.py:2343–2380  ·  view source on GitHub ↗

Returns |ASN.1| type component by name. Equivalent to Python :class:`dict` subscription operation (e.g. `[]`). Parameters ---------- name: :class:`str` |ASN.1| type component name Keyword Args ------------ default: :class:`object

(self, name, default=noValue, instantiate=True)

Source from the content-addressed store, hash-verified

2341 myClone.setComponentByPosition(idx, componentValue.clone())
2342
2343 def getComponentByName(self, name, default=noValue, instantiate=True):
2344 """Returns |ASN.1| type component by name.
2345
2346 Equivalent to Python :class:`dict` subscription operation (e.g. `[]`).
2347
2348 Parameters
2349 ----------
2350 name: :class:`str`
2351 |ASN.1| type component name
2352
2353 Keyword Args
2354 ------------
2355 default: :class:`object`
2356 If set and requested component is a schema object, return the `default`
2357 object instead of the requested component.
2358
2359 instantiate: :class:`bool`
2360 If :obj:`True` (default), inner component will be automatically
2361 instantiated.
2362 If :obj:`False` either existing component or the :class:`NoValue`
2363 object will be returned.
2364
2365 Returns
2366 -------
2367 : :py:class:`~pyasn1.type.base.PyAsn1Item`
2368 Instantiate |ASN.1| component type or return existing
2369 component value
2370 """
2371 if self._componentTypeLen:
2372 idx = self.componentType.getPositionByName(name)
2373 else:
2374 try:
2375 idx = self._dynamicNames.getPositionByName(name)
2376
2377 except KeyError:
2378 raise error.PyAsn1Error('Name %s not found' % (name,))
2379
2380 return self.getComponentByPosition(idx, default=default, instantiate=instantiate)
2381
2382 def setComponentByName(self, name, value=noValue,
2383 verifyConstraints=True,

Callers 5

__getitem__Method · 0.95
valueDecoderMethod · 0.80
indefLenValueDecoderMethod · 0.80

Calls 2

getPositionByNameMethod · 0.45

Tested by

no test coverage detected