def add_postfix_user(username):
    # FIXME: do something a little more serious than a superficial grep
    # for instance, slurp the file, get the first column and check the 
    # username isn't in it.
    with open('/etc/postfix/vmaps', 'r') as fd: 
        if username in fd.read():
            print "User already exists"
            return

    with open('/etc/postfix/vmaps', 'a') as fd:
        fd.write("%s@%s %s/\n" % (username, config.SERVER_NAME, username))

    os.system("postmap /etc/postfix/vmaps") 
    os.system("service postfix reload")
dataset/ETHPy150Open khamidou/kite/src/back/kite/kite-adduser.py/add_postfix_user/original