/usr/lib64/python3.12/encodings
NameSizeModeActions
__pycache__/-0755rm
aliases.py156770644editdlrm
ascii.py12480644editdlrm
base64_codec.py15330644editdlrm
big5.py10190644editdlrm
big5hkscs.py10390644editdlrm
bz2_codec.py22490644editdlrm
charmap.py20840644editdlrm
cp037.pyc31090644editdlrm
cp273.pyc30950644editdlrm
cp424.pyc31390644editdlrm
cp437.pyc132860644editdlrm
cp500.pyc31090644editdlrm
cp720.py136860644editdlrm
cp737.pyc136880644editdlrm
cp775.pyc133260644editdlrm
cp850.pyc128670644editdlrm
cp852.pyc133420644editdlrm
cp855.pyc136550644editdlrm
cp856.pyc31710644editdlrm
cp857.pyc126680644editdlrm
cp858.py340150644editdlrm
cp860.pyc132570644editdlrm
cp861.pyc132820644editdlrm
cp862.pyc135150644editdlrm
cp863.pyc132780644editdlrm
cp864.pyc133230644editdlrm
cp865.pyc132820644editdlrm
cp866.pyc136950644editdlrm
cp869.pyc132250644editdlrm
cp874.pyc32370644editdlrm
cp875.pyc31060644editdlrm
cp932.py10230644editdlrm
cp949.py10230644editdlrm
cp950.py10230644editdlrm
cp1006.pyc31850644editdlrm
cp1026.pyc31130644editdlrm
cp1125.py345970644editdlrm
cp1140.pyc30990644editdlrm
cp1250.pyc31360644editdlrm
cp1251.pyc31330644editdlrm
cp1252.pyc31360644editdlrm
cp1253.pyc31490644editdlrm
cp1254.pyc31380644editdlrm
cp1255.pyc31570644editdlrm
cp1256.pyc31350644editdlrm
cp1257.pyc31430644editdlrm
cp1258.pyc31410644editdlrm
euc_jisx0213.py10510644editdlrm
euc_jis_2004.py10510644editdlrm
euc_jp.py10270644editdlrm
euc_kr.py10270644editdlrm
gb2312.py10270644editdlrm
gb18030.py10310644editdlrm
gbk.py10150644editdlrm
hex_codec.py15080644editdlrm
hp_roman8.pyc33100644editdlrm
hz.py10110644editdlrm
idna.py97100644editdlrm
iso2022_jp.py10530644editdlrm
iso2022_jp_1.py10610644editdlrm
iso2022_jp_2.py10610644editdlrm
iso2022_jp_3.py10610644editdlrm
iso2022_jp_2004.py10730644editdlrm
iso2022_jp_ext.py10690644editdlrm
iso2022_kr.py10530644editdlrm
iso8859_1.pyc31080644editdlrm
iso8859_2.pyc31080644editdlrm
iso8859_3.pyc31150644editdlrm
iso8859_4.pyc31080644editdlrm
iso8859_5.pyc31090644editdlrm
iso8859_6.pyc31530644editdlrm
iso8859_7.pyc31160644editdlrm
iso8859_8.pyc31470644editdlrm
iso8859_9.pyc31080644editdlrm
iso8859_10.pyc31130644editdlrm
iso8859_11.pyc32070644editdlrm
iso8859_13.pyc31160644editdlrm
iso8859_14.pyc31340644editdlrm
iso8859_15.pyc31130644editdlrm
iso8859_16.pyc31150644editdlrm
johab.py10230644editdlrm
koi8_r.pyc31600644editdlrm
koi8_t.py131930644editdlrm
koi8_u.pyc31460644editdlrm
kz1048.pyc31230644editdlrm
latin_1.py12640644editdlrm
mac_arabic.pyc131720644editdlrm
mac_croatian.pyc31550644editdlrm
mac_cyrillic.pyc31450644editdlrm
mac_farsi.pyc30890644editdlrm
mac_greek.pyc31290644editdlrm
mac_iceland.pyc31480644editdlrm
mac_latin2.pyc32890644editdlrm
mac_roman.pyc31460644editdlrm
mac_romanian.pyc31560644editdlrm
mac_turkish.pyc31490644editdlrm
mbcs.py12110644editdlrm
oem.py10190644editdlrm
palmos.py135190644editdlrm
ptcp154.pyc32300644editdlrm
punycode.py68830644editdlrm
quopri_codec.py15250644editdlrm
raw_unicode_escape.py13320644editdlrm
rot_13.py24490755editdlrm
shift_jis.py10390644editdlrm
shift_jisx0213.py10590644editdlrm
shift_jis_2004.py10590644editdlrm
tis_620.pyc31980644editdlrm
undefined.py12990644editdlrm
unicode_escape.py13040644editdlrm
utf_7.py9460644editdlrm
utf_8.py10050644editdlrm
utf_8_sig.py41330644editdlrm
utf_16.py52360644editdlrm
utf_16_be.py10370644editdlrm
utf_16_le.py10370644editdlrm
utf_32.py51290644editdlrm
utf_32_be.py9300644editdlrm
utf_32_le.py9300644editdlrm
uu_codec.py28510644editdlrm
zlib_codec.py22040644editdlrm
__init__.py58840644editdlrm
Edit: /usr/lib64/python3.12/encodings/__init__.py (5884B)
""" Standard "encodings" Package Standard Python encoding modules are stored in this package directory. Codec modules must have names corresponding to normalized encoding names as defined in the normalize_encoding() function below, e.g. 'utf-8' must be implemented by the module 'utf_8.py'. Each codec module must export the following interface: * getregentry() -> codecs.CodecInfo object The getregentry() API must return a CodecInfo object with encoder, decoder, incrementalencoder, incrementaldecoder, streamwriter and streamreader attributes which adhere to the Python Codec Interface Standard. In addition, a module may optionally also define the following APIs which are then used by the package's codec search function: * getaliases() -> sequence of encoding name strings to use as aliases Alias names returned by getaliases() must be normalized encoding names as defined by normalize_encoding(). Written by Marc-Andre Lemburg (mal@lemburg.com). (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. """#" import codecs import sys from . import aliases _cache = {} _unknown = '--unknown--' _import_tail = ['*'] _aliases = aliases.aliases class CodecRegistryError(LookupError, SystemError): pass def normalize_encoding(encoding): """ 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. Note that encoding names should be ASCII only. """ if isinstance(encoding, bytes): encoding = str(encoding, "ascii") chars = [] punct = False for c in encoding: if c.isalnum() or c == '.': if punct and chars: chars.append('_') if c.isascii(): chars.append(c) punct = False else: punct = True return ''.join(chars) def search_function(encoding): # Cache lookup entry = _cache.get(encoding, _unknown) if entry is not _unknown: return entry # Import the module: # # First try to find an alias for the normalized encoding # name and lookup the module using the aliased name, then try to # lookup the module using the standard import scheme, i.e. first # try in the encodings package, then at top-level. # norm_encoding = normalize_encoding(encoding) aliased_encoding = _aliases.get(norm_encoding) or \ _aliases.get(norm_encoding.replace('.', '_')) if aliased_encoding is not None: modnames = [aliased_encoding, norm_encoding] else: modnames = [norm_encoding] for modname in modnames: if not modname or '.' in modname: continue try: # Import is absolute to prevent the possibly malicious import of a # module with side-effects that is not in the 'encodings' package. mod = __import__('encodings.' + modname, fromlist=_import_tail, level=0) except ImportError: # ImportError may occur because 'encodings.(modname)' does not exist, # or because it imports a name that does not exist (see mbcs and oem) pass else: break else: mod = None try: getregentry = mod.getregentry except AttributeError: # Not a codec module mod = None if mod is None: # Cache misses _cache[encoding] = None return None # Now ask the module for the registry entry entry = getregentry() if not isinstance(entry, codecs.CodecInfo): if not 4 <= len(entry) <= 7: raise CodecRegistryError('module "%s" (%s) failed to register' % (mod.__name__, mod.__file__)) if not callable(entry[0]) or not callable(entry[1]) or \ (entry[2] is not None and not callable(entry[2])) or \ (entry[3] is not None and not callable(entry[3])) or \ (len(entry) > 4 and entry[4] is not None and not callable(entry[4])) or \ (len(entry) > 5 and entry[5] is not None and not callable(entry[5])): raise CodecRegistryError('incompatible codecs in module "%s" (%s)' % (mod.__name__, mod.__file__)) if len(entry)<7 or entry[6] is None: entry += (None,)*(6-len(entry)) + (mod.__name__.split(".", 1)[1],) entry = codecs.CodecInfo(*entry) # Cache the codec registry entry _cache[encoding] = entry # Register its aliases (without overwriting previously registered # aliases) try: codecaliases = mod.getaliases() except AttributeError: pass else: for alias in codecaliases: if alias not in _aliases: _aliases[alias] = modname # Return the registry entry return entry # Register the search_function in the Python codec registry codecs.register(search_function) if sys.platform == 'win32': # bpo-671666, bpo-46668: If Python does not implement a codec for current # Windows ANSI code page, use the "mbcs" codec instead: # WideCharToMultiByte() and MultiByteToWideChar() functions with CP_ACP. # Python does not support custom code pages. def _alias_mbcs(encoding): try: import _winapi ansi_code_page = "cp%s" % _winapi.GetACP() if encoding == ansi_code_page: import encodings.mbcs return encodings.mbcs.getregentry() except ImportError: # Imports may fail while we are shutting down pass codecs.register(_alias_mbcs)