I don't think `os.path.split()` splits all parts of a path name, just directory name and basename. Should this be `path.split(os.sep)`?