def cp(src_hdfs_path, dest_hdfs_path, **kwargs):
src, dest = {}, {}<EOL>try:<EOL><INDENT>for d, p in ((src, src_hdfs_path), (dest, dest_hdfs_path)):<EOL><INDENT>d["<STR_LIT:host>"], d["<STR_LIT:port>"], d["<STR_LIT:path>"] = path.split(p)<EOL>d["<STR_LIT>"] = hdfs(d["<STR_LIT:host>"], d["<STR_LIT:port>"])<EOL><DEDENT>try:<EOL><INDENT>src["<STR_LIT:info>"] = src["<STR_LIT>"].get_path_info(src["<STR_LIT:path>"])<EOL><DEDENT>except IOError:<EOL><INDENT>raise IOError("<STR_LIT>" % (src["<STR_LIT:path>"]))<EOL><DEDENT>try:<EOL><INDENT>dest["<STR_LIT:info>"] = dest["<STR_LIT>"].get_path_info(dest["<STR_LIT:path>"])<EOL><DEDENT>except IOError:<EOL><INDENT>if src["<STR_LIT:info>"]["<STR_LIT>"] == "<STR_LIT:file>":<EOL><INDENT>_cp_file(src["<STR_LIT>"], src["<STR_LIT:path>"], dest["<STR_LIT>"], dest["<STR_LIT:path>"],<EOL>**kwargs)<EOL>return<EOL><DEDENT>else:<EOL><INDENT>dest["<STR_LIT>"].create_directory(dest["<STR_LIT:path>"])<EOL>dest_hdfs_path = dest["<STR_LIT>"].get_path_info(dest["<STR_LIT:path>"])["<STR_LIT:name>"]<EOL>for item in src["<STR_LIT>"].list_directory(src["<STR_LIT:path>"]):<EOL><INDENT>cp(item["<STR_LIT:name>"], dest_hdfs_path, **kwargs)<EOL><DEDENT>return<EOL><DEDENT><DEDENT>if dest["<STR_LIT:info>"]["<STR_LIT>"] == "<STR_LIT:file>":<EOL><INDENT>raise IOError("<STR_LIT>" % (dest["<STR_LIT:path>"]))<EOL><DEDENT>dest["<STR_LIT:path>"] = path.join(dest["<STR_LIT:path>"], path.basename(src["<STR_LIT:path>"]))<EOL>if dest["<STR_LIT>"].exists(dest["<STR_LIT:path>"]):<EOL><INDENT>raise IOError("<STR_LIT>" % (dest["<STR_LIT:path>"]))<EOL><DEDENT>if src["<STR_LIT:info>"]["<STR_LIT>"] == "<STR_LIT:file>":<EOL><INDENT>_cp_file(src["<STR_LIT>"], src["<STR_LIT:path>"], dest["<STR_LIT>"], dest["<STR_LIT:path>"],<EOL>**kwargs)<EOL><DEDENT>else:<EOL><INDENT>dest["<STR_LIT>"].create_directory(dest["<STR_LIT:path>"])<EOL>dest_hdfs_path = dest["<STR_LIT>"].get_path_info(dest["<STR_LIT:path>"])["<STR_LIT:name>"]<EOL>for item in src["<STR_LIT>"].list_directory(src["<STR_LIT:path>"]):<EOL><INDENT>cp(item["<STR_LIT:name>"], dest_hdfs_path, **kwargs)<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>for d in src, dest:<EOL><INDENT>try:<EOL><INDENT>d["<STR_LIT>"].close()<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>
\
    Copy the contents of ``src_hdfs_path`` to ``dest_hdfs_path``.

    If ``src_hdfs_path`` is a directory, its contents will be copied
    recursively. Source file(s) are opened for reading and copies are
    opened for writing. Additional keyword arguments, if any, are
    handled like in :func:`open`.