def get_next_job(infile): qfile = open(infile, 'r') bakfile = open(infile + '.bak','w') job_name='' job_cmd='' for line in qfile: tmp_n, tmp_c = pjs.read_job_from_line(line) if line.startswith('#'): line = '*' + line[1:] elif not line.startswith('*'): if job_cmd == '' and (tmp_c != '' or tmp_n != ''): job_name, job_cmd = tmp_n, tmp_c line = '#' + line bakfile.write(line) qfile.close() bakfile.close() return (job_name, job_cmd)