Skip to content
Snippets Groups Projects
Commit 8cf7f0c4 authored by Durham Goode's avatar Durham Goode
Browse files

ignore: refactor file read into a function

This refactors the ignore file reading code into a function so that in a future
patch we can make it recursive.
parent 3bbbadf6
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,20 @@
return patterns, warnings
def readignorefile(filepath, warn, skipwarning=False):
try:
pats = []
fp = open(filepath)
pats, warnings = ignorepats(fp)
fp.close()
for warning in warnings:
warn("%s: %s\n" % (filepath, warning))
except IOError, inst:
if not skipwarning:
warn(_("skipping unreadable ignore file '%s': %s\n") %
(filepath, inst.strerror))
return pats
def readpats(root, files, warn):
'''return a dict mapping ignore-file-name to list-of-patterns'''
......@@ -59,17 +73,9 @@
for f in files:
if f in pats:
continue
try:
pats[f] = []
fp = open(f)
pats[f], warnings = ignorepats(fp)
fp.close()
for warning in warnings:
warn("%s: %s\n" % (f, warning))
except IOError, inst:
if f != files[0]:
warn(_("skipping unreadable ignore file '%s': %s\n") %
(f, inst.strerror))
skipwarning = f == files[0]
pats[f] = readignorefile(f, warn, skipwarning=skipwarning)
return [(f, pats[f]) for f in files if f in pats]
def ignore(root, files, warn):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment