cgilsxml.py: bug

This commit is contained in:
Jephté Clain 2017-04-06 22:23:37 +04:00
parent e44003526f
commit ee2e411856
1 changed files with 12 additions and 14 deletions

View File

@ -182,6 +182,7 @@ class File:
def find_files(basedir, filters, spec_method='all'):
basedir = path.abspath(basedir)
files = []
deep_filters = [filter for filter in filters if filter.re_spec is not None and filter.deep_scan]
if deep_filters:
for dirpath, dirnames, filenames in os.walk(basedir):
@ -191,7 +192,7 @@ def find_files(basedir, filters, spec_method='all'):
try: file = File(dirpath, filename)
except: continue
matched1 = matched = False
allowed1 = allowed = False
allowed = False
for filter in deep_filters:
if spec_method == 'all' or \
(spec_method == 'first' and not matched):
@ -199,16 +200,14 @@ def find_files(basedir, filters, spec_method='all'):
else:
matched1 = False
matched = matched1 or matched
if spec_method == 'all' or \
(spec_method == 'first' and matched and not allowed):
allowed1 = filter.match_allow(file)
else:
allowed1 = False
allowed = allowed1 or allowed
allowed = filter.match_allow(file) or allowed
if matched: pass
elif allowed: file.dontlist = True
else: continue
files.append(file)
simple_filters = [filter for filter in filters if filter.re_spec is not None and not filter.deep_scan]
if simple_filters:
for name in os.listdir(basedir):
@ -218,7 +217,7 @@ def find_files(basedir, filters, spec_method='all'):
except: continue
if not file.isfile(): continue
matched1 = matched = False
allowed1 = allowed = False
allowed = False
for filter in simple_filters:
if spec_method == 'all' or \
(spec_method == 'first' and not matched):
@ -226,16 +225,14 @@ def find_files(basedir, filters, spec_method='all'):
else:
matched1 = False
matched = matched1 or matched
if spec_method == 'all' or \
(spec_method == 'first' and matched and not allowed):
allowed1 = filter.match_allow(file)
else:
allowed1 = False
allowed = allowed1 or allowed
allowed = filter.match_allow(file) or allowed
if matched: pass
elif allowed: file.dontlist = True
else: continue
files.append(file)
glob_filters = [filter for filter in filters if filter.glob is not None]
if glob_filters:
for filter in glob_filters:
@ -260,6 +257,7 @@ def find_files(basedir, filters, spec_method='all'):
elif filter.match_allow(file): file.dontlist = True
else: continue
files.append(file)
return files
def build_sortfunc(sortby):