Skip to content

Instantly share code, notes, and snippets.

@fish2000
Created September 30, 2010 05:04
Show Gist options
  • Save fish2000/604054 to your computer and use it in GitHub Desktop.
Save fish2000/604054 to your computer and use it in GitHub Desktop.
dump lists of all directories and egg files, in sys.path and all visible .pth files; group the results accordingly.
#!/usr/bin/env python
# encoding: utf-8
"""
whereismyshit.py
Created by FI$H 2000 on 2010-09-16.
Copyright (c) 2010 OST, LLC. All rights reserved.
"""
from __future__ import with_statement
import sys, os
eggs = []
dirs = []
pths = []
def main():
for p in sys.path:
if p.endswith('.egg'):
eggs.append(p)
else:
dirs.append(p)
try:
pths.extend(["%s/%s" % (p, pth) for pth in os.listdir(p) if pth.endswith('.pth')])
except OSError, err:
print "WTF: OSError %s for path %s" % (err, p)
print ""
print "###\t EGGS:"
for egg in eggs:
print ">>>\t %s" % egg
print ""
print "###\t DIRS:"
for durr in dirs:
print ">>>\t %s" % durr
print ""
print "###\t PTH FILES:"
for pth in pths:
print ">>>\t %s" % pth
with open(pth, 'r') as pthf:
print pthf.read()
print ""
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment