Give helpful error for bad regex, fixes #20
This commit is contained in:
parent
cbe4a1691e
commit
72ea63708d
@ -129,8 +129,9 @@ def main():
|
||||
help="explicit datetime value used to filter updates in change list for "
|
||||
"--incremental sync")
|
||||
opt.add_option('--exclude', type=str, action='append',
|
||||
help="exclude resources with URI or filename matching pattern "
|
||||
"(repeat option for multiple excludes)")
|
||||
help="exclude resources with URI or filename matching the python regex "
|
||||
"supplied (see: <https://docs.python.org/2/howto/regex.html> for regex "
|
||||
"information, repeat option for multiple excludes)")
|
||||
opt.add_option('--empty', action='store_true',
|
||||
help="combine with --changelist to write and empty changelist, perhaps with links")
|
||||
opt.add_option('--multifile', '-m', action='store_true',
|
||||
|
||||
@ -65,8 +65,9 @@ def main():
|
||||
help="explicit datetime value used to filter updates in change list for "
|
||||
"--incremental sync")
|
||||
opt.add_option('--exclude', type=str, action='append',
|
||||
help="exclude resources with URI or filename matching pattern "
|
||||
"(repeat option for multiple excludes)")
|
||||
help="exclude resources with URI or filename matching the python regex "
|
||||
"supplied (see: <https://docs.python.org/2/howto/regex.html> for regex "
|
||||
"information, repeat option for multiple excludes)")
|
||||
opt.add_option('--multifile', '-m', action='store_true',
|
||||
help="disable reading and output of sitemapindex for multifile sitemap")
|
||||
opt.add_option('--noauth', action='store_true',
|
||||
|
||||
@ -3,4 +3,4 @@
|
||||
# Format: x.y.z where
|
||||
# x.y is spec version, see http://www.openarchives.org/rs/x.y/
|
||||
# z is incremented for revisions within that version, 1...
|
||||
__version__ = '1.0.0'
|
||||
__version__ = '1.0.1'
|
||||
|
||||
@ -110,8 +110,11 @@ class Client(object):
|
||||
# 1. Build from disk
|
||||
rlb = ResourceListBuilder(set_md5=self.checksum,mapper=self.mapper)
|
||||
rlb.set_path=set_path
|
||||
rlb.add_exclude_files(self.exclude_patterns)
|
||||
rl = rlb.from_disk(paths=paths)
|
||||
try:
|
||||
rlb.add_exclude_files(self.exclude_patterns)
|
||||
rl = rlb.from_disk(paths=paths)
|
||||
except ValueError as e:
|
||||
raise ClientFatalError(str(e))
|
||||
# 2. Set defaults and overrides
|
||||
rl.allow_multifile = self.allow_multifile
|
||||
rl.pretty_xml = self.pretty_xml
|
||||
|
||||
@ -63,7 +63,10 @@ class ResourceListBuilder():
|
||||
"""Compile a set of regexps for files to be exlcuded from scans"""
|
||||
self.compiled_exclude_files = []
|
||||
for pattern in self.exclude_files:
|
||||
self.compiled_exclude_files.append(re.compile(pattern))
|
||||
try:
|
||||
self.compiled_exclude_files.append(re.compile(pattern))
|
||||
except re.error as e:
|
||||
raise ValueError("Bad python regex in exclude '%s': %s" % (pattern,str(e)))
|
||||
|
||||
def exclude_file(self, file):
|
||||
"""True if file should be exclude based on name pattern"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user