Ejemplo n.º 1
0
 def testPNDiff(self):
     plus, minus, _ = compare_boms.get_diff_data(self.old_pn, self.new_pn,
                                                 "partnumbers", True)
     self.assertEqual(plus, {('LMBR160FT1G', 'SOD123-FL')})
     self.assertEqual(
         minus, {('AP6398S', 'AP6356S'),
                 ('KX-6 37.4 MHz 10/10ppm 18pF', '2520'),
                 ('NU/LMBR160FT1G', 'SOD123-FL'),
                 ('U.FL-R-SMT-1', 'U.FL-R-SMT-1'), ('WPM3401', 'SOT23')})
Ejemplo n.º 2
0
 def testNoDeleted(self):
     _, _, res = compare_boms.get_diff_data(self.old_pn, self.new_pn,
                                            "partnumbers", False)
     self.assertFalse('deleted' in res.lower())
Ejemplo n.º 3
0
 def testResDiff(self):
     plus, minus, _ = compare_boms.get_diff_data(self.old_res, self.new_res,
                                                 "resistors", True)
     self.assertEqual(plus, {('12000R', '0402')})
     self.assertEqual(minus, {('127000R', '0402')})
Ejemplo n.º 4
0
 def testCapDiff(self):
     plus, minus, _ = compare_boms.get_diff_data(self.old_cap, self.new_cap,
                                                 "capacitors", True)
     self.assertEqual(plus, {('18pf', '0603')})
     self.assertEqual(minus, {('10pf', '0402'), ('18pf', '0402')})
Ejemplo n.º 5
0
def find_new_pns(old: List[data_types.Component],
                 new: List[data_types.Component], sheet,
                 headers: Dict[str, Optional[int]], quantity: bool):
    """
    compare two lists to find new positions
    :param quantity: add quantity?
    :param sheet: sheet
    :param headers: headers
    :param old: list of old components
    :param new: list of new components
    :return:
    """
    old_pn, old_cap, old_res, old_ind = compare_boms.get_comp_list_precise(old)
    new_pn, new_cap, new_res, new_ind = compare_boms.get_comp_list_precise(new)
    plus_pn, minus_pn, _ = compare_boms.get_diff_data(old_pn, new_pn,
                                                      "partnumbers", True)
    plus_cap, minus_cap, _ = compare_boms.get_diff_data(
        old_cap, new_cap, "capacitors", True)
    plus_res, minus_res, _ = compare_boms.get_diff_data(
        old_res, new_res, "resistors", True)
    plus_ind, minus_ind, _ = compare_boms.get_diff_data(
        old_ind, new_ind, "inductors", True)
    new_sorted = sorted(new, key=lambda x: x.row)
    index = 0
    for (index, component) in enumerate(new_sorted):
        if component.component_type not in [
                data_types.ComponentType.CAPACITOR,
                data_types.ComponentType.RESISTOR
        ]:
            if component.pn:
                add_row(component, headers, sheet, index + 2, False)
            if quantity:
                paired = get_component_by_pn(component.pn, component.footprint,
                                             old)
                if paired:
                    if len(paired.designator) > len(component.designator):
                        sheet["%s%i" % (ascii_uppercase[headers['quantity'] - 1], index + 2)].fill = \
                            PatternFill("solid", fgColor='FF0000')
                    elif len(paired.designator) < len(component.designator):
                        sheet["%s%i" % (ascii_uppercase[headers['quantity'] - 1], index + 2)].fill = \
                            PatternFill("solid", fgColor="00FF00")
            if (component.pn, component.footprint) in plus_pn:
                color_row(headers, sheet, '00FF00', index + 2)

        if component.component_type == data_types.ComponentType.RESISTOR:
            if component.details and component.details.value != -1:
                add_row(component, headers, sheet, index + 2, True)
                if (str(component.details.value) + 'R',
                        component.footprint) in plus_res:
                    color_row(headers, sheet, '00FF00', index + 2)
                if quantity:
                    paired = get_component_by_value(
                        str(component.details.value) + 'R',
                        component.footprint, component.component_type, old)
                    if paired:
                        if len(paired.designator) > len(component.designator):
                            sheet["%s%i" % (ascii_uppercase[headers['quantity'] - 1], index + 2)].fill = \
                                PatternFill("solid", fgColor='FF0000')
                        elif len(paired.designator) < len(
                                component.designator):
                            sheet["%s%i" % (ascii_uppercase[headers['quantity'] - 1], index + 2)].fill = \
                                PatternFill("solid", fgColor="00FF00")

        if component.component_type == data_types.ComponentType.CAPACITOR:
            if component.details and component.details.value:
                add_row(component, headers, sheet, index + 2, True)
                if (str(component.details.absolute_pf_value) + 'pf',
                        component.footprint) in plus_cap:
                    color_row(headers, sheet, '00FF00', index + 2)

                if quantity:
                    paired = get_component_by_value(
                        str(component.details.absolute_pf_value) + 'pf',
                        component.footprint, component.component_type, old)
                    if paired:
                        if len(paired.designator) > len(component.designator):
                            sheet["%s%i" % (ascii_uppercase[headers['quantity'] - 1], index + 2)].fill = \
                                PatternFill("solid", fgColor='FF0000')
                        elif len(paired.designator) < len(
                                component.designator):
                            sheet["%s%i" % (ascii_uppercase[headers['quantity'] - 1], index + 2)].fill = \
                                PatternFill("solid", fgColor="00FF00")

        if component.component_type == data_types.ComponentType.INDUCTOR:
            if not component.pn and component.details and component.details.value:
                add_row(component, headers, sheet, index + 2, True)
                if (component.details.value, component.footprint) in plus_ind:
                    color_row(headers, sheet, '00FF00', index + 2)
                if quantity:
                    paired = get_component_by_value(
                        str(component.details.value), component.footprint,
                        component.component_type, old)
                    if paired:
                        if len(paired.designator) > len(component.designator):
                            sheet["%s%i" % (ascii_uppercase[headers['quantity'] - 1], index + 2)].fill = \
                                PatternFill("solid", fgColor='FF0000')
                        elif len(paired.designator) < len(
                                component.designator):
                            sheet["%s%i" % (ascii_uppercase[headers['quantity'] - 1], index + 2)].fill = \
                                PatternFill("solid", fgColor="00FF00")

    added_rows = index + 3
    for (pn, footprint) in minus_pn:
        component = get_component_by_pn(pn, footprint, old)
        if component:
            add_row(component, headers, sheet, added_rows, False)
            color_row(headers, sheet, 'FF0000', added_rows)
            added_rows += 1
    for (value, footprint) in minus_cap:
        component = get_component_by_value(value, footprint,
                                           data_types.ComponentType.CAPACITOR,
                                           old)
        if component:
            add_row(component, headers, sheet, added_rows, False)
            color_row(headers, sheet, 'FF0000', added_rows)
            added_rows += 1
    for (value, footprint) in minus_res & minus_ind:
        component = get_component_by_value(value, footprint,
                                           data_types.ComponentType.RESISTOR,
                                           old)
        if component:
            add_row(component, headers, sheet, added_rows, False)
            color_row(headers, sheet, 'FF0000', added_rows)
            added_rows += 1