This file is indexed.

/usr/lib/python3/dist-packages/postgresql/encodings/aliases.py is in python3-postgresql 1.1.0-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
##
# .encodings.aliases
##
"""
Module for mapping PostgreSQL encoding names to Python encoding names.

These are **not** installed in Python's aliases. Rather, `get_python_name`
should be used directly.

URLs of interest:
 * http://docs.python.org/library/codecs.html
 * http://git.postgresql.org/gitweb?p=postgresql.git;a=blob;f=src/backend/utils/mb/encnames.c
"""

##
#: Dictionary of Postgres encoding names to Python encoding names.
#: This mapping only contains those encoding names that do not intersect.
postgres_to_python = {
	'unicode' : 'utf_8',
	'sql_ascii' : 'ascii',
	'euc_jp' : 'eucjp',
	'euc_cn' : 'euccn',
	'euc_kr' : 'euckr',
	'shift_jis_2004' : 'euc_jis_2004',
	'sjis' : 'shift_jis',
	'alt' : 'cp866', # IBM866
	'abc' : 'cp1258',
	'vscii' : 'cp1258',
	'koi8r' : 'koi8_r',
	'koi8u' : 'koi8_u',
	'tcvn' : 'cp1258',
	'tcvn5712' : 'cp1258',
#	'euc_tw' : None, # N/A
#	'mule_internal' : None, # N/A
}

def get_python_name(encname):
	"""
	Lookup the name in the `postgres_to_python` dictionary. If no match is
	found, check for a 'win' or 'windows-' name and convert that to a 'cp###'
	name.

	Returns `None` if there is no alias for `encname`.

	The win[0-9]+ and windows-[0-9]+ entries are handled functionally.
	"""
	# check the dictionary first
	localname = postgres_to_python.get(encname)
	if localname is not None:
		return localname
	# no explicit mapping, check for functional transformation
	if encname.startswith('win'):
		# handle win#### and windows-####
		# remove the trailing CP number
		bare = encname.rstrip('0123456789')
		if bare.strip('_-') in ('win', 'windows'):
			return 'cp' + encname[len(bare):]
	return encname