|
| 1 | +############################################################################### |
| 2 | +# |
| 3 | +# ReturnCodes - A class for XlsxWriter return codes. |
| 4 | +# |
| 5 | +# SPDX-License-Identifier: BSD-2-Clause |
| 6 | +# Copyright 2013-2022, John McNamara, jmcnamara@cpan.org |
| 7 | +# |
| 8 | + |
| 9 | +from enum import Enum |
| 10 | + |
| 11 | + |
| 12 | +class ReturnCode(str, Enum): |
| 13 | + """Return codes enumeration for XlsxWriter functions |
| 14 | +
|
| 15 | + These values can be converted to string in different ways: |
| 16 | + - direct assignment: mystr = retcode |
| 17 | + - through format function: mystr = "Value {0}".format(retcode) |
| 18 | + - through f-string: mystr = f'Value {retcode}' |
| 19 | +
|
| 20 | + Conversion through str() function will result in the internal Enum |
| 21 | + representation, i.e. str(ReturnCode.XW_NO_ERROR) will return |
| 22 | + "ReturnCode.XW_NO_ERROR" |
| 23 | + """ |
| 24 | + |
| 25 | + # Note: the following are not tuples, but strings on multiple lines |
| 26 | + # This is required to be compliant to E501 |
| 27 | + |
| 28 | + ########################################################################### |
| 29 | + # |
| 30 | + # Values from libxlsxwriter library |
| 31 | + # |
| 32 | + ########################################################################### |
| 33 | + |
| 34 | + XW_NO_ERROR = "No error" |
| 35 | + XW_ERROR_MAX_STRING_LENGTH_EXCEEDED = ("String exceeds Excel's limit of " |
| 36 | + "32,767 characters") |
| 37 | + XW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE = ("Worksheet row or column index " |
| 38 | + "out of range") |
| 39 | + XW_ERROR_WORKSHEET_MAX_URL_LENGTH_EXCEEDED = ("Maximum hyperlink length " |
| 40 | + "(2079) exceeded") |
| 41 | + XW_ERROR_WORKSHEET_MAX_NUMBER_URLS_EXCEEDED = ("Maximum number of " |
| 42 | + "worksheet URLs (65530) " |
| 43 | + "exceeded") |
| 44 | + |
| 45 | + ########################################################################### |
| 46 | + # |
| 47 | + # Values added only for this library |
| 48 | + # |
| 49 | + ########################################################################### |
| 50 | + |
| 51 | + XW_ERROR_VBA_FILE_NOT_FOUND = "VBA project binary file not found" |
| 52 | + XW_ERROR_FORMULA_CANT_BE_NONE_OR_EMPTY = "Formula can't be None or empty" |
| 53 | + XW_ERROR_2_CONSECUTIVE_FORMATS = "2 consecutive formats used" |
| 54 | + XW_ERROR_EMPTY_STRING_USED = "Empty string used" |
| 55 | + XW_ERROR_INSUFFICIENT_PARAMETERS = "Insufficient parameters" |
| 56 | + XW_ERROR_IMAGE_FILE_NOT_FOUND = "Image file not found" |
| 57 | + XW_ERROR_INCORRECT_PARAMETER_OR_OPTION = "Incorrect parameter or option" |
| 58 | + XW_ERROR_NOT_SUPPORTED_COSTANT_MEMORY = ("Not supported in " |
| 59 | + "constant_memory mode") |
0 commit comments