Normalize an encoding name. Normalization works as follows: all non-alphanumeric characters except the dot used for Python package names are collapsed and replaced with a single underscore, e.g. ' -;#' becomes '_'. Leading and trailing underscores are removed.
(encoding)
| 43 | pass |
| 44 | |
| 45 | def normalize_encoding(encoding): |
| 46 | |
| 47 | """ Normalize an encoding name. |
| 48 | |
| 49 | Normalization works as follows: all non-alphanumeric |
| 50 | characters except the dot used for Python package names are |
| 51 | collapsed and replaced with a single underscore, e.g. ' -;#' |
| 52 | becomes '_'. Leading and trailing underscores are removed. |
| 53 | |
| 54 | Note that encoding names should be ASCII only. |
| 55 | |
| 56 | """ |
| 57 | if isinstance(encoding, bytes): |
| 58 | encoding = str(encoding, "ascii") |
| 59 | |
| 60 | if not encoding.isascii(): |
| 61 | import warnings |
| 62 | warnings.warn( |
| 63 | "Support for non-ascii encoding names will be removed in 3.17", |
| 64 | DeprecationWarning, stacklevel=2) |
| 65 | |
| 66 | return _normalize_encoding(encoding) |
| 67 | |
| 68 | def search_function(encoding): |
| 69 |
no test coverage detected
searching dependent graphs…