def print_diff(a, b, difftype='unified', filename=None, fp=None):

    def write_tempfile(data, **kwargs):
        fd, path = tempfile.mkstemp(**kwargs)
        try:
            os.write(fd, bytestr(data))
        finally:
            os.close(fd)
        return path

    if difftype == 'unified':
        print_unified_diff(a, b, fromfile=filename, tofile='', n=3, fp=fp)
    elif difftype == 'html':
        htmldiffer = difflib.HtmlDiff(tabsize=4)
        html = htmldiffer.make_file(unilines(a), unilines(b),
                                    fromdesc=filename,
                                    todesc='',
                                    context=True, numlines=2)
        htmlfilename = write_tempfile(html, suffix='.html', prefix=timestamp())
        reporterror('\nopen "%s"' % htmlfilename, fp=fp)
    elif difftype == 'opendiff':
        outfilename = write_tempfile(b, suffix='.pbxproj', prefix=timestamp())
        reporterror('\nopendiff "%s" "%s"' % (filename, outfilename), fp=fp)
    else:
        raise ValueError(difftype % "Unknown difftype: '%s'")
dataset/ETHPy150Open mikr/xcodeprojer/xcodeprojer.py/print_diff/swapped operands of `%`