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

Method setComponentByName

pager_lib/pyasn1/type/univ.py:2382–2426  ·  view source on GitHub ↗

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

(self, name, value=noValue,
                           verifyConstraints=True,
                           matchTags=True,
                           matchConstraints=True)

Source from the content-addressed store, hash-verified

2380 return self.getComponentByPosition(idx, default=default, instantiate=instantiate)
2381
2382 def setComponentByName(self, name, value=noValue,
2383 verifyConstraints=True,
2384 matchTags=True,
2385 matchConstraints=True):
2386 """Assign |ASN.1| type component by name.
2387
2388 Equivalent to Python :class:`dict` item assignment operation (e.g. `[]`).
2389
2390 Parameters
2391 ----------
2392 name: :class:`str`
2393 |ASN.1| type component name
2394
2395 Keyword Args
2396 ------------
2397 value: :class:`object` or :py:class:`~pyasn1.type.base.PyAsn1Item` derivative
2398 A Python value to initialize |ASN.1| component with (if *componentType* is set)
2399 or ASN.1 value object to assign to |ASN.1| component.
2400 If `value` is not given, schema object will be set as a component.
2401
2402 verifyConstraints: :class:`bool`
2403 If :obj:`False`, skip constraints validation
2404
2405 matchTags: :class:`bool`
2406 If :obj:`False`, skip component tags matching
2407
2408 matchConstraints: :class:`bool`
2409 If :obj:`False`, skip component constraints matching
2410
2411 Returns
2412 -------
2413 self
2414 """
2415 if self._componentTypeLen:
2416 idx = self.componentType.getPositionByName(name)
2417 else:
2418 try:
2419 idx = self._dynamicNames.getPositionByName(name)
2420
2421 except KeyError:
2422 raise error.PyAsn1Error('Name %s not found' % (name,))
2423
2424 return self.setComponentByPosition(
2425 idx, value, verifyConstraints, matchTags, matchConstraints
2426 )
2427
2428 def getComponentByPosition(self, idx, default=noValue, instantiate=True):
2429 """Returns |ASN.1| type component by index.

Callers 3

__setitem__Method · 0.95
generateAuthSecurityBlobFunction · 0.80

Calls 2

getPositionByNameMethod · 0.45

Tested by

no test coverage detected