sys.getfilesystemencoding

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

499 Examples 7

3 Source : glob.py
with Apache License 2.0
from 1020528175

def glob1(dirname, pattern):
    if not dirname:
        dirname = os.curdir
    if isinstance(pattern, _unicode) and not isinstance(dirname, unicode):
        dirname = unicode(dirname, sys.getfilesystemencoding() or
                                   sys.getdefaultencoding())
    try:
        names = os.listdir(dirname)
    except os.error:
        return []
    if pattern[0] != '.':
        names = filter(lambda x: x[0] != '.', names)
    return fnmatch.filter(names, pattern)

def glob0(dirname, basename):

3 Source : test_archive_util.py
with GNU General Public License v3.0
from adityaprakash-bobby

def can_fs_encode(filename):
    """
    Return True if the filename can be saved in the file system.
    """
    if os.path.supports_unicode_filenames:
        return True
    try:
        filename.encode(sys.getfilesystemencoding())
    except UnicodeEncodeError:
        return False
    return True


class ArchiveUtilTestCase(support.TempdirManager,

3 Source : test_fileinput.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_unicode_filenames(self):
        try:
            t1 = writeTmp(1, ["A\nB"])
            encoding = sys.getfilesystemencoding()
            if encoding is None:
                encoding = 'ascii'
            fi = FileInput(files=unicode(t1, encoding))
            lines = list(fi)
            self.assertEqual(lines, ["A\n", "B"])
        finally:
            remove_tempfiles(t1)

    def test_fileno(self):

3 Source : test_imghdr.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_data(self):
        for filename, expected in TEST_FILES:
            filename = findfile(filename, subdir='imghdrdata')
            self.assertEqual(imghdr.what(filename), expected)
            ufilename = filename.decode(sys.getfilesystemencoding())
            self.assertEqual(imghdr.what(ufilename), expected)
            with open(filename, 'rb') as stream:
                self.assertEqual(imghdr.what(stream), expected)
            with open(filename, 'rb') as stream:
                data = stream.read()
            self.assertEqual(imghdr.what(None, data), expected)

    def test_register_test(self):

3 Source : test_pep277.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def _apply_failure(self, fn, filename, expected_exception,
                       check_fn_in_exception = True):
        with self.assertRaises(expected_exception) as c:
            fn(filename)
        exc_filename = c.exception.filename
        # the "filename" exception attribute may be encoded
        if isinstance(exc_filename, str):
            filename = filename.encode(sys.getfilesystemencoding())
        if check_fn_in_exception:
            self.assertEqual(exc_filename, filename, "Function '%s(%r) failed "
                             "with bad filename in the exception: %r" %
                             (fn.__name__, filename, exc_filename))

    def test_failures(self):

3 Source : test_pep277.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_listdir(self):
        sf0 = set(self.files)
        f1 = os.listdir(test_support.TESTFN)
        f2 = os.listdir(unicode(test_support.TESTFN,
                                sys.getfilesystemencoding()))
        sf2 = set(os.path.join(unicode(test_support.TESTFN), f) for f in f2)
        self.assertEqual(sf0, sf2)
        self.assertEqual(len(f1), len(f2))

    def test_rename(self):

3 Source : test_posixpath.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_expandvars_nonascii_word(self):
        encoding = sys.getfilesystemencoding()
        # Non-ASCII word characters
        letters = test_support.u(r'\xe6\u0130\u0141\u03c6\u041a\u05d0\u062a\u0e01')
        uwnonascii = letters.encode(encoding, 'ignore').decode(encoding)[:3]
        swnonascii = uwnonascii.encode(encoding)
        if not swnonascii:
            self.skipTest('Needs non-ASCII word characters')
        with test_support.EnvironmentVarGuard() as env:
            env.clear()
            env[swnonascii] = 'baz' + swnonascii
            self.assertEqual(posixpath.expandvars(u'$%s bar' % uwnonascii),
                             u'baz%s bar' % uwnonascii)


class PosixCommonTest(test_genericpath.CommonTest):

3 Source : test_tarfile.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_issue13639(self):
        try:
            with tarfile.open(unicode(tmpname, sys.getfilesystemencoding()), self.mode):
                pass
        except UnicodeDecodeError:
            self.fail("_Stream failed to write unicode filename")


class GNUWriteTest(unittest.TestCase):

3 Source : test_warnings.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_formatwarning_unicode_msg_nonascii_filename(self):
        message = u"msg"
        category = Warning
        unicode_file_name = test_support.FS_NONASCII + u'.py'
        file_name = unicode_file_name.encode(sys.getfilesystemencoding())
        line_num = 3
        file_line = 'spam'
        format = "%s:%s: %s: %s\n  %s\n"
        expect = format % (file_name, line_num, category.__name__, str(message),
                            file_line)
        self.assertEqual(expect, self.module.formatwarning(message,
                                    category, file_name, line_num, file_line))
        message = u"\xb5sg"
        expect = format % (unicode_file_name, line_num, category.__name__, message,
                            file_line)
        self.assertEqual(expect, self.module.formatwarning(message,
                                    category, file_name, line_num, file_line))

    @test_support.requires_unicode

3 Source : libpython.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def os_fsencode(filename):
        if not isinstance(filename, unicode):
            return filename
        encoding = sys.getfilesystemencoding()
        if encoding == 'mbcs':
            # mbcs doesn't support surrogateescape
            return filename.encode(encoding)
        encoded = []
        for char in filename:
            # surrogateescape error handler
            if 0xDC80   <  = ord(char)  < = 0xDCFF:
                byte = chr(ord(char) - 0xDC00)
            else:
                byte = char.encode(encoding)
            encoded.append(byte)
        return ''.join(encoded)

class StringTruncated(RuntimeError):

3 Source : Utils.py
with GNU General Public License v3.0
from adityaprakash-bobby

def decode_filename(filename):
    if isinstance(filename, bytes):
        try:
            filename_encoding = sys.getfilesystemencoding()
            if filename_encoding is None:
                filename_encoding = sys.getdefaultencoding()
            filename = filename.decode(filename_encoding)
        except UnicodeDecodeError:
            pass
    return filename

# support for source file encoding detection

_match_file_encoding = re.compile(u"coding[:=]\s*([-\w.]+)").search

3 Source : req_install.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def setup_py(self):
        assert self.source_dir, "No source dir for %s" % self

        setup_py = os.path.join(self.setup_py_dir, 'setup.py')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py

    @property

3 Source : req_install.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def pyproject_toml(self):
        assert self.source_dir, "No source dir for %s" % self

        pp_toml = os.path.join(self.setup_py_dir, 'pyproject.toml')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(pp_toml, six.text_type):
            pp_toml = pp_toml.encode(sys.getfilesystemencoding())

        return pp_toml

    def get_pep_518_info(self):

3 Source : wheel.py
with GNU General Public License v3.0
from adityaprakash-bobby

def fix_script(path):
    """Replace #!python with #!/path/to/python
    Return True if file was changed."""
    # XXX RECORD hashes will need to be updated
    if os.path.isfile(path):
        with open(path, 'rb') as script:
            firstline = script.readline()
            if not firstline.startswith(b'#!python'):
                return False
            exename = sys.executable.encode(sys.getfilesystemencoding())
            firstline = b'#!' + exename + os.linesep.encode("ascii")
            rest = script.read()
        with open(path, 'wb') as script:
            script.write(firstline)
            script.write(rest)
        return True


dist_info_re = re.compile(r"""^(?P  <  namever>(?P < name>.+?)(-(?P < ver>.+?))?)

3 Source : misc.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def fsencode(filename):
        if isinstance(filename, bytes):
            return filename
        elif isinstance(filename, str):
            return filename.encode(sys.getfilesystemencoding())
        else:
            raise TypeError("expect bytes or str, not %s" %
                            type(filename).__name__)

3 Source : distro.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def _lsb_release_info(self):
        """
        Get the information items from the lsb_release command output.

        Returns:
            A dictionary containing all information items.
        """
        if not self.include_lsb:
            return {}
        with open(os.devnull, 'w') as devnull:
            try:
                cmd = ('lsb_release', '-a')
                stdout = subprocess.check_output(cmd, stderr=devnull)
            except OSError:  # Command not found
                return {}
        content = stdout.decode(sys.getfilesystemencoding()).splitlines()
        return self._parse_lsb_release_content(content)

    @staticmethod

3 Source : pyproject.py
with GNU General Public License v3.0
from agajdosi

def make_pyproject_path(setup_py_dir):
    # type: (str) -> str
    path = os.path.join(setup_py_dir, 'pyproject.toml')

    # Python2 __file__ should not be unicode
    if six.PY2 and isinstance(path, six.text_type):
        path = path.encode(sys.getfilesystemencoding())

    return path


def load_pyproject_toml(

3 Source : req_install.py
with GNU General Public License v3.0
from agajdosi

    def setup_py(self):
        # type: () -> str
        assert self.source_dir, "No source dir for %s" % self

        setup_py = os.path.join(self.setup_py_dir, 'setup.py')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py

    @property

3 Source : distro.py
with GNU General Public License v3.0
from agajdosi

    def _uname_info(self):
        with open(os.devnull, 'w') as devnull:
            try:
                cmd = ('uname', '-rs')
                stdout = subprocess.check_output(cmd, stderr=devnull)
            except OSError:
                return {}
        content = stdout.decode(sys.getfilesystemencoding()).splitlines()
        return self._parse_uname_content(content)

    @staticmethod

3 Source : wheel.py
with MIT License
from AgenteDog

def fix_script(path):
    """Replace #!python with #!/path/to/python
    Return True if file was changed."""
    # XXX RECORD hashes will need to be updated
    if os.path.isfile(path):
        with open(path, 'rb') as script:
            firstline = script.readline()
            if not firstline.startswith(b'#!python'):
                return False
            exename = sys.executable.encode(sys.getfilesystemencoding())
            firstline = b'#!' + exename + os.linesep.encode("ascii")
            rest = script.read()
        with open(path, 'wb') as script:
            script.write(firstline)
            script.write(rest)
        return True

dist_info_re = re.compile(r"""^(?P  <  namever>(?P < name>.+?)(-(?P < ver>\d.+?))?)

3 Source : _utils.py
with MIT License
from AgenteDog

    def _get_win32_short_name(s):
        """ Returns short name """
        buf_size = MAX_PATH
        for i in range(2):
            buf = create_unicode_buffer(u('\0') * (buf_size + 1))
            r = GetShortPathNameW(u_fs(s), buf, buf_size)
            if r == 0:
                raise WinError()
            if r   <   buf_size:
                if PY_2:
                    return buf.value.encode(sys.getfilesystemencoding())
                return buf.value
            buf_size = r
        raise WinError()

    def _get_win32_long_name(s):

3 Source : _utils.py
with MIT License
from AgenteDog

    def _get_win32_long_name(s):
        """ Returns long name """
        buf_size = MAX_PATH
        for i in range(2):
            buf = create_unicode_buffer(u('\0') * (buf_size + 1))
            r = GetLongPathNameW(u_fs(s), buf, buf_size)
            if r == 0:
                raise WinError()
            if r   <   buf_size:
                if PY_2:
                    return buf.value.encode(sys.getfilesystemencoding())
                return buf.value
            buf_size = r
        raise WinError()

    def _get_win32_case_sensitive_name(s):

3 Source : pyproject.py
with MIT License
from Air-999

def make_pyproject_path(unpacked_source_directory):
    # type: (str) -> str
    path = os.path.join(unpacked_source_directory, 'pyproject.toml')

    # Python2 __file__ should not be unicode
    if six.PY2 and isinstance(path, six.text_type):
        path = path.encode(sys.getfilesystemencoding())

    return path


BuildSystemDetails = namedtuple('BuildSystemDetails', [

3 Source : req_install.py
with MIT License
from Air-999

    def setup_py_path(self):
        # type: () -> str
        assert self.source_dir, "No source dir for {}".format(self)
        setup_py = os.path.join(self.unpacked_source_directory, 'setup.py')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py

    @property

3 Source : distro.py
with MIT License
from Air-999

    def _to_str(text):
        encoding = sys.getfilesystemencoding()
        encoding = 'utf-8' if encoding == 'ascii' else encoding

        if sys.version_info[0] >= 3:
            if isinstance(text, bytes):
                return text.decode(encoding)
        else:
            if isinstance(text, unicode):  # noqa
                return text.encode(encoding)

        return text

    @cached_property

3 Source : cv.py
with Apache License 2.0
from AirtestProject

def imread(filename):
    """根据图片路径,将图片读取为cv2的图片处理格式."""
    if not os.path.isfile(filename):
        raise RuntimeError("File not exist: %s" % filename)
    if PY3:
        stream = open(filename, "rb")
        bytes = bytearray(stream.read())
        numpyarray = np.asarray(bytes, dtype=np.uint8)
        img = cv2.imdecode(numpyarray, cv2.IMREAD_UNCHANGED)
    else:
        filename = filename.encode(sys.getfilesystemencoding())
        img = cv2.imread(filename, 1)
    return img


def imwrite(filename, img):

3 Source : cv.py
with Apache License 2.0
from AirtestProject

def imwrite(filename, img):
    """写出图片到本地路径"""
    if PY3:
        cv2.imencode('.jpg', img)[1].tofile(filename)
    else:
        filename = filename.encode(sys.getfilesystemencoding())
        cv2.imwrite(filename, img)


def rotate(img, angle=90, clockwise=True):

3 Source : snippet.py
with Apache License 2.0
from AirtestProject

def get_std_encoding(stream):
    """
    Get encoding of the stream

    Args:
        stream: stream

    Returns:
        encoding or file system encoding

    """
    return getattr(stream, "encoding", None) or sys.getfilesystemencoding()


CLEANUP_CALLS = queue.Queue()

3 Source : req_install.py
with MIT License
from alexander-marquardt

    def setup_py_path(self):
        # type: () -> str
        assert self.source_dir, "No source dir for %s" % self

        setup_py = os.path.join(self.setup_py_dir, 'setup.py')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py

    @property

3 Source : distro.py
with MIT License
from ali5h

    def _to_str(text):
        # type: (Union[bytes, str]) -> str
        encoding = sys.getfilesystemencoding()
        encoding = "utf-8" if encoding == "ascii" else encoding

        if sys.version_info[0] >= 3:
            if isinstance(text, bytes):
                return text.decode(encoding)
        else:
            if isinstance(text, unicode):  # noqa
                return text.encode(encoding)

        return text

    @cached_property

3 Source : configloader.py
with Apache License 2.0
from almeidaw

def _unicode_path(path):
    if isinstance(path, six.text_type):
        return path
    # According to the documentation getfilesystemencoding can return None
    # on unix in which case the default encoding is used instead.
    filesystem_encoding = sys.getfilesystemencoding()
    if filesystem_encoding is None:
        filesystem_encoding = sys.getdefaultencoding()
    return path.decode(filesystem_encoding, 'replace')


def _parse_nested(config_value):

3 Source : dviread.py
with MIT License
from alvarobartt

    def __init__(self, filename):
        self._font = {}
        self._filename = filename
        if six.PY3 and isinstance(filename, bytes):
            encoding = sys.getfilesystemencoding() or 'utf-8'
            self._filename = filename.decode(encoding, errors='replace')
        with open(filename, 'rb') as file:
            self._parse(file)

    def __getitem__(self, texname):

3 Source : __init__.py
with MIT License
from alvarobartt

def _decode_filesystem_path(path):
    if not isinstance(path, str):
        return path.decode(sys.getfilesystemencoding())
    else:
        return path


def _get_data_path():

3 Source : backports.py
with MIT License
from alvarobartt

        def replace(src, dst):
            if not isinstance(src, unicode):  # noqa
                src = unicode(src, sys.getfilesystemencoding())  # noqa
            if not isinstance(dst, unicode):  # noqa
                dst = unicode(dst, sys.getfilesystemencoding())  # noqa

            movefile_replace_existing = 0x1
            return_value = ctypes.windll.kernel32.MoveFileExW(
                src, dst, movefile_replace_existing)
            if return_value == 0:
                raise ctypes.WinError()

    def concurrency_safe_rename(src, dst):

3 Source : subcommands.py
with MIT License
from amiracle

    def _convert_path_args(self, parsed_args):
        if not isinstance(parsed_args.paths, list):
            parsed_args.paths = [parsed_args.paths]
        for i in range(len(parsed_args.paths)):
            path = parsed_args.paths[i]
            if isinstance(path, six.binary_type):
                dec_path = path.decode(sys.getfilesystemencoding())
                enc_path = dec_path.encode('utf-8')
                new_path = enc_path.decode('utf-8')
                parsed_args.paths[i] = new_path


class CpCommand(S3TransferCommand):

3 Source : surfaces.py
with MIT License
from Amirh24

def _encode_filename(filename):
    """Return a byte string, encoding Unicode with the filesystem encoding."""
    if not isinstance(filename, bytes):
        filename = filename.encode(sys.getfilesystemencoding())
    return ffi.new('char[]', filename)


def from_buffer(obj):

3 Source : compat.py
with MIT License
from ankitgoyal0301

def to_env(text):
    # type: (Text) -> str
    """
    Encode a string the same way whether it comes from the environment or a `.env` file.
    """
    if PY2:
        return text.encode(sys.getfilesystemencoding() or "utf-8")
    else:
        return text


def to_text(string):

3 Source : font_manager.py
with GNU General Public License v3.0
from Artikash

    def fc_match(pattern, fontext):
        fontexts = get_fontext_synonyms(fontext)
        ext = "." + fontext
        try:
            pipe = subprocess.Popen(['fc-match', '-sv', pattern], stdout=subprocess.PIPE)
            output = pipe.communicate()[0]
        except OSError, IOError:
            return None
        if pipe.returncode == 0:
            for match in _fc_match_regex.finditer(output):
                file = match.group(1)
                file = file.decode(sys.getfilesystemencoding())
                if os.path.splitext(file)[1][1:] in fontexts:
                    return file
        return None

    _fc_match_regex = re.compile(br'\sfile:\s+"([^"]*)"')

3 Source : utils.py
with GNU General Public License v3.0
from Artikash

def get_filesystem_encoding():
    encoding = sys.getfilesystemencoding()
    return encoding if encoding is not None else 'utf-8'


def shell_quote(args):

3 Source : _utils.py
with GNU General Public License v3.0
from Artikash

    def _get_win32_short_name(s):
        """ Returns short name """
        buf_size = MAX_PATH
        for i in range(2):
            buf = create_unicode_buffer(u('\0') * (buf_size + 1))
            r = GetShortPathNameW(u(s), buf, buf_size)
            if r == 0:
                raise WinError()
            if r   <   buf_size:
                if PY_2:
                    return buf.value.encode(sys.getfilesystemencoding())
                return buf.value
            buf_size = r
        raise WinError()

    def _get_win32_long_name(s):

3 Source : _utils.py
with GNU General Public License v3.0
from Artikash

    def _get_win32_long_name(s):
        """ Returns long name """
        buf_size = MAX_PATH
        for i in range(2):
            buf = create_unicode_buffer(u('\0') * (buf_size + 1))
            r = GetLongPathNameW(u(s), buf, buf_size)
            if r == 0:
                raise WinError()
            if r   <   buf_size:
                if PY_2:
                    return buf.value.encode(sys.getfilesystemencoding())
                return buf.value
            buf_size = r
        raise WinError()

    def _get_win32_case_sensitive_name(s):

3 Source : req_install.py
with MIT License
from AstonZ

    def pyproject_toml(self):
        # type: () -> str
        assert self.source_dir, "No source dir for %s" % self

        pp_toml = os.path.join(self.setup_py_dir, 'pyproject.toml')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(pp_toml, six.text_type):
            pp_toml = pp_toml.encode(sys.getfilesystemencoding())

        return pp_toml

    def load_pyproject_toml(self):

3 Source : test_static.py
with GNU General Public License v2.0
from Atrion

def unicode_filesystem(tmpdir):
    filename = tmpdir / ntou('☃', 'utf-8')
    tmpl = 'File system encoding ({encoding}) cannot support unicode filenames'
    msg = tmpl.format(encoding=sys.getfilesystemencoding())
    try:
        io.open(str(filename), 'w').close()
    except UnicodeEncodeError:
        pytest.skip(msg)


def ensure_unicode_filesystem():

3 Source : _util.py
with MIT License
from autofelix

def path_string(s):
    """
    Convert a Python string to a :py:class:`bytes` string identifying the same
    path and which can be passed into an OpenSSL API accepting a filename.

    :param s: An instance of :py:class:`bytes` or :py:class:`unicode`.

    :return: An instance of :py:class:`bytes`.
    """
    if isinstance(s, binary_type):
        return s
    elif isinstance(s, text_type):
        return s.encode(sys.getfilesystemencoding())
    else:
        raise TypeError("Path must be represented as bytes or unicode string")


if PY3:

3 Source : _dumbwin32proc.py
with MIT License
from autofelix

def _fsdecode(x):
    """
    Decode a string to a L{unicode} representation, passing
    through existing L{unicode} unchanged.

    @param x: The string to be conditionally decoded.
    @type x: L{bytes} or L{unicode}

    @return: L{unicode}
    """
    if isinstance(x, bytes):
        return x.decode(sys.getfilesystemencoding())
    else:
        return x



def debug(msg):

3 Source : test_iutils.py
with MIT License
from autofelix

    def _pathTest(self, utilFunc, check):
        dir = os.path.abspath(self.mktemp())
        os.makedirs(dir)
        scriptFile = self.makeSourceFile([
                "import os, sys",
                "sys.stdout.write(os.getcwd())"])
        d = utilFunc(self.exe, ['-u', scriptFile], path=dir)
        d.addCallback(check, dir.encode(sys.getfilesystemencoding()))
        return d


    def test_getProcessOutputPath(self):

3 Source : req_install.py
with Apache License 2.0
from awslabs

    def setup_py_path(self):
        # type: () -> str
        assert self.source_dir, "No source dir for %s" % self
        setup_py = os.path.join(self.unpacked_source_directory, 'setup.py')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py

    @property

3 Source : _utils.py
with Apache License 2.0
from awslabs

    def _str_to_unicode(x):
        """Handle text decoding. Internal use only"""
        if not isinstance(x, str):
            return x.decode(sys.getfilesystemencoding())
        return x

    def _handle_errors(rv, src):

3 Source : utils.py
with Apache License 2.0
from awslabs

    def _str_to_unicode(x):
        """Handle text decoding. Internal use only"""
        if not isinstance(x, text_type):
            return x.decode(sys.getfilesystemencoding())
        return x

    def _handle_errors(rv, src):

3 Source : venv-bootstrap.py
with MIT License
from BinTuner

def install_files(home_dir, bin_dir, prompt, files):
    if hasattr(home_dir, "decode"):
        home_dir = home_dir.decode(sys.getfilesystemencoding())
    virtualenv_name = os.path.basename(home_dir)
    for name, content in files.items():
        content = content.replace("__VIRTUAL_PROMPT__", prompt or "")
        content = content.replace("__VIRTUAL_WINPROMPT__", prompt or "({}) ".format(virtualenv_name))
        content = content.replace("__VIRTUAL_ENV__", home_dir)
        content = content.replace("__VIRTUAL_NAME__", virtualenv_name)
        content = content.replace("__BIN_NAME__", os.path.basename(bin_dir))
        content = content.replace("__PATH_SEP__", os.pathsep)
        writefile(os.path.join(bin_dir, name), content)


def install_python_config(home_dir, bin_dir, prompt=None):

See More Examples