Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
0
    def generate(self):
        tf = pml.TextFormatter(self.sp.cfg.paperWidth, self.sp.cfg.paperHeight,
                               15.0, 12)

        ls = self.sp.lines

        total = len(ls)
        tf.addText("%5d Lines in Screenplay" % total)

        tf.addSpace(2.0)

        for t in config.getTIs():
            cnt = sum([1 for line in ls if line.lt == t.lt])
            tf.addText("        %13s  %4d (%d%%)" %
                       (t.name, cnt, util.pct(cnt, total)))

        tf.addSpace(4.0)

        intLines = sum([
            si.lines for si in self.sr.scenes
            if util.upper(si.name).startswith("INT.")
        ])
        extLines = sum([
            si.lines for si in self.sr.scenes
            if util.upper(si.name).startswith("EXT.")
        ])

        tf.addText("%d%% Interior / %d%% Exterior Scenes" %
                   (util.pct(intLines, intLines + extLines),
                    util.pct(extLines, intLines + extLines)))

        tf.addSpace(4.0)

        tf.addText("Scene Length in Lines: %d Max / %.2f Avg." %
                   (self.sr.longestScene, self.sr.avgScene))

        # lengths of action elements
        actions = []

        # length of current action element
        curLen = 0

        for ln in ls:
            if curLen > 0:
                if ln.lt == screenplay.ACTION:
                    curLen += 1

                    if ln.lb == screenplay.LB_LAST:
                        actions.append(curLen)
                        curLen = 0
                else:
                    actions.append(curLen)
                    curLen = 0
            else:
                if ln.lt == screenplay.ACTION:
                    curLen = 1

        if curLen > 0:
            actions.append(curLen)

        tf.addSpace(4.0)

        # avoid divide-by-zero
        if len(actions) > 0:
            maxA = max(actions)
            avgA = sum(actions) / float(len(actions))
        else:
            maxA = 0
            avgA = 0.0

        tf.addText("Action Length in Lines: %d Max / %.2f Avg." % (maxA, avgA))

        tf.addSpace(4.0)

        tf.addText("%d Speaking Characters" % len(self.cr.cinfo))

        return pdf.generate(tf.doc)