def METHOD_NAME(args, cfg, job):
    s = ''
    if 'before_script' in cfg:
        for cmd in cfg['before_script']:
            s += cmd.replace('\\n','\n')
            if not cmd.endswith('\n'):
                s += '\n'
    for cmd in job['script']:
        if args.keep:
            cmd = re.sub(r'(test\.py[^\n]*)', '\\1 --keep || /bin/true', cmd)
        s += cmd.replace('\\n','\n')
        if not cmd.endswith('\n'):
            s += '\n'
    return s