def decode(self, encoding='utf-8', errors='strict'): """ Returns a newstr (i.e. unicode subclass) Decode B using the codec registered for encoding. Default encoding is 'utf-8'. errors may be given to set a different error handling scheme. Default is 'strict' meaning that encoding errors raise a UnicodeDecodeError. Other possible values are 'ignore' and 'replace' as well as any other name registered with codecs.register_error that is able to handle UnicodeDecodeErrors. """ # Py2 str.encode() takes encoding and errors as optional parameter, # not keyword arguments as in Python 3 str. from future.types.newstr import newstr if errors == 'surrogateescape': from future.utils.surrogateescape import register_surrogateescape register_surrogateescape() return newstr(super(newbytes, self).decode(encoding, errors))
def decode(self, encoding='utf-8', errors='strict'): """ Returns a newstr (i.e. unicode subclass) Decode B using the codec registered for encoding. Default encoding is 'utf-8'. errors may be given to set a different error handling scheme. Default is 'strict' meaning that encoding errors raise a UnicodeDecodeError. Other possible values are 'ignore' and 'replace' as well as any other name registered with codecs.register_error that is able to handle UnicodeDecodeErrors. """ # Py2 str.encode() takes encoding and errors as optional parameter, # not keyword arguments as in Python 3 str. from future.types.newstr import newstr if errors == 'surrogateescape': from future.utils.surrogateescape import register_surrogateescape register_surrogateescape() return newstr(super(newbytes, self).decode(encoding, errors))
def main(): """Main function""" register_surrogateescape() script_name = os.path.basename(__file__)[:-3] parser = argparse.ArgumentParser( description='Execute repositories') parser.add_argument('-v', '--verbose', type=int, default=config.VERBOSE, help='increase output verbosity') parser.add_argument('-e', '--retry-errors', action='store_true', help='retry errors') parser.add_argument('-i', '--interval', type=int, nargs=2, default=config.REPOSITORY_INTERVAL, help='repository id interval') parser.add_argument('-c', '--count', action='store_true', help='count results') parser.add_argument('-r', '--reverse', action='store_true', help='iterate in reverse order') parser.add_argument('--check', type=str, nargs='*', default={'all', script_name, script_name + '.py'}, help='check name in .exit') args = parser.parse_args() config.VERBOSE = args.verbose status = None if not args.count: status = StatusLogger(script_name) status.report() with connect() as session, savepid(): apply( session, status, 0 if args.retry_errors else consts.R_COMPRESS_ERROR, args.count, args.interval, args.reverse, set(args.check) )
# Copyright 2015 by Ecpy Authors, see AUTHORS for more details. # # Distributed under the terms of the BSD license. # # The full license is in the file LICENCE, distributed with this software. # ----------------------------------------------------------------------------- """Utility functions to generate well behaved tracebacks """ from __future__ import (division, unicode_literals, print_function, absolute_import) import sys from future.utils.surrogateescape import register_surrogateescape register_surrogateescape() if sys.version_info >= (3, ): from traceback import format_exc, format_tb else: # Returns a single string def format_exc(): """Format and decode the current traceback in a safe way. """ from traceback import format_exc return format_exc().decode('utf-8', 'surrogateescape') # Returns a list of strings def format_tb(tb): """Format and decode a traceback in a safe way.
def setUp(self): register_surrogateescape()
# Author: Barry Warsaw # Contact: [email protected] """ Backport of the Python 3.3 email package for Python-Future. A package for parsing, handling, and generating email messages. """ from __future__ import absolute_import from __future__ import division from __future__ import unicode_literals # Install the surrogate escape handler here because this is used by many # modules in the email package. from future.utils import surrogateescape surrogateescape.register_surrogateescape() # (Should this be done globally by ``future``?) __version__ = '5.1.0' __all__ = [ 'base64mime', 'charset', 'encoders', 'errors', 'feedparser', 'generator', 'header', 'iterators', 'message', 'message_from_file',
fsdecode (new in Python 3.2) Backport modifications are marked with "XXX backport" and "TODO backport". """ from __future__ import unicode_literals import sys # XXX backport: unicode on Python 2 _str = unicode if sys.version_info < (3,) else str # XXX backport: Use backported surrogateescape for Python 2 # TODO backport: Find a way to do this without pulling in the entire future package? if sys.version_info < (3,): from future.utils.surrogateescape import register_surrogateescape register_surrogateescape() # XXX backport: This invalid_utf8_indexes() helper is shamelessly copied from # Bob Ippolito's pyutf8 package (pyutf8/ref.py), in order to help support the # Python 2 UTF-8 decoding hack in fsdecode() below. # # URL: https://github.com/etrepum/pyutf8/blob/master/pyutf8/ref.py # def _invalid_utf8_indexes(bytes): skips = [] i = 0 len_bytes = len(bytes) while i < len_bytes: c1 = bytes[i] if c1 < 0x80:
# Contact: [email protected] """ Backport of the Python 3.3 email package for Python-Future. A package for parsing, handling, and generating email messages. """ from __future__ import unicode_literals from __future__ import division from __future__ import absolute_import # Install the surrogate escape handler here because this is used by many # modules in the email package. from future.utils import surrogateescape surrogateescape.register_surrogateescape() # (Should this be done globally by ``future``?) __version__ = "5.1.0" __all__ = [ "base64mime", "charset", "encoders", "errors", "feedparser", "generator", "header", "iterators", "message",
def setUp(self): register_surrogateescape()
def main(): """Main function""" register_surrogateescape() script_name = os.path.basename(__file__)[:-3] parser = argparse.ArgumentParser(description='Execute repositories') parser.add_argument('-v', '--verbose', type=int, default=config.VERBOSE, help='increase output verbosity') parser.add_argument("-n", "--notebooks", type=int, default=None, nargs="*", help="notebooks ids") parser.add_argument('-e', '--retry-errors', action='store_true', help='retry errors') parser.add_argument('-s', '--retry-syntaxerrors', action='store_true', help='retry syntax errors') parser.add_argument('-t', '--retry-timeout', action='store_true', help='retry timeout') parser.add_argument('-i', '--interval', type=int, nargs=2, default=config.REPOSITORY_INTERVAL, help='repository id interval') parser.add_argument('-c', '--count', action='store_true', help='count results') parser.add_argument('-r', '--reverse', action='store_true', help='iterate in reverse order') parser.add_argument('--check', type=str, nargs='*', default={'all', script_name, script_name + '.py'}, help='check name in .exit') args = parser.parse_args() config.VERBOSE = args.verbose status = None if not args.count: status = StatusLogger(script_name) status.report() dispatches = set() with savepid(): with connect() as session: apply(SafeSession(session), status, dispatches, args.notebooks or True, 0 if args.retry_errors else consts.C_PROCESS_ERROR, 0 if args.retry_syntaxerrors else consts.C_SYNTAX_ERROR, 0 if args.retry_timeout else consts.C_TIMEOUT, args.count, args.interval, args.reverse, set(args.check)) pos_apply(dispatches, args.retry_errors, args.retry_timeout, args.verbose)
# Copyright (c) 2013-2021 NASK. All rights reserved. import os.path as osp _ABS_PATH = [osp.abspath(osp.dirname(p)) for p in __path__] from future import standard_library #3-- from future.utils.surrogateescape import register_surrogateescape #3-- standard_library.install_aliases() #3-- register_surrogateescape() #3-- #3-- import re #3-- if not hasattr(re, 'ASCII'): #3-- re.ASCII = 0 #3-- from n6sdk.encoding_helpers import provide_custom_unicode_error_handlers provide_custom_unicode_error_handlers()