def dir_ensure(location, recursive=False, mode=None,<EOL>owner=None, group=None, use_sudo=False):
args = '<STR_LIT>'<EOL>if recursive:<EOL><INDENT>args = args + '<STR_LIT>'<EOL><DEDENT>if not dir_exists(location):<EOL><INDENT>if use_sudo:<EOL><INDENT>sudo('<STR_LIT>' % (args, location))<EOL><DEDENT>else:<EOL><INDENT>run('<STR_LIT>' % (args, location))<EOL><DEDENT><DEDENT>if owner or group or mode:<EOL><INDENT>if use_sudo:<EOL><INDENT>dir_attribs(location,<EOL>owner=owner,<EOL>group=group,<EOL>mode=mode,<EOL>recursive=recursive,<EOL>use_sudo=True)<EOL><DEDENT>else:<EOL><INDENT>dir_attribs(location,<EOL>owner=owner,<EOL>group=group,<EOL>mode=mode,<EOL>recursive=recursive)<EOL><DEDENT><DEDENT>
cuisine dir_ensure doesn't do sudo, so we implement our own
    Ensures that there is a remote directory at the given location,
    optionally updating its mode/owner/group.
    If we are not updating the owner/group then this can be done as a single
    ssh call, so use that method, otherwise set owner/group after creation.