예제 #1
0
def test_wz():
    temp = dataprint.to_string([w, z], columns=True)
    assert temp == c
예제 #2
0
def test_multiple_comments():
    temp = dataprint.to_string(data, comments=b_comments)
    assert temp == b_default
예제 #3
0
def test_comment_character_multiple():
    temp = dataprint.to_string(data, comments=b_comments, comment_lead='%')
    assert temp == b_symbol
예제 #4
0
                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
예제 #5
0
def test_not_iter ():
	with pytest.raises(dataprint.DataPrinterException):
		c = dataprint.to_string(a)
예제 #6
0
def test_const ():
	c_copy = copy.deepcopy(c)
	temp = dataprint.to_string(c)
	assert c == c_copy
예제 #7
0
def test_no_comments ():
	temp = dataprint.to_string(e, comment_lead=None)
	assert temp == e_def
예제 #8
0
def test_simple():
    temp = dataprint.to_string(d)
    assert temp == d_def
예제 #9
0
def test_no_comments():
    temp = dataprint.to_string(e, comment_lead=None)
    assert temp == e_def
예제 #10
0
def test_longer():
    temp = dataprint.to_string(c)
    assert temp == c_def
예제 #11
0
def test_const():
    c_copy = copy.deepcopy(c)
    temp = dataprint.to_string(c)
    assert c == c_copy
예제 #12
0
def test_tuples():
    temp = dataprint.to_string(b)
    assert temp == b_default
예제 #13
0
def test_arrays():
    temp = dataprint.to_string(a)
    assert temp == a_default
예제 #14
0
                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('')
예제 #15
0
def test_tuples ():
	temp = dataprint.to_string(b)
	assert temp == b_default
예제 #16
0
def test_single_comment ():
	temp = dataprint.to_string(data, comments=a_comments)
	assert temp == a_default
예제 #17
0
def test_longer ():
	temp = dataprint.to_string(c)
	assert temp == c_def
예제 #18
0
def test_multiple_comments ():
	temp = dataprint.to_string(data, comments=b_comments)
	assert temp == b_default
예제 #19
0
def test_simple ():
	temp = dataprint.to_string(d)
	assert temp == d_def
예제 #20
0
def test_comment_character_single ():
	temp = dataprint.to_string(data, comments=a_comments, comment_lead='%')
	assert temp == a_symbol
예제 #21
0
            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))
예제 #22
0
def test_comment_character_multiple ():
	temp = dataprint.to_string(data, comments=b_comments, comment_lead='%')
	assert temp == b_symbol
예제 #23
0
			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)
예제 #24
0
def test_no_comment_character ():
	temp = dataprint.to_string(data, comments=a_comments, comment_lead=None)
	assert temp == a_none
예제 #25
0
def test_single_comment():
    temp = dataprint.to_string(data, comments=a_comments)
    assert temp == a_default
예제 #26
0
def test_not_iter():
    with pytest.raises(dataprint.DataPrinterException):
        c = dataprint.to_string(a)
예제 #27
0
def test_comment_character_single():
    temp = dataprint.to_string(data, comments=a_comments, comment_lead='%')
    assert temp == a_symbol
예제 #28
0
def test_arrays ():
	temp = dataprint.to_string(a)
	assert temp == a_default
예제 #29
0
def test_no_comment_character():
    temp = dataprint.to_string(data, comments=a_comments, comment_lead=None)
    assert temp == a_none
예제 #30
0
def test_xyz():
    temp = dataprint.to_string([x, y, z], columns=True)
    assert temp == b