Skip to content

Commit 7259f0f

Browse files
committed
fnmatch: Remove dependency on os.path.
1 parent dcdac1f commit 7259f0f

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

python-stdlib/fnmatch/fnmatch.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@
99
The function translate(PATTERN) returns a regular expression
1010
corresponding to PATTERN. (It does not compile it.)
1111
"""
12-
import os
13-
import os.path
1412
import re
1513

16-
# import functools
14+
try:
15+
from os.path import normcase
16+
except ImportError:
17+
18+
def normcase(s):
19+
"""
20+
From os.path.normcase
21+
Normalize the case of a pathname. On Windows, convert all characters
22+
in the pathname to lowercase, and also convert forward slashes to
23+
backward slashes. On other operating systems, return the path unchanged.
24+
"""
25+
return s
26+
1727

1828
__all__ = ["filter", "fnmatch", "fnmatchcase", "translate"]
1929

@@ -35,8 +45,8 @@ def fnmatch(name, pat):
3545
if the operating system requires it.
3646
If you don't want this, use fnmatchcase(FILENAME, PATTERN).
3747
"""
38-
name = os.path.normcase(name)
39-
pat = os.path.normcase(pat)
48+
name = normcase(name)
49+
pat = normcase(pat)
4050
return fnmatchcase(name, pat)
4151

4252

@@ -59,10 +69,10 @@ def _compile_pattern(pat):
5969
def filter(names, pat):
6070
"""Return the subset of the list NAMES that match PAT."""
6171
result = []
62-
pat = os.path.normcase(pat)
72+
pat = normcase(pat)
6373
match = _compile_pattern(pat)
6474
for name in names:
65-
if match(os.path.normcase(name)):
75+
if match(normcase(name)):
6676
result.append(name)
6777
return result
6878

python-stdlib/fnmatch/metadata.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
srctype = cpython
22
type = module
33
version = 0.5.2
4-
depends = os, os.path

python-stdlib/fnmatch/setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@
2121
license="Python",
2222
cmdclass={"sdist": sdist_upip.sdist},
2323
py_modules=["fnmatch"],
24-
install_requires=["micropython-os", "micropython-os.path"],
2524
)

0 commit comments

Comments
 (0)