Beispiel #1
0
    def render_fdx_subset(self,fdx,start_with_scene,end_with_scene,mode,formatter):
        theoutput = tag.div(class_="scrippet"+mode)
#        self.log.debug("FDX: %s START: %d END %d" % (fdx,start_with_scene,end_with_scene))
        fdx_obj = self._get_src(self.env, formatter.req, *fdx)
        fd_doc = cElementTree.fromstring(fdx_obj.getStream().read())
        renderParagraphs = False
        for fd_content in fd_doc.findall("Content"):
            for fd_paragraph in fd_content.findall("Paragraph"):
                ptype = fd_paragraph.get('Type')
                if ptype == "Action":
                    ptype = "action"
                elif ptype == "Character":
                    ptype = "character"
                elif ptype == "Dialogue":
                    ptype = "dialogue"
                elif ptype == "Parenthetical":
                    ptype = "parenthetical"
                elif ptype == "Shot":
                    ptype = "shot"
                elif ptype == "Scene Heading":
                    if int(fd_paragraph.get('Number')) == start_with_scene:
                        renderParagraphs = True
                    if int(fd_paragraph.get('Number')) == end_with_scene:
                        renderParagraphs = False
                    ptype = "sceneheader"
                elif ptype == "Transition":
                    ptype = "transition"
                elif ptype == "Teaser/Act One":
                    ptype = "header"
                elif ptype == "New Act":
                    ptype = "header"
                elif ptype == "End Of Act":
                    ptype = "header"
                else:
                    ptype = "action"
                #UNHANDLED FOR THE MOMENT
                #Show/Ep. Title
                ptext = []
                for fd_text in fd_paragraph.findall("Text"):
                    text_style = fd_text.get('Style')
                    if fd_text.text != None:
                        if "FADE IN:" in fd_text.text.upper():
                            fd_text.text = fd_text.text.upper()
                        if ptype in ["character","transition","sceneheader","header","shot"]:
                            fd_text.text = fd_text.text.upper()
                        #clean smart quotes
                        fd_text.text = fd_text.text.replace(u"\u201c", "\"").replace(u"\u201d", "\"") #strip double curly quotes
                        fd_text.text  = fd_text.text.replace(u"\u2018", "'").replace(u"\u2019", "'").replace(u"\u02BC", "'") #strip single curly quotes
                        ptext.append({"style":text_style,"text":fd_text.text})
                content = []
                for block in ptext:
                    if block["style"] == "Italic":
                        
                        content.append(tag.i(block["text"]))
                    elif block["style"] == "Underline":
                        content.append(tag.u(block["text"]))
                    elif block["style"] == "Bold":
                        content.append(tag.b(block["text"]))
                    elif block["style"] == "Bold+Underline":
                        content.append(tag.b(tag.u(block["text"])))
                    else:
                        content.append(block["text"])
                if renderParagraphs:
                    theoutput.append(tag.p(content,class_=ptype+mode))
        return theoutput
Beispiel #2
0
    def render(self, context, mimetype, content, filename=None, url=None):
        add_stylesheet(context.req, 'scrippets/css/scrippets-full.css')
        if hasattr(content, 'read'):
            content = content.read()
        mode = "-full"
        theoutput = tag.div(class_="scrippet" + mode)
        fd_doc = cElementTree.fromstring(content)
        for fd_content in fd_doc.findall("Content"):
            for fd_paragraph in fd_content.findall("Paragraph"):
                ptype = fd_paragraph.get('Type')
                if ptype == "Action":
                    ptype = "action"
                elif ptype == "Character":
                    ptype = "character"
                elif ptype == "Dialogue":
                    ptype = "dialogue"
                elif ptype == "Parenthetical":
                    ptype = "parenthetical"
                elif ptype == "Scene Heading":
                    ptype = "sceneheader"
                elif ptype == "Shot":
                    ptype = "shot"
                elif ptype == "Transition":
                    ptype = "transition"
                elif ptype == "Teaser/Act One":
                    ptype = "header"
                elif ptype == "New Act":
                    ptype = "header"
                elif ptype == "End Of Act":
                    ptype = "header"
                else:
                    ptype = "action"
                #UNHANDLED FOR THE MOMENT
                #Show/Ep. Title
                ptext = []
                for fd_text in fd_paragraph.findall("Text"):
                    text_style = fd_text.get('Style')
                    if fd_text.text != None:
                        if "FADE IN:" in fd_text.text.upper():
                            fd_text.text = fd_text.text.upper()
                        if ptype in [
                                "character", "transition", "sceneheader",
                                "header", "shot"
                        ]:
                            fd_text.text = fd_text.text.upper()
                        #clean smart quotes
                        fd_text.text = fd_text.text.replace(
                            u"\u201c",
                            "\"").replace(u"\u201d",
                                          "\"")  #strip double curly quotes
                        fd_text.text = fd_text.text.replace(
                            u"\u2018", "'").replace(u"\u2019", "'").replace(
                                u"\u02BC", "'")  #strip single curly quotes
                        ptext.append({
                            "style": text_style,
                            "text": fd_text.text
                        })
                content = []
                for block in ptext:
                    if block["style"] == "Italic":

                        content.append(tag.i(block["text"]))
                    elif block["style"] == "Underline":
                        content.append(tag.u(block["text"]))
                    elif block["style"] == "Bold":
                        content.append(tag.b(block["text"]))
                    elif block["style"] == "Bold+Underline":
                        content.append(tag.b(tag.u(block["text"])))
                    else:
                        content.append(block["text"])
                theoutput += tag.p(content, class_=ptype + mode)
        for fd_titlepage in fd_doc.findall("TitlePage"):
            for fd_content in fd_titlepage.findall("Content"):
                for fd_paragraph in fd_content.findall("Paragraph"):
                    ptype = fd_paragraph.get('Type')
                    for fd_text in fd_paragraph.findall("Text"):
                        text_style = fd_text.get('Style')
                        if fd_text.text != None:
                            self.log.debug("SCRIPPET: " + fd_text.text)

        return "%s" % theoutput
