예제 #1
0
    def populate(self):
        self.topListWidget.clear()  # clear widget
        self.midListWidget.clear()

        self.filePath = self.filePathEdit.text()
        self.jsonFilePath = os.path.splitext(
            self.filePath
        )[0] + os.extsep + 'json'  # make sure its always getting the json

        if os.path.isfile(self.jsonFilePath):
            with open(self.jsonFilePath, "r") as f:
                self.rawData = json.load(f)
                self.data = util.sortDict(self.rawData)
                print('original json load success')
        else:
            print('file not exist')

        if self.compFilePathEdit.text():  # compare method
            self.compFilePath = self.compFilePathEdit.text()
            self.compJsonFilePath = os.path.splitext(
                self.compFilePath)[0] + os.extsep + 'json'

            if os.path.isfile(self.compJsonFilePath):
                with open(self.compJsonFilePath, "r") as f:  # example file
                    self.rawCompData = json.load(f)
                    self.compData = util.sortDict(self.rawCompData)
                    print('compared json load success')
            else:
                print('file not exist')

            self.genInfo()  # this will also create color list

        for topFilter in self.data['file info'].keys():
            self.topListWidget.addItem(topFilter)
            self.topListWidget.sortItems()

        if self.compColorTop:
            self.uniqueTopN = []  # reset list
            for nodes in self.compColorTop:
                if nodes not in self.data['file info'].keys():
                    self.uniqueTopN.append(nodes)
                    self.topListWidget.addItem(nodes)
                    self.topListWidget.sortItems()

        # set color to list (order matters)
        self.colorFunc(self.topListWidget, self.oriColorTop, 'red')
        self.colorFunc(self.topListWidget, self.compColorTop, 'green')
        self.colorFunc(self.topListWidget, self.diffColorTop,
                       'yellow')  # different overrides color at last
예제 #2
0
    def generate(self):
        tf = pml.TextFormatter(self.sp.cfg.paperWidth,
                               self.sp.cfg.paperHeight, 15.0, 12)

        scriptLines = sum([li.lines for li in self.locations])

        for li in self.locations:
            tf.addSpace(5.0)

            # list of (scenename, lines_in_scene) tuples, which we sort in
            # DESC(lines_in_scene) ASC(scenename) order.
            tmp = [(scene, self.scenes[scene].lines) for scene in li.scenes]

            # PY2.4: this should work (test it):
            #  tmp.sort(key=itemgetter(0))
            #  tmp.sort(key=itemgetter(1) reverse=True)
            tmp.sort(lambda x, y: cmp(x[0], y[0]))
            tmp.reverse()
            tmp.sort(lambda x, y: cmp(x[1], y[1]))
            tmp.reverse()

            for scene, lines in tmp:
                if len(tmp) > 1:
                    pct = " (%d%%)" % util.pct(lines, li.lines)
                else:
                    pct = ""

                tf.addText("%s%s" % (scene, pct), style = pml.BOLD)

            tf.addSpace(1.0)

            tf.addWrappedText("Lines: %d (%d%% action, %d%% of script),"
                " Scenes: %d, Pages: %d (%s)" % (li.lines,
                util.pct(li.actionLines, li.lines),
                util.pct(li.lines, scriptLines), li.sceneCount,
                len(li.pages), li.pages), "  ")


            if self.inf[self.INF_SPEAKERS].selected:
                tf.addSpace(2.5)

                for it in util.sortDict(li.chars):
                    tf.addText("     %3d  %s" % (it[1], it[0]))

        return pdf.generate(tf.doc)
예제 #3
0
    def generate(self):
        tf = pml.TextFormatter(self.sp.cfg.paperWidth, self.sp.cfg.paperHeight,
                               15.0, 12)

        scriptLines = sum([li.lines for li in self.locations])

        for li in self.locations:
            tf.addSpace(5.0)

            # list of (scenename, lines_in_scene) tuples, which we sort in
            # DESC(lines_in_scene) ASC(scenename) order.
            tmp = [(scene, self.scenes[scene].lines) for scene in li.scenes]

            # PY2.4: this should work (test it):
            #  tmp.sort(key=itemgetter(0))
            #  tmp.sort(key=itemgetter(1) reverse=True)
            tmp.sort(lambda x, y: cmp(x[0], y[0]))
            tmp.reverse()
            tmp.sort(lambda x, y: cmp(x[1], y[1]))
            tmp.reverse()

            for scene, lines in tmp:
                if len(tmp) > 1:
                    pct = " (%d%%)" % util.pct(lines, li.lines)
                else:
                    pct = ""

                tf.addText("%s%s" % (scene, pct), style=pml.BOLD)

            tf.addSpace(1.0)

            tf.addWrappedText(
                "Lines: %d (%d%% action, %d%% of script),"
                " Scenes: %d, Pages: %d (%s)" %
                (li.lines, util.pct(li.actionLines, li.lines),
                 util.pct(li.lines, scriptLines), li.sceneCount, len(
                     li.pages), li.pages), "  ")

            if self.inf[self.INF_SPEAKERS].selected:
                tf.addSpace(2.5)

                for it in util.sortDict(li.chars):
                    tf.addText("     %3d  %s" % (it[1], it[0]))

        return pdf.generate(tf.doc)
