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