def test_not_writable(tmpdir): fd = open(str(tmpdir) + "/write.file", "w") fd.write("test") fd.close() fd = open(str(tmpdir) + "/write.file", "r") with pytest.raises(dataprint.DataPrinterException): dataprint.to_file(fd, a)
def test_not_writable (tmpdir): fd = open(str(tmpdir) + "/write.file", "w") fd.write("test") fd.close() fd = open(str(tmpdir) + "/write.file", "r") with pytest.raises(dataprint.DataPrinterException): dataprint.to_file(fd, a)
def test_existing (tmpdir): fd = open(str(tmpdir) + "/exist.file", "w") dataprint.to_file(fd, a) fd.close() fd = open(str(tmpdir) + "/exist.file", "r") temp = fd.read() fd.close() assert temp == a_default
def test_existing(tmpdir): fd = open(str(tmpdir) + "/exist.file", "w") dataprint.to_file(fd, a) fd.close() fd = open(str(tmpdir) + "/exist.file", "r") temp = fd.read() fd.close() assert temp == a_default
def test_exists (tmpdir): fd = open(str(tmpdir) + "/write.file", "w") fd.write("test") fd.close() with pytest.raises(dataprint.DataPrinterException): dataprint.to_file(str(tmpdir) + "/write.file", a)
def test_notfile (tmpdir): with pytest.raises(dataprint.DataPrinterException): dataprint.to_file(3, a)
def test_invalid (tmpdir): fd = open(str(tmpdir) + "/exist.file", "w") fd.close() with pytest.raises(dataprint.DataPrinterException): dataprint.to_file(fd, a)
rows.append(row) handle_orphan_parts(orphan_parts) if rows_before == rows: termcolor.cprint('No changes', attrs=['bold']) print(dataprint.to_string(rows)) else: with tempfile.NamedTemporaryFile( mode='w+t') as before, tempfile.NamedTemporaryFile( mode='w+t') as after: # HACK for space of MPN entry on diff rows_before[0][rows_before[0].index( 'MPN')] = '.' * 8 + 'MPN' + '.' * 8 rows[0][rows[0].index('MPN')] = '.' * 8 + 'MPN' + '.' * 8 dataprint.to_file(before, rows_before) dataprint.to_file(after, rows) before.flush() after.flush() options = icdiff.get_options()[0] options.no_headers = True icdiff.diff_files(options, before.name, after.name) print('') print() r = input('Write updated Eagle files? [Y/n] ') if len(r) and r[0].lower() == 'n': sys.exit() sch.write(sch_file) brd.write(brd_file)
# print('\tBinary data is formatted as:') # print('\t<uint64_t><int16_t><int16_t><int16_t><int16_t>... all little endian') # print('\ttimestmap real0 imag0 real1 imag1 ...') # print('\tFor 1024 total complex numbers') #dataprint.to_newfile(args.outfile, data_array, # overwrite=True, # #comments=("Time", "X", "Y", "Z"), # ) if args.trilaterate: ofile = open(args.outfile, 'w') aa = [] for a in sorted(ANCHORS.keys()): aa.append(':'.join((a, *map(str, ANCHORS[a])))) ofile.write("#" + '\t'.join(("Time", "X", "Y", "Z", *aa)) + '\n') dataprint.to_file(ofile, data_array) ofile.write('#windows {} {} {}\n'.format(*windows)) print("Saved to {}".format(args.outfile)) if args.ground_truth: t1_errs = np.array(t1_errs) print("t1: min {:.4f} max {:.4f} mean {:.4f} med {:.4f}".format( np.min(t1_errs), np.max(t1_errs), np.mean(t1_errs), np.median(t1_errs), )) print(nodiversity_drop_count)
def test_exists(tmpdir): fd = open(str(tmpdir) + "/write.file", "w") fd.write("test") fd.close() with pytest.raises(dataprint.DataPrinterException): dataprint.to_file(str(tmpdir) + "/write.file", a)
def test_notfile(tmpdir): with pytest.raises(dataprint.DataPrinterException): dataprint.to_file(3, a)
def test_invalid(tmpdir): fd = open(str(tmpdir) + "/exist.file", "w") fd.close() with pytest.raises(dataprint.DataPrinterException): dataprint.to_file(fd, a)
orphan_parts.append(sch_part) row = attr_row_helper(kind, value, device, number, sch_part, rows) rows.append(row) handle_orphan_parts(orphan_parts) if rows_before == rows: termcolor.cprint('No changes', attrs=['bold']) print(dataprint.to_string(rows)) else: with tempfile.NamedTemporaryFile(mode='w+t') as before, tempfile.NamedTemporaryFile(mode='w+t') as after: # HACK for space of MPN entry on diff rows_before[0][rows_before[0].index('MPN')] = '.' * 8 + 'MPN' + '.' * 8 rows[0][rows[0].index('MPN')] = '.' * 8 + 'MPN' + '.' * 8 dataprint.to_file(before, rows_before) dataprint.to_file(after, rows) before.flush() after.flush() options = icdiff.get_options()[0] options.no_headers = True icdiff.diff_files(options, before.name, after.name) print('') print() r = input('Write updated Eagle files? [Y/n] ') if len(r) and r[0].lower() == 'n': sys.exit() sch.write(sch_file) brd.write(brd_file)