Пример #1
0
    def __add_data_to_dict(self):
        print("Collecting data to dictionary:")

        data = ReturnData()
        for pdf in self.pdf_list:
            notes = Notes()
            try:
                pdf_without_notes, notes = notes.extract_notes(pdf)
            except:
                continue #check impact
            else:
                if notes is None:
                    data.files_skipped += 1
                    print("NOT PREPPED: ", pdf_without_notes[:7])
                else:
                    product = Product.factory(pdf_without_notes, notes)
                    row = product.merge_notes_without_csv()

                    key = notes["stock"]
                    if notes["type"] == "FLAT":
                        data.rows_flat.setdefault(key,[]).append(row)
                    elif notes["type"] == "BOUND":
                        data.rows_bound.setdefault(key, []).append(row)

                    print("ADDED!!: ", pdf[:7])
                    data.files_added_to_csv += 1

        print("All data in dictionary!")
        return data