/usr/lib/python2.7/dist-packages/DisplayCAL/encoding.py is in dispcalgui 3.1.0.0-1.
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 | # -*- coding: utf-8 -*-
import locale
import sys
if sys.platform == "win32":
from ctypes import windll
def get_encoding(stream):
""" Return stream encoding. """
enc = None
if stream in (sys.stdin, sys.stdout, sys.stderr):
if sys.platform == "darwin":
# There is no way to determine it reliably under OS X 10.4?
return "UTF-8"
elif sys.platform == "win32":
if sys.version_info >= (2, 6):
# Windows/Python 2.6+: If a locale is set, the actual encoding
# of stdio changes, but the encoding attribute isn't updated
enc = locale.getlocale()[1]
if not enc:
try:
# GetConsoleCP and GetConsoleOutputCP return zero if
# we're not running as console executable. Fall back
# to GetOEMCP
if stream is (sys.stdin):
enc = "cp%i" % (windll.kernel32.GetConsoleCP() or
windll.kernel32.GetOEMCP())
else:
enc = "cp%i" % (windll.kernel32.GetConsoleOutputCP() or
windll.kernel32.GetOEMCP())
except:
pass
enc = enc or getattr(stream, "encoding", None) or \
locale.getpreferredencoding() or sys.getdefaultencoding()
return enc
def get_encodings():
""" Return console encoding, filesystem encoding. """
enc = get_encoding(sys.stdout)
fs_enc = sys.getfilesystemencoding() or enc
return enc, fs_enc
|