Hmm. I'm going to try and play with this a little tonight and report back tomorrow but on first try both these solutions return an error <type 'exceptions.AttributeError'> 'NoneType' object has no attribute 'endswith'
Don't know what that is but I'm digging in right now to find out. --