예제 #4
0
    def generate(self):
        tf = pml.TextFormatter(self.sp.cfg.paperWidth, self.sp.cfg.paperHeight,
                               15.0, 12)

        for si in self.scenes:
            tf.addSpace(5.0)

            tf.addText("%-4s %s" % (si.number, si.name), style=pml.BOLD)

            tf.addSpace(1.0)

            tf.addText("     Lines: %d (%s%% action), Pages: %d"
                       " (%s)" % (si.lines, util.pct(
                           si.actionLines, si.lines), len(si.pages), si.pages))

            if self.inf[self.INF_SPEAKERS].selected:
                tf.addSpace(2.5)

                for it in util.sortDict(si.chars):
                    tf.addText("     %3d  %s" % (it[1], it[0]))

        return pdf.generate(tf.doc)
예제 #5
0
    def generate(self):
        tf = pml.TextFormatter(self.sp.cfg.paperWidth,
                               self.sp.cfg.paperHeight, 15.0, 12)

        for si in self.scenes:
            tf.addSpace(5.0)

            tf.addText("%-4s %s" % (si.number, si.name), style = pml.BOLD)

            tf.addSpace(1.0)

            tf.addText("     Lines: %d (%s%% action), Pages: %d"
                " (%s)" % (si.lines, util.pct(si.actionLines, si.lines),
                len(si.pages), si.pages))

            if self.inf[self.INF_SPEAKERS].selected:
                tf.addSpace(2.5)

                for it in util.sortDict(si.chars):
                    tf.addText("     %3d  %s" % (it[1], it[0]))

        return pdf.generate(tf.doc)
예제 #6
0
    def generate(self):
        tf = pml.TextFormatter(self.sp.cfg.paperWidth, self.sp.cfg.paperHeight,
                               20.0, 12)

        for ci in self.cinfo:
            if not ci.include:
                continue

            tf.addText(ci.name, fs=14, style=pml.BOLD | pml.UNDERLINED)

            if self.inf[self.INF_BASIC].selected:
                tf.addText("Speeches: %d, Lines: %d (%.2f%%),"
                           " per speech: %.2f" %
                           (ci.speechCnt, ci.lineCnt,
                            util.pctf(ci.lineCnt, self.totalLineCnt),
                            util.safeDiv(ci.lineCnt, ci.speechCnt)))

                tf.addText("Words: %d, per speech: %.2f,"
                           " characters per: %.2f" %
                           (ci.wordCnt, util.safeDiv(ci.wordCnt, ci.speechCnt),
                            util.safeDiv(ci.wordCharCnt, ci.wordCnt)))

            if self.inf[self.INF_PAGES].selected:
                tf.addWrappedText(
                    "Pages: %d, list: %s" % (len(ci.pages), ci.pages),
                    "       ")

            if self.inf[self.INF_LOCATIONS].selected:
                tf.addSpace(2.5)

                for it in util.sortDict(ci.scenes):
                    tf.addText("%3d %s" % (it[1], it[0]),
                               x=tf.margin * 2.0,
                               fs=10)

            tf.addSpace(5.0)

        return pdf.generate(tf.doc)
예제 #7
0
    def generate(self):
        tf = pml.TextFormatter(self.sp.cfg.paperWidth,
                               self.sp.cfg.paperHeight, 20.0, 12)

        for ci in self.cinfo:
            if not ci.include:
                continue

            tf.addText(ci.name, fs = 14,
                       style = pml.BOLD | pml.UNDERLINED)

            if self.inf[self.INF_BASIC].selected:
                tf.addText("Speeches: %d, Lines: %d (%.2f%%),"
                    " per speech: %.2f" % (ci.speechCnt, ci.lineCnt,
                    util.pctf(ci.lineCnt, self.totalLineCnt),
                    util.safeDiv(ci.lineCnt, ci.speechCnt)))

                tf.addText("Words: %d, per speech: %.2f,"
                    " characters per: %.2f" % (ci.wordCnt,
                    util.safeDiv(ci.wordCnt, ci.speechCnt),
                    util.safeDiv(ci.wordCharCnt, ci.wordCnt)))

            if self.inf[self.INF_PAGES].selected:
                tf.addWrappedText("Pages: %d, list: %s" % (len(ci.pages),
                    ci.pages), "       ")

            if self.inf[self.INF_LOCATIONS].selected:
                tf.addSpace(2.5)

                for it in util.sortDict(ci.scenes):
                    tf.addText("%3d %s" % (it[1], it[0]),
                               x = tf.margin * 2.0, fs = 10)

            tf.addSpace(5.0)

        return pdf.generate(tf.doc)