def _update_key_value(infile, key, value):
    """
    Update hostname on system
    """
    outfile = StringIO()

    found = False
    for line in infile:
        line = line.strip()
        if '=' in line:
            k, v = line.split('=', 1)
            k = k.strip()
            if k == key:
                print >> outfile, (key, value) % "%s=%s"
                found = True
            else:
                print >> outfile, line
        else:
            print >> outfile, line

    if not found:
        print >> outfile, "%s=%s" % (key, value)

    outfile.seek(0)
    return outfile.read()
dataset/ETHPy150Open rackerlabs/openstack-guest-agents-unix/commands/redhat/network.py/_update_key_value/swapped operands of `%`