Beispiel #3
0
 def render(self, context, mimetype, content, filename=None, url=None):
     add_stylesheet(context.req, 'scrippets/css/scrippets-full.css')
     if hasattr(content, 'read'):
         content = content.read()
     mode = "-full"
     theoutput = tag.div(class_="scrippet"+mode)
     fd_doc = cElementTree.fromstring(content)
     for fd_content in fd_doc.findall("Content"):
         for fd_paragraph in fd_content.findall("Paragraph"):
             ptype = fd_paragraph.get('Type')
             if ptype == "Action":
                 ptype = "action"
             elif ptype == "Character":
                 ptype = "character"
             elif ptype == "Dialogue":
                 ptype = "dialogue"
             elif ptype == "Parenthetical":
                 ptype = "parenthetical"
             elif ptype == "Scene Heading":
                 ptype = "sceneheader"
             elif ptype == "Shot":
                 ptype = "shot"
             elif ptype == "Transition":
                 ptype = "transition"
             elif ptype == "Teaser/Act One":
                 ptype = "header"
             elif ptype == "New Act":
                 ptype = "header"
             elif ptype == "End Of Act":
                 ptype = "header"
             else:
                 ptype = "action"
             #UNHANDLED FOR THE MOMENT
             #Show/Ep. Title
             ptext = []
             for fd_text in fd_paragraph.findall("Text"):
                 text_style = fd_text.get('Style')
                 if fd_text.text != None:
                     if "FADE IN:" in fd_text.text.upper():
                         fd_text.text = fd_text.text.upper()
                     if ptype in ["character","transition","sceneheader","header","shot"]:
                         fd_text.text = fd_text.text.upper()
                     #clean smart quotes
                     fd_text.text = fd_text.text.replace(u"\u201c", "\"").replace(u"\u201d", "\"") #strip double curly quotes
                     fd_text.text  = fd_text.text.replace(u"\u2018", "'").replace(u"\u2019", "'").replace(u"\u02BC", "'") #strip single curly quotes
                     ptext.append({"style":text_style,"text":fd_text.text})
             content = []
             for block in ptext:
                 if block["style"] == "Italic":
                     
                     content.append(tag.i(block["text"]))
                 elif block["style"] == "Underline":
                     content.append(tag.u(block["text"]))
                 elif block["style"] == "Bold":
                     content.append(tag.b(block["text"]))
                 elif block["style"] == "Bold+Underline":
                     content.append(tag.b(tag.u(block["text"])))
                 else:
                     content.append(block["text"])
             theoutput += tag.p(content,class_=ptype+mode)
     for fd_titlepage in fd_doc.findall("TitlePage"):
         for fd_content in fd_titlepage.findall("Content"):
             for fd_paragraph in fd_content.findall("Paragraph"):
                 ptype = fd_paragraph.get('Type')
                 for fd_text in fd_paragraph.findall("Text"):
                     text_style = fd_text.get('Style')
                     if fd_text.text != None:
                         self.log.debug("SCRIPPET: " + fd_text.text)
                 
     
     return "%s" % theoutput