@@ -0,0 +1,2957 @@
+# Copyright 2016-present Facebook, Inc.%0A# All rights reserved.%0A#%0A# Redistribution and use in source and binary forms, with or without%0A# modification, are permitted provided that the following conditions are met:%0A#%0A#  * Redistributions of source code must retain the above copyright notice,%0A#    this list of conditions and the following disclaimer.%0A#%0A#  * Redistributions in binary form must reproduce the above copyright notice,%0A#    this list of conditions and the following disclaimer in the documentation%0A#    and/or other materials provided with the distribution.%0A#%0A#  * Neither the name Facebook nor the names of its contributors may be used to%0A#    endorse or promote products derived from this software without specific%0A#    prior written permission.%0A#%0A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS %22AS IS%22%0A# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE%0A# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE%0A# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE%0A# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL%0A# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR%0A# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER%0A# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,%0A# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE%0A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%0A%0Afrom __future__ import absolute_import%0Afrom __future__ import division%0Afrom __future__ import print_function%0A# no unicode literals%0A%0A'''Module to deal with filename encoding on the local system, as returned by%0AWatchman.'''%0A%0Aimport sys%0A%0Afrom . import (%0A    compat,%0A)%0A%0Aif compat.PYTHON3:%0A    default_local_errors = 'surrogateescape'%0A%0A    def get_local_encoding():%0A        if sys.platform == 'win32':%0A            # Watchman always returns UTF-8 encoded strings on Windows.%0A            return 'utf-8'%0A        # On the Python 3 versions we support, sys.getfilesystemencoding never%0A        # returns None.%0A        return sys.getfilesystemencoding()%0Aelse:%0A    # Python 2 doesn't support surrogateescape, so use 'strict' by%0A    # default. Users can register a custom surrogateescape error handler and use%0A    # that if they so desire.%0A    default_local_errors = 'strict'%0A%0A    def get_local_encoding():%0A        if sys.platform == 'win32':%0A            # Watchman always returns UTF-8 encoded strings on Windows.%0A            return 'utf-8'%0A        fsencoding = sys.getfilesystemencoding()%0A        if fsencoding is None:%0A            # This is very unlikely to happen, but if it does, just use UTF-8%0A            fsencoding = 'utf-8'%0A        return fsencoding%0A%0Adef encode_local(s):%0A    return s.encode(get_local_encoding(), default_local_errors)%0A%0Adef decode_local(bs):%0A    return bs.decode(get_local_encoding(), default_local_errors)%0A

add an encoding module