Find the best converter for a given string, and return the result. The supplied string `value` is converted by testing different converters in order. First the `func` method of the `StringConverter` instance is tried, if this fails other available converters
(self, value)
| 724 | self.default = default |
| 725 | |
| 726 | def upgrade(self, value): |
| 727 | """ |
| 728 | Find the best converter for a given string, and return the result. |
| 729 | |
| 730 | The supplied string `value` is converted by testing different |
| 731 | converters in order. First the `func` method of the |
| 732 | `StringConverter` instance is tried, if this fails other available |
| 733 | converters are tried. The order in which these other converters |
| 734 | are tried is determined by the `_status` attribute of the instance. |
| 735 | |
| 736 | Parameters |
| 737 | ---------- |
| 738 | value : str |
| 739 | The string to convert. |
| 740 | |
| 741 | Returns |
| 742 | ------- |
| 743 | out : any |
| 744 | The result of converting `value` with the appropriate converter. |
| 745 | |
| 746 | """ |
| 747 | self._checked = True |
| 748 | try: |
| 749 | return self._strict_call(value) |
| 750 | except ValueError: |
| 751 | self._do_upgrade() |
| 752 | return self.upgrade(value) |
| 753 | |
| 754 | def iterupgrade(self, value): |
| 755 | self._checked = True |