Esempio n. 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)]))
Esempio n. 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)]))
Esempio n. 3
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]))
Esempio n. 4
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]))
Esempio n. 5
0

def listfiles(dirname=''):
    git_files = gitlsfiles(dirname)

    cwd = realpath(dirname or os.curdir)
    prefix_length = len(cwd) + 1

    if sys.version_info >= (2, 6):
        walker = os.walk(cwd, followlinks=True)
    else:
        walker = os.walk(cwd)

    for root, dirs, files in walker:
        for file in files:
            filename = join(root, file)
            if posix(realpath(filename)) in git_files:
                yield filename[prefix_length:]


if __name__ == '__main__':
    if len(sys.argv) > 1:
        dirname = sys.argv[1]
    else:
        dirname = ''
    for filename in listfiles(dirname):
        try:
            print(compose(filename))
        except UnicodeEncodeError:
            print(repr(filename)[1:-1])
Esempio n. 6
0

def listfiles(dirname=""):
    git_files = gitlsfiles(dirname)

    cwd = realpath(dirname or os.curdir)
    prefix_length = len(cwd) + 1

    if sys.version_info >= (2, 6):
        walker = os.walk(cwd, followlinks=True)
    else:
        walker = os.walk(cwd)

    for root, dirs, files in walker:
        for file in files:
            filename = join(root, file)
            if posix(realpath(filename)) in git_files:
                yield filename[prefix_length:]


if __name__ == "__main__":
    if len(sys.argv) > 1:
        dirname = sys.argv[1]
    else:
        dirname = ""
    for filename in listfiles(dirname):
        try:
            print(compose(filename))
        except UnicodeEncodeError:
            print(repr(filename)[1:-1])