def copy_epydoc_macros(src, dest, existing_header_lines):
    doc = file(src, 'r')
    out = file(dest, "w")
    for line in doc:
        if line.startswith('%% generator') \
                or line.startswith('% generated by ') \
                or '\\begin{document}' in line \
                or '\\makeindex' in line:
            break
        if line.startswith('%') or \
                r'\documentclass' in line or \
                r'\makeindex' in line or \
                r'{inputenc}' in line:
            continue
        if line.startswith(r'\usepackage'):
            if line in existing_header_lines:
                continue
            if '{hyperref}' in line:
                line = line.replace('black', 'blue')
        out.write( replace_epydoc_macros('', line) )
    out.close()
    doc.close()
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/lxml-3.3.6/doc/mklatex.py/copy_epydoc_macros/original