mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Issue #16620: Got rid of using undocumented function glob.glob1().
This commit is contained in:
parent
47670ebb0c
commit
31a858cbf1
1 changed files with 8 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2005 Martin v. Löwis
|
# Copyright (C) 2005 Martin v. Löwis
|
||||||
# Licensed to PSF under a Contributor Agreement.
|
# Licensed to PSF under a Contributor Agreement.
|
||||||
from _msi import *
|
from _msi import *
|
||||||
import glob
|
import fnmatch
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
|
@ -379,7 +379,13 @@ class Directory:
|
||||||
def glob(self, pattern, exclude = None):
|
def glob(self, pattern, exclude = None):
|
||||||
"""Add a list of files to the current component as specified in the
|
"""Add a list of files to the current component as specified in the
|
||||||
glob pattern. Individual files can be excluded in the exclude list."""
|
glob pattern. Individual files can be excluded in the exclude list."""
|
||||||
files = glob.glob1(self.absolute, pattern)
|
try:
|
||||||
|
files = os.listdir(self.absolute)
|
||||||
|
except OSError:
|
||||||
|
return []
|
||||||
|
if pattern[:1] != '.':
|
||||||
|
files = (f for f in files if f[0] != '.')
|
||||||
|
files = fnmatch.filter(files, pattern)
|
||||||
for f in files:
|
for f in files:
|
||||||
if exclude and f in exclude: continue
|
if exclude and f in exclude: continue
|
||||||
self.add_file(f)
|
self.add_file(f)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue