예제 #1
0
    def test_utf8_filename(self):
        if sys.version_info >= (3,):
            filename = 'héhé.html'.encode('utf-8')
        else:
            filename = 'héhé.html'

        # Windows does not like byte filenames under Python 3
        if sys.platform == 'win32' and sys.version_info >= (3,):
            filename = filename.decode('utf-8')

        self.create_file(filename)

        # HFS Plus uses decomposed UTF-8
        if sys.platform == 'darwin':
            filename = decompose(filename)

        self.add_file(filename)

        self.assertEqual(
                [fn for fn in os.listdir(os.curdir) if fn[0] != '.'],
                [fsdecode(filename)])

        # git ls-files returns composed UTF-8
        if sys.platform == 'darwin':
            filename = compose(filename)

        self.assertEqual(
                set(self.listfiles()),
                set([fsdecode(filename)]))
예제 #2
0
    def test_utf8_filename(self):
        if sys.version_info >= (3, ):
            filename = 'héhé.html'.encode('utf-8')
        else:
            filename = 'héhé.html'

        # Windows does not like byte filenames under Python 3
        if sys.platform == 'win32' and sys.version_info >= (3, ):
            filename = filename.decode('utf-8')

        self.create_file(filename)

        # HFS Plus uses decomposed UTF-8
        if sys.platform == 'darwin':
            filename = decompose(filename)

        self.add_file(filename)

        self.assertEqual([fn for fn in os.listdir(os.curdir) if fn[0] != '.'],
                         [fsdecode(filename)])

        # git ls-files returns composed UTF-8
        if sys.platform == 'darwin':
            filename = compose(filename)

        self.assertEqual(set(self.listfiles()), set([fsdecode(filename)]))
예제 #3
0
    def test_nonascii_filename(self):
        filename = 'héhé.html'

        # HFS Plus uses decomposed UTF-8
        if sys.platform == 'darwin':
            filename = decompose(filename)

        self.create_git_file(filename)

        self.assertEqual(
            [fn for fn in os.listdir(self.directory) if fn[0] != '.'],
            [filename])

        self.assertEqual(set(self.listfiles(self.directory)), set([filename]))
예제 #4
0
    def test_nonascii_filename(self):
        filename = 'héhé.html'

        # HFS Plus uses decomposed UTF-8
        if sys.platform == 'darwin':
            filename = decompose(filename)

        self.create_git_file(filename)

        self.assertEqual(
                [fn for fn in os.listdir(self.directory) if fn[0] != '.'],
                [filename])

        self.assertEqual(
                set(self.gitlsfiles(self.directory)),
                set([posix(realpath(filename))]))
예제 #5
0
    def test_nonascii_filename(self):
        filename = 'héhé.html'

        self.create_and_add(filename)

        # HFS Plus uses decomposed UTF-8
        if sys.platform == 'darwin':
            filename = decompose(filename)

        self.assertEqual([fn for fn in os.listdir(os.curdir) if fn[0] != '.'],
                         [filename])

        # git ls-files returns composed UTF-8
        if sys.platform == 'darwin':
            filename = compose(filename)

        self.assertEqual(set(self.listfiles()), set([filename]))
예제 #6
0
def gitlsfiles(dirname=''):
    # NB: Passing the '-z' option to 'git ls-files' below returns the
    # output as a blob of null-terminated filenames without canonical-
    # ization or use of double-quoting.
    #
    # So we'll get back e.g.:
    #
    # 'pyramid/tests/fixtures/static/h\xc3\xa9h\xc3\xa9.html'
    #
    # instead of:
    #
    # '"pyramid/tests/fixtures/static/h\\303\\251h\\303\\251.html"'
    #
    # for each file.
    res = set()

    try:
        topdir = check_output(['git', 'rev-parse', '--show-toplevel'],
                              cwd=dirname or None,
                              stderr=PIPE).strip()

        if sys.platform == 'win32':
            cwd = ntfsdecode(topdir)
        else:
            cwd = topdir

        filenames = check_output(['git', 'ls-files', '-z'],
                                 cwd=cwd,
                                 stderr=PIPE)
    except (CalledProcessError, OSError):
        # Setuptools mandates we fail silently
        return res

    for filename in filenames.split(b('\x00')):
        if filename:
            filename = posixpath.join(topdir, filename)
            if sys.platform == 'darwin':
                filename = hfs_quote(filename)
            if sys.platform == 'win32':
                filename = ntfsdecode(filename)
            else:
                filename = fsdecode(filename)
            if sys.platform == 'darwin':
                filename = decompose(filename)
            res.add(filename)
    return res
