| 671 | |
| 672 | |
| 673 | class Parameter(TokenList): |
| 674 | |
| 675 | token_type = 'parameter' |
| 676 | sectioned = False |
| 677 | extended = False |
| 678 | charset = 'us-ascii' |
| 679 | |
| 680 | @property |
| 681 | def section_number(self): |
| 682 | # Because the first token, the attribute (name) eats CFWS, the second |
| 683 | # token is always the section if there is one. |
| 684 | return self[1].number if self.sectioned else 0 |
| 685 | |
| 686 | @property |
| 687 | def param_value(self): |
| 688 | # This is part of the "handle quoted extended parameters" hack. |
| 689 | for token in self: |
| 690 | if token.token_type == 'value': |
| 691 | return token.stripped_value |
| 692 | if token.token_type == 'quoted-string': |
| 693 | for token in token: |
| 694 | if token.token_type == 'bare-quoted-string': |
| 695 | for token in token: |
| 696 | if token.token_type == 'value': |
| 697 | return token.stripped_value |
| 698 | return '' |
| 699 | |
| 700 | |
| 701 | class InvalidParameter(Parameter): |