sys.__stdout__.encoding

Here are the examples of the python api sys.__stdout__.encoding taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

22 Examples 7

Example 1

Project: calibre
Source File: readability.py
View license
def main():
    from calibre.utils.logging import default_log
    parser = option_parser()
    options, args = parser.parse_args()

    if len(args) != 1:
        parser.print_help()
        raise SystemExit(1)

    with open(args[0], 'rb') as f:
        raw = f.read()

    enc = sys.__stdout__.encoding or 'utf-8'
    if options.verbose:
        default_log.filter_level = default_log.DEBUG
    print (Document(raw, default_log,
            debug=options.verbose,
            keep_elements=options.keep_elements).summary().encode(enc,
                'replace'))

Example 2

Project: calibre
Source File: readability.py
View license
def main():
    from calibre.utils.logging import default_log
    parser = option_parser()
    options, args = parser.parse_args()

    if len(args) != 1:
        parser.print_help()
        raise SystemExit(1)

    with open(args[0], 'rb') as f:
        raw = f.read()

    enc = sys.__stdout__.encoding or 'utf-8'
    if options.verbose:
        default_log.filter_level = default_log.DEBUG
    print (Document(raw, default_log,
            debug=options.verbose,
            keep_elements=options.keep_elements).summary().encode(enc,
                'replace'))

Example 3

Project: OpenWatch
Source File: organize_recordings.py
View license
    def write(self, string):
        ''' A wrapper for self.stdout.write to avoid problems with unicode:
            A bug in Python 2.6 results in self.stdout.write using
            'default' unicode encoding, which can be ascii. This breaks
            when the module encounters unicode characters.
            Thus we've got to wrap the call :(
            see http://stackoverflow.com/questions/8016236/python-unicode-handling-differences-between-print-and-sys-stdout-write
        '''
        if isinstance(string, unicode):
            string = string.encode(sys.__stdout__.encoding)
        sys.__stdout__.write(string)

Example 4

Project: OpenWatch
Source File: organize_recordings.py
View license
    def write(self, string):
        ''' A wrapper for self.stdout.write to avoid problems with unicode:
            A bug in Python 2.6 results in self.stdout.write using
            'default' unicode encoding, which can be ascii. This breaks
            when the module encounters unicode characters.
            Thus we've got to wrap the call :(
            see http://stackoverflow.com/questions/8016236/python-unicode-handling-differences-between-print-and-sys-stdout-write
        '''
        if isinstance(string, unicode):
            string = string.encode(sys.__stdout__.encoding)
        sys.__stdout__.write(string)

Example 5

Project: pymo
Source File: test_sys.py
View license
    def test_43581(self):
        # Can't use sys.stdout, as this is a cStringIO object when
        # the test runs under regrtest.
        self.assertTrue(sys.__stdout__.encoding == sys.__stderr__.encoding)

Example 6

Project: pip
Source File: __init__.py
View license
    def console_to_str(s):
        try:
            return s.decode(sys.__stdout__.encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')

Example 7

Project: TrustRouter
Source File: test_sys.py
View license
    def test_43581(self):
        # Can't use sys.stdout, as this is a StringIO object when
        # the test runs under regrtest.
        self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding)

Example 8

Project: brython
Source File: test_sys.py
View license
    def test_43581(self):
        # Can't use sys.stdout, as this is a StringIO object when
        # the test runs under regrtest.
        self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding)

Example 9

Project: chipsec
Source File: test_sys.py
View license
    def test_43581(self):
        # Can't use sys.stdout, as this is a cStringIO object when
        # the test runs under regrtest.
        self.assertTrue(sys.__stdout__.encoding == sys.__stderr__.encoding)

Example 10

Project: HealthStarter
Source File: __init__.py
View license
    def console_to_str(s):
        try:
            return s.decode(sys.__stdout__.encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')

Example 11

Project: pip-update-requirements
Source File: __init__.py
View license
    def console_to_str(s):
        try:
            return s.decode(sys.__stdout__.encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')

Example 12

Project: pyp2rpm
Source File: utils.py
View license
    def console_to_str(s):
        try:
            return s.decode(sys.__stdout__.encoding)
        except UnicodeDecodeError:
            return s.decode('utf-8')

Example 13

Project: datafari
Source File: __init__.py
View license
    def console_to_str(s):
        try:
            return s.decode(sys.__stdout__.encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')

Example 14

Project: datafari
Source File: test_sys.py
View license
    def test_43581(self):
        # Can't use sys.stdout, as this is a cStringIO object when
        # the test runs under regrtest.
        self.assertTrue(sys.__stdout__.encoding == sys.__stderr__.encoding)

Example 15

Project: openwrt-mt7620
Source File: test_sys.py
View license
    def test_43581(self):
        # Can't use sys.stdout, as this is a cStringIO object when
        # the test runs under regrtest.
        self.assertTrue(sys.__stdout__.encoding == sys.__stderr__.encoding)

Example 16

Project: openwrt-mt7620
Source File: test_sys.py
View license
    def test_43581(self):
        # Can't use sys.stdout, as this is a cStringIO object when
        # the test runs under regrtest.
        self.assertTrue(sys.__stdout__.encoding == sys.__stderr__.encoding)

Example 17

Project: iot-utilities
Source File: test_sys.py
View license
    def test_43581(self):
        # Can't use sys.stdout, as this is a StringIO object when
        # the test runs under regrtest.
        self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding)

Example 18

Project: iot-utilities
Source File: test_sys.py
View license
    def test_43581(self):
        # Can't use sys.stdout, as this is a StringIO object when
        # the test runs under regrtest.
        self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding)

Example 19

Project: iot-utilities
Source File: test_sys.py
View license
    def test_43581(self):
        # Can't use sys.stdout, as this is a StringIO object when
        # the test runs under regrtest.
        self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding)

Example 20

Project: iot-utilities
Source File: test_sys.py
View license
    def test_43581(self):
        # Can't use sys.stdout, as this is a StringIO object when
        # the test runs under regrtest.
        self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding)

Example 21

Project: PyAutoC
Source File: test_sys.py
View license
    def test_43581(self):
        # Can't use sys.stdout, as this is a cStringIO object when
        # the test runs under regrtest.
        self.assertTrue(sys.__stdout__.encoding == sys.__stderr__.encoding)

Example 22

Project: yadapy
Source File: __init__.py
View license
    def console_to_str(s):
        try:
            return s.decode(sys.__stdout__.encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')