Assign |ASN.1| type component by position. Equivalent to Python sequence item assignment operation (e.g. `[]`). Parameters ---------- idx : :class:`int` Component index (zero-based). Must either refer to existing component (if *componentType*
(self, idx, value=noValue,
verifyConstraints=True,
matchTags=True,
matchConstraints=True)
| 2520 | return default |
| 2521 | |
| 2522 | def setComponentByPosition(self, idx, value=noValue, |
| 2523 | verifyConstraints=True, |
| 2524 | matchTags=True, |
| 2525 | matchConstraints=True): |
| 2526 | """Assign |ASN.1| type component by position. |
| 2527 | |
| 2528 | Equivalent to Python sequence item assignment operation (e.g. `[]`). |
| 2529 | |
| 2530 | Parameters |
| 2531 | ---------- |
| 2532 | idx : :class:`int` |
| 2533 | Component index (zero-based). Must either refer to existing |
| 2534 | component (if *componentType* is set) or to N+1 component |
| 2535 | otherwise. In the latter case a new component of given ASN.1 |
| 2536 | type gets instantiated and appended to |ASN.1| sequence. |
| 2537 | |
| 2538 | Keyword Args |
| 2539 | ------------ |
| 2540 | value: :class:`object` or :py:class:`~pyasn1.type.base.PyAsn1Item` derivative |
| 2541 | A Python value to initialize |ASN.1| component with (if *componentType* is set) |
| 2542 | or ASN.1 value object to assign to |ASN.1| component. |
| 2543 | If `value` is not given, schema object will be set as a component. |
| 2544 | |
| 2545 | verifyConstraints : :class:`bool` |
| 2546 | If :obj:`False`, skip constraints validation |
| 2547 | |
| 2548 | matchTags: :class:`bool` |
| 2549 | If :obj:`False`, skip component tags matching |
| 2550 | |
| 2551 | matchConstraints: :class:`bool` |
| 2552 | If :obj:`False`, skip component constraints matching |
| 2553 | |
| 2554 | Returns |
| 2555 | ------- |
| 2556 | self |
| 2557 | """ |
| 2558 | componentType = self.componentType |
| 2559 | componentTypeLen = self._componentTypeLen |
| 2560 | |
| 2561 | if self._componentValues is noValue: |
| 2562 | componentValues = [] |
| 2563 | |
| 2564 | else: |
| 2565 | componentValues = self._componentValues |
| 2566 | |
| 2567 | try: |
| 2568 | currentValue = componentValues[idx] |
| 2569 | |
| 2570 | except IndexError: |
| 2571 | currentValue = noValue |
| 2572 | if componentTypeLen: |
| 2573 | if componentTypeLen < idx: |
| 2574 | raise error.PyAsn1Error('component index out of range') |
| 2575 | |
| 2576 | componentValues = [noValue] * componentTypeLen |
| 2577 | |
| 2578 | if value is noValue: |
| 2579 | if componentTypeLen: |
no test coverage detected