예제 #7
0
def gitlsfiles(dirname=''):
    # NB: Passing the '-z' option to 'git ls-files' below returns the
    # output as a blob of null-terminated filenames without canonical-
    # ization or use of double-quoting.
    #
    # So we'll get back e.g.:
    #
    # 'pyramid/tests/fixtures/static/h\xc3\xa9h\xc3\xa9.html'
    #
    # instead of:
    #
    # '"pyramid/tests/fixtures/static/h\\303\\251h\\303\\251.html"'
    #
    # for each file.
    res = set()

    try:
        topdir = check_output(
            ['git', 'rev-parse', '--show-toplevel'], cwd=dirname or None,
            stderr=PIPE).strip()

        if sys.platform == 'win32':
            cwd = ntfsdecode(topdir)
        else:
            cwd = topdir

        filenames = check_output(
            ['git', 'ls-files', '-z'], cwd=cwd, stderr=PIPE)
    except (CalledProcessError, OSError):
        # Setuptools mandates we fail silently
        return res

    for filename in filenames.split(b('\x00')):
        if filename:
            filename = posixpath.join(topdir, filename)
            if sys.platform == 'darwin':
                filename = hfs_quote(filename)
            if sys.platform == 'win32':
                filename = ntfsdecode(filename)
            else:
                filename = fsdecode(filename)
            if sys.platform == 'darwin':
                filename = decompose(filename)
            res.add(filename)
    return res
예제 #8
0
    def test_nonascii_filename(self):
        filename = 'héhé.html'

        self.create_and_add(filename)

        # HFS Plus uses decomposed UTF-8
        if sys.platform == 'darwin':
            filename = decompose(filename)

        self.assertEqual(
                [fn for fn in os.listdir(os.curdir) if fn[0] != '.'],
                [filename])

        # git ls-files returns composed UTF-8
        if sys.platform == 'darwin':
            filename = compose(filename)

        self.assertEqual(
                set(self.listfiles()),
                set([filename]))
예제 #9
0
    def test_utf8_filename(self):
        if sys.version_info >= (3, ):
            filename = 'héhé.html'.encode('utf-8')
        else:
            filename = 'héhé.html'

        # HFS Plus uses decomposed UTF-8
        if sys.platform == 'darwin':
            filename = decompose(filename)

        # Windows does not like byte filenames under Python 3
        if sys.platform == 'win32' and sys.version_info >= (3, ):
            filename = filename.decode('utf-8')

        self.create_git_file(filename)

        self.assertEqual(
            [fn for fn in os.listdir(self.directory) if fn[0] != '.'],
            [fsdecode(filename)])

        self.assertEqual(set(self.gitlsfiles(self.directory)),
                         set([posix(realpath(fsdecode(filename)))]))
예제 #10
0
    def test_utf8_filename(self):
        if sys.version_info >= (3,):
            filename = 'héhé.html'.encode('utf-8')
        else:
            filename = 'héhé.html'

        # HFS Plus uses decomposed UTF-8
        if sys.platform == 'darwin':
            filename = decompose(filename)

        # Windows does not like byte filenames under Python 3
        if sys.platform == 'win32' and sys.version_info >= (3,):
            filename = filename.decode('utf-8')

        self.create_git_file(filename)

        self.assertEqual(
                [fn for fn in os.listdir(self.directory) if fn[0] != '.'],
                [fsdecode(filename)])

        self.assertEqual(
                set(self.gitlsfiles(self.directory)),
                set([posix(realpath(fsdecode(filename)))]))