コード例 #1
0
ファイル: notes.py プロジェクト: propbono/pdf-csv-merge
    def extract_notes(self, pdf):
        try:
            notes_from_pdf = self._find_prepp_notes(pdf)
        except Exception as e:
            print("Error '{0}' occured. Arguments {1}.".format(e, e.args))
        else:
            if notes_from_pdf:
                name = pdf.split('-')[2].lower()
                notes_from_pdf = notes_from_pdf[0].lstrip('(').rstrip(')').split('-')
                self.notes["width"] = notes_from_pdf[0].lower().split('x')[0]
                self.notes["height"] = notes_from_pdf[0].lower().split('x')[1]
                self.notes["stock"] = notes_from_pdf[1].lower()
                self.notes["quantity"] = pdf.split('-')[-1].rstrip(".pdf")

                for note in notes_from_pdf[2:]:
                    if _operator.contains(note, "n;"):
                        self.notes["notes"] = note.lstrip("n;")
                    elif _operator.contains(note, "g;"):
                        self.notes["group"] =  note.lstrip("g;").upper()
                    elif _operator.contains(note, "p;"):
                        self.notes["pages"] = note.lstrip("p;")
                    elif note.lower() == 't' or note.lower() == 't;':
                        self.notes["is_special"] = "special"
                if _operator.contains(name, "fedex"):
                    if self.notes["group"] == "":
                        self.notes["group"] = "x".upper()
                    else:
                        self.notes["group"] +=",x".upper()

                self.notes = self._parse_notes(self.notes)
                pdf = self.delete_prepp_notes_from(pdf)
            else:
                self.notes = None
        finally:
            return pdf, self.notes
コード例 #2
0
ファイル: notes.py プロジェクト: propbono/pdf-csv-merge
 def _check_and_crorrect_group(self, notes):
     if notes["group"] in self.GROUPS:
         notes["group"] = self.GROUPS[notes["group"]]
     elif self._check_if_mixed_group(notes["group"]):
         notes["notes"] += self._correct_notes_for_mixed_group(notes["group"])
         notes["group"] = "MIXED"
     elif _operator.contains(notes["group"], ","):
         notes["group"] = ""
     return notes
コード例 #3
0
ファイル: notes.py プロジェクト: propbono/pdf-csv-merge
    def _check_and_correct_stock(self, notes):

        if notes["stock"] == "16pt":
            if int(notes["quantity"]) > 1000:
                notes["stock"] += "5000"
            else:
                notes["stock"] += "1000"

        if _operator.contains(notes["stock"], "16pt") or notes["stock"] == \
                "uv" or notes["stock"] == "matte":
            notes["stockname"] = "16pt-Cover"
            notes["stockweight"] = "338"

        if notes["stock"] == "100lb":
            notes["stockname"] = "100lb-Text"
            notes["stockweight"] = "150"

        if notes["stock"] == "80lb":
            notes["stockname"] = "80lb-Text"
            notes["stockweight"] = "115"

        if notes["stock"] == "70lb":
            notes["stockname"] = "70lb-Text"
            notes["stockweight"] = "95"

        if notes["stock"] == "60lb":
            notes["stockname"] = "60lb-Text"
            notes["stockweight"] = "90"

        if notes["stock"] == "18pt":
            notes["stockname"] = "18pt-Matte"
            notes["stockweight"] = "350"

        if notes["stock"] == "8pt":
            notes["stockname"] = "8pt-Cover"
            notes["stockweight"] = "260"

        if notes["stock"] == "10pt":
            notes["stockname"] = "10pt-Cover"
            notes["stockweight"] = "260"

        if notes["stock"] == "12pt":
            notes["stockname"] = "12pt-Cover"
            notes["stockweight"] = "278"

        if notes["stock"] == "14pt":
            notes["stockname"] = "14pt-Cover"
            notes["stockweight"] = "308"

        if notes["stock"] == "13pt":
            notes["stockname"] = "13pt-Enviro"
            notes["stockweight"] = "290"

        if notes["stock"] == "24pt":
            notes["stockname"] = "24pt-Cover"
            notes["stockweight"] = "350"

        if notes["stock"] == "15pt":
            notes["stockname"] = "15pt-C1S"
            notes["stockweight"] = "308"

        if notes["stock"] == "70lboffset":
            notes["stockname"] = "70lb-Offset"
            notes["stockweight"] = "95"

        if notes["stock"] == "80lboffset":
            notes["stockname"] = "80lb-Offset"
            notes["stockweight"] = "100"

        if notes["stock"] == "60lboffset":
            notes["stockname"] = "60lb-Offset"
            notes["stockweight"] = "90"

        if notes["stock"] == "50lboffset":
            notes["stockname"] = "50lb-Offset"
            notes["stockweight"] = "74"

        if notes["stock"] =="qm":
            notes["stockname"] = "QM"
            notes["stockweight"] = "20"

        if notes["stock"] == "digital" or notes["stock"] == "d":
            notes["stockname"] = "Digital"
            notes["stockweight"] = "150"

        if notes["pages"] != "":
            notes["stock"] += "magazine"
            notes["notes"] += " BOOKLET"
        return notes