Created
May 16, 2010 12:54
-
-
Save snim2/402861 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
def listexns(mod): | |
module = __import__(mod) | |
exns = [] | |
for name in module.__dict__: | |
if (isinstance(module.__dict__[name], Exception) or | |
name.endswith('Error')): | |
exns.append(name) | |
for name in exns: | |
print '%s.%s is an exception type' % (str(mod), name) | |
return | |
if __name__ == '__main__': | |
import sys | |
if len(sys.argv) <= 1: | |
print 'Give me a module name on the $PYTHONPATH!' | |
print 'Looking for exception types in module: %s' % sys.argv[1] | |
listexns(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment