def ensure_parent_dir(filename):
<EOL>securesystemslib.formats.PATH_SCHEMA.check_match(filename)<EOL>directory = os.path.split(filename)[<NUM_LIT:0>]<EOL>if directory and not os.path.exists(directory):<EOL><INDENT>os.makedirs(directory, <NUM_LIT>)<EOL><DEDENT>
<Purpose>
  To ensure existence of the parent directory of 'filename'.  If the parent
  directory of 'name' does not exist, create it.

  Example: If 'filename' is '/a/b/c/d.txt', and only the directory '/a/b/'
  exists, then directory '/a/b/c/d/' will be created.

<Arguments>
  filename:
    A path string.

<Exceptions>
  securesystemslib.exceptions.FormatError: If 'filename' is improperly
  formatted.

<Side Effects>
  A directory is created whenever the parent directory of 'filename' does not
  exist.

<Return>
  None.