def update_frequency(prf_file, fixed_number): if not_exists(prf_file, "elder prf file"): return 1 prf_file_bak = prf_file + ".b" wrap_copy_file(prf_file, prf_file_bak, force=True) prf_lines = open(prf_file_bak) prf_ob = open(prf_file, "w") for line in prf_lines: line = line.strip() if p_frequency.search(line): line = p_mhz.sub("%s MHz" % fixed_number, line) print >> prf_ob, line prf_ob.close()
def update_clocks(prf_file, clocks, fixed_number): if not clocks: print_error("Not found any clocks name") return 1 prf_file_bak = prf_file + ".a" if not os.path.isfile(prf_file_bak): wrap_copy_file(prf_file, prf_file_bak) prf_lines = open(prf_file_bak) prf_ob = open(prf_file, "w") for line in prf_lines: line = line.strip() if p_frequency.search(line): continue print >> prf_ob, line for clk in clocks: print >> prf_ob, 'FREQUENCY NET "%s" %s MHz ;' % (clk, fixed_number) prf_ob.close()