Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # copied from one of the well known/talented OSX developers who posted this simple snippet somewhere, since the
- # uti/filemap situation is quite confusing on 10.6.
- # there are other solutions, even in python, that have been done using graphviz to create a huge graph/network
- # of the relationships (can get rather large if you have >100apps). And, there are other solutions like
- # setting an application's affinity (code is on github by another great developer),
- # and a 10.6 service. I would think that these are going to get more complex, even becoming a niche industry for
- # someone to make $10 via registration off of at some point, since the new UTI system has some potential (using magic vs file suffix, etc)
- # </rant off>
- import plistlib
- thePath = '/System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist'
- thePlist = plistlib.readPlist(thePath)
- theDocumentTypes = thePlist['UTExportedTypeDeclarations']
- theNames = {}
- theIndex =
- for theDocumentType in theDocumentTypes:
- theNames[theDocumentType['UTTypeIdentifier']] = 'UT%d' % theIndex
- theIndex += 1
- print 'digraph G {'
- for theDocumentType in theDocumentTypes:
- theType = theDocumentType['UTTypeIdentifier']
- theName = theNames[theType]
- print '\t%s [label="%s"];' % (theName, theType)
- if theDocumentType.has_key('UTTypeConformsTo'):
- if type(theDocumentType['UTTypeConformsTo']) == type(''):
- theDocumentType['UTTypeConformsTo'] = [theDocumentType['UTTypeConformsTo']]
- for theConformTo in theDocumentType['UTTypeConformsTo']:
- theConformToName = theNames[theConformTo]
- print '\t%s -> %s;' % (theName, theConformToName)
- print '}'
Add Comment
Please, Sign In to add comment