def test_wz(): temp = dataprint.to_string([w, z], columns=True) assert temp == c
def test_multiple_comments(): temp = dataprint.to_string(data, comments=b_comments) assert temp == b_default
def test_comment_character_multiple(): temp = dataprint.to_string(data, comments=b_comments, comment_lead='%') assert temp == b_symbol
handle_attrs_for_part(sch_part) try: brd_element = sch_part_to_brd_element[sch_part] handle_attrs_update_element(sch_part, brd_element) except KeyError: 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
def test_not_iter (): with pytest.raises(dataprint.DataPrinterException): c = dataprint.to_string(a)
def test_const (): c_copy = copy.deepcopy(c) temp = dataprint.to_string(c) assert c == c_copy
def test_no_comments (): temp = dataprint.to_string(e, comment_lead=None) assert temp == e_def
def test_simple(): temp = dataprint.to_string(d) assert temp == d_def
def test_no_comments(): temp = dataprint.to_string(e, comment_lead=None) assert temp == e_def
def test_longer(): temp = dataprint.to_string(c) assert temp == c_def
def test_const(): c_copy = copy.deepcopy(c) temp = dataprint.to_string(c) assert c == c_copy
def test_tuples(): temp = dataprint.to_string(b) assert temp == b_default
def test_arrays(): temp = dataprint.to_string(a) assert temp == a_default
sch_part = sch_kinds[kind][value][device][number] handle_attrs_for_part(sch_part) try: brd_element = sch_part_to_brd_element[sch_part] handle_attrs_update_element(sch_part, brd_element) except KeyError: 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('')
def test_tuples (): temp = dataprint.to_string(b) assert temp == b_default
def test_single_comment (): temp = dataprint.to_string(data, comments=a_comments) assert temp == a_default
def test_longer (): temp = dataprint.to_string(c) assert temp == c_def
def test_multiple_comments (): temp = dataprint.to_string(data, comments=b_comments) assert temp == b_default
def test_simple (): temp = dataprint.to_string(d) assert temp == d_def
def test_comment_character_single (): temp = dataprint.to_string(data, comments=a_comments, comment_lead='%') assert temp == a_symbol
print('Unable to convert bom on this go. Will try again \ because that seems to fix it.') bom_tries -= 1 if bom_tries == 0: # Failed to convert bom. Exclude it print('Converting bom to csv failed. Not much we can do now.') sys.exit(1) # Convert CSV to txt rows = [] with open(csv, 'rb') as f: csvreader = csvr.reader(f) for row in csvreader: rows.append(row) txt_contents = dataprint.to_string(data=rows, separator=' ') with open(txt, 'w') as f: f.write(header.replace('"', '').format(b)) f.write(txt_contents) # Read in CSV csv_contents = '' with open(csv, 'r') as f: csv_contents = f.read() # Figure out how many columns there are with open(csv, 'r') as f: csvreader = csvr.reader(f) columns = len(next(csvreader))
def test_comment_character_multiple (): temp = dataprint.to_string(data, comments=b_comments, comment_lead='%') assert temp == b_symbol
print('Unable to convert bom on this go. Will try again \ because that seems to fix it.') bom_tries -= 1 if bom_tries == 0: # Failed to convert bom. Exclude it print('Converting bom to csv failed. Not much we can do now.') sys.exit(1) # Convert CSV to txt rows = [] with open(csv,'rb') as f: csvreader = csvr.reader(f) for row in csvreader: rows.append(row) txt_contents = dataprint.to_string(data=rows, separator=' ') with open(txt, 'w') as f: f.write(header.format(b)) f.write(txt_contents) # Read in CSV csv_contents = '' with open(csv, 'r') as f: csv_contents = f.read() # Write back CSV with open(csv, 'w') as f: # Add header to csv f.write(header.format(b)) f.write(csv_contents)
def test_no_comment_character (): temp = dataprint.to_string(data, comments=a_comments, comment_lead=None) assert temp == a_none
def test_single_comment(): temp = dataprint.to_string(data, comments=a_comments) assert temp == a_default
def test_not_iter(): with pytest.raises(dataprint.DataPrinterException): c = dataprint.to_string(a)
def test_comment_character_single(): temp = dataprint.to_string(data, comments=a_comments, comment_lead='%') assert temp == a_symbol
def test_arrays (): temp = dataprint.to_string(a) assert temp == a_default
def test_no_comment_character(): temp = dataprint.to_string(data, comments=a_comments, comment_lead=None) assert temp == a_none
def test_xyz(): temp = dataprint.to_string([x, y, z], columns=True) assert temp == b