python: Use os.path.basename instead of open-coding it.