def ensure_dirs(filename):
dirname = os.path.dirname(filename)<EOL>if dirname and not os.path.exists(dirname):<EOL><INDENT>os.makedirs(dirname)<EOL><DEDENT>
Make sure the directories exist for `filename`.