mirror of
https://github.com/ejwa/gitinspector.git
synced 2024-11-13 07:11:08 +01:00
Added InvalidRegExpError in the filtering module.
This is a better solution than simply relying on ValueError and also helps us to maintain compatibility with all our other exceptions (it gives us a msg attribute that we can access when catching the error). Also localized the string for InvalidRegExpError.
This commit is contained in:
parent
291761e6a4
commit
064a2e11b8
2 changed files with 10 additions and 5 deletions
|
@ -28,6 +28,11 @@ import textwrap
|
|||
__filters__ = []
|
||||
__filtered_files__ = set()
|
||||
|
||||
class InvalidRegExpError(ValueError):
|
||||
def __init__(self, msg):
|
||||
super(InvalidRegExpError, self).__init__(msg)
|
||||
self.msg = msg
|
||||
|
||||
def get():
|
||||
return __filters__
|
||||
|
||||
|
@ -51,7 +56,7 @@ def set_filtered(file_name):
|
|||
__filtered_files__.add(string)
|
||||
return True
|
||||
except:
|
||||
raise ValueError("Invalid regular expression specified")
|
||||
raise InvalidRegExpError(_("invalid regular expression specified"))
|
||||
return False
|
||||
|
||||
FILTERING_INFO_TEXT = N_("The following files were excluded from the statistics due to the specified exclusion patterns")
|
||||
|
|
|
@ -184,13 +184,13 @@ def main():
|
|||
filtering.clear()
|
||||
filtering.add(a)
|
||||
|
||||
except (format.InvalidFormatError, optval.InvalidOptionArgument, getopt.error) as exception:
|
||||
__check_python_version__()
|
||||
__run__.output()
|
||||
|
||||
except (filtering.InvalidRegExpError, format.InvalidFormatError, optval.InvalidOptionArgument, getopt.error) as exception:
|
||||
print(sys.argv[0], "\b:", exception.msg)
|
||||
print(_("Try `{0} --help' for more information.").format(sys.argv[0]))
|
||||
sys.exit(2)
|
||||
|
||||
__check_python_version__()
|
||||
__run__.output()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue