fnmatch: Remove dependency on posixpath module.

In micropython-lib, os.path.normcase is already a no-op.

Signed-off-by: Damien George <damien@micropython.org>
pull/205/merge
Damien George 2020-07-07 19:09:59 +10:00
rodzic 6b985bbc1b
commit dedf328503
3 zmienionych plików z 5 dodań i 12 usunięć

Wyświetl plik

@ -11,7 +11,6 @@ corresponding to PATTERN. (It does not compile it.)
""" """
import os import os
import os.path import os.path
import posixpath
import re import re
#import functools #import functools
@ -51,15 +50,9 @@ def filter(names, pat):
result = [] result = []
pat = os.path.normcase(pat) pat = os.path.normcase(pat)
match = _compile_pattern(pat) match = _compile_pattern(pat)
if os.path is posixpath: for name in names:
# normcase on posix is NOP. Optimize it away from the loop. if match(os.path.normcase(name)):
for name in names: result.append(name)
if match(name):
result.append(name)
else:
for name in names:
if match(os.path.normcase(name)):
result.append(name)
return result return result
def fnmatchcase(name, pat): def fnmatchcase(name, pat):

Wyświetl plik

@ -1,4 +1,4 @@
srctype = cpython srctype = cpython
type = module type = module
version = 0.5.2 version = 0.5.2
depends = os, os.path, posixpath, re-pcre depends = os, os.path, re-pcre

Wyświetl plik

@ -18,4 +18,4 @@ setup(name='micropython-fnmatch',
license='Python', license='Python',
cmdclass={'sdist': sdist_upip.sdist}, cmdclass={'sdist': sdist_upip.sdist},
py_modules=['fnmatch'], py_modules=['fnmatch'],
install_requires=['micropython-os', 'micropython-os.path', 'micropython-posixpath', 'micropython-re-pcre']) install_requires=['micropython-os', 'micropython-os.path', 'micropython-re-pcre'])