Mercurial > hg > config
annotate python/dotpath.py @ 928:84543f2cda0d
restore my real email that companies keep making me change
| author | Jeff Hammel <k0scist@gmail.com> |
|---|---|
| date | Tue, 14 Oct 2025 14:20:55 -0700 |
| parents | 03fc1f76db91 |
| children |
| rev | line source |
|---|---|
| 20 | 1 #!/usr/bin/env python |
| 2 | |
| 3 import sys | |
| 4 | |
| 5 def filename(dotpath): | |
| 6 path = dotpath.split('.') | |
| 7 while path: | |
| 8 try: | |
| 9 module = __import__('.'.join(path)) | |
| 10 return module.__file__.rstrip('c') | |
| 11 except ImportError: | |
| 12 path.pop() | |
| 13 | |
| 14 def main(args=sys.argv[1:]): | |
| 15 for arg in args: | |
| 16 try: | |
| 17 _filename = filename(arg) | |
| 18 except Exception, e: | |
| 19 print e | |
| 20 continue | |
| 21 print _filename | |
| 22 | |
| 23 if __name__ == '__main__': | |
| 24 main() |
