Exemple #1
0
 def setUp(self):
     self.new, _ = xlsx_parce.get_components_from_xlxs(filename_new)
     self.old, _ = xlsx_parce.get_components_from_xlxs(filename_old)
     self.old_pn, self.old_cap, self.old_res, self.old_ind = compare_boms.get_comp_list_precise(
         self.old)
     self.new_pn, self.new_cap, self.new_res, self.new_ind = compare_boms.get_comp_list_precise(
         self.new)
def find_similar():
    """
    main function for finding similar positions
    :return:
    """
    path = sys.argv[2] if len(sys.argv) >= 3 else '.'
    if os.path.exists(path):
        if os.path.isdir(path):
            components_list: List[data_types.Component] = list()
            for filename in os.listdir(path):
                if os.path.splitext(filename)[1].lower() == '.xlsx' \
                        and os.access(os.path.join(path, filename), os.R_OK):
                    try:
                        data, _ = xlsx_parce.get_components_from_xlxs(os.path.join(path, filename))
                        components_list.extend(data)
                    except PermissionError:
                        pass
        else:
            components_list: List[data_types.Component] = xlsx_parce.get_components_from_xlxs(path)[0]
        equal, similar, alternative, error = duplicates.compare_pns(components_list, root_len=8, precise=False)
        if error:
            print(error)
        if equal:
            print("These rows have equal pns:\n")
            print([(pn1, row1, pn2, row2) for (pn1, row1, in1, pn2, row2, ind2) in equal])
        if similar:
            print("These rows have similar pns:\n")
            print([(pn1, row1, pn2, row2) for (pn1, row1, in1, pn2, row2, ind2) in similar])
        if alternative:
            print('These rows have similar alternative pn:\n')
            print([(pn1, row1, pn2, row2) for (pn1, row1, in1, pn2, row2, ind2) in alternative])
        similar_caps = duplicates.compare_capacitors(components_list)
        if similar_caps:
            print("Those capacitors are similar:")
            print(similar_caps)
        similar_resistors = duplicates.compare_resistors(components_list)
        if similar_resistors:
            print("Similar resistor rows: ")
            print(similar_resistors)

        print("Search in %s complited" % path)
    else:
        print("Incorrect filename")
def compare_boms_new_pns(quantity=False, detailed=False):
    """
    main function for bom comparing. Use detailed=True to get detailed comparing and False to compare PNs only
    :return:
    """
    if len(sys.argv) != 4:
        print("Wrong params: two bom files to compare expected")
        return
    if not os.path.exists(sys.argv[2]) or not os.path.exists(sys.argv[3]) or os.path.isdir(sys.argv[2]) \
            or os.path.isdir(sys.argv[3]):
        print("Both files should be existing files (not folders)")
        return
    old, warning = xlsx_parce.get_components_from_xlxs(sys.argv[2])
    print(warning)
    new, warning = xlsx_parce.get_components_from_xlxs(sys.argv[3])
    print(warning)
    compare_boms.find_new_pns(old, new, not quantity)
    if detailed:
        compare_boms.detail_compare(old, new, False)
    if quantity:
        compare_boms.detail_compare(old, new, True)
Exemple #4
0
 def setUp(self):
     self.data, self.warning = xlsx_parce.get_components_from_xlxs(filename)
Exemple #5
0
 def setUp(self):
     self.new, _ = xlsx_parce.get_components_from_xlxs(filename_new)
     self.old, _ = xlsx_parce.get_components_from_xlxs(filename_old)
Exemple #6
0
 def setUp(self):
     self.new, _ = xlsx_parce.get_components_from_xlxs(filename_new)
     self.old, _ = xlsx_parce.get_components_from_xlxs(filename_old)
     self.old_len = len(self.old)
     compare_boms.join_the_same(self.old)
Exemple #7
0
 def setUp(self):
     self.data, _ = xlsx_parce.get_components_from_xlxs(filename_duplicate)
Exemple #8
0
        print("Similar resistor rows: ")
        print(similar_resistors)


if __name__ == '__main__':
    if len(sys.argv) >= 2:
        if os.path.exists(sys.argv[1]):
            if os.path.isdir(sys.argv[1]):
                folder = sys.argv[1]
                components_list: List[data_types.Component] = list()
                for filename in os.listdir(folder):
                    if os.path.splitext(filename)[1].lower() == '.xlsx' \
                            and os.access(os.path.join(folder, filename), os.R_OK):
                        try:
                            components_list.extend(
                                xlsx_parce.get_components_from_xlxs(
                                    os.path.join(folder, filename)))
                        except PermissionError:
                            pass
            else:
                components_list: List[
                    data_types.
                    Component] = xlsx_parce.get_components_from_xlxs(
                        sys.argv[1])
            compare_pns(components_list)
            compare_capacitors(components_list)
            compare_resistors(components_list)
            print("Search complited")
        else:
            print("Incorrect filename")
    else:
        print("No file")