def prepForPublicus(brief,profileID,slug): from slugTools import wrapAndWrite from slugTools import openArticle from slugTools import closeArticle from slugTools import tomorrowString filename=slug #slug = slug + '.xml' slug = '/Users/Editmac05/Documents/bin/briefs/workbin/' + slug + '.xml' fileXML = open(slug,'w') openArticle(fileXML) briefHed = brief briefBody = brief briefHed = re.sub(r'(.*<.generic_head>).*',r'\1',briefHed) briefHed = re.sub(r'<EP>',r' ',briefHed) briefHed = re.sub(r' <.gen',r'</gen',briefHed) print "brief hed = " + briefHed briefHed = re.sub(r'generic_head','headline',briefHed) briefHed = re.sub(r'<NO.*?>',r'<NO>',briefHed) briefHed = re.sub(r'<NO>.*?<NO>',r'',briefHed) wrapAndWrite("filename",filename,fileXML) wrapAndWrite("profileId",profileID,fileXML) wrapAndWrite("Gns","",fileXML) wrapAndWrite("keyword","BRIEF",fileXML) wrapAndWrite("pubdate",tomorrowString(),fileXML) #wrapAndWrite("pubdate",'2/7/2012',fileXML) wrapAndWrite("edition","",fileXML) wrapAndWrite("section","",fileXML) print >> fileXML, briefHed briefBody = re.sub(r'.*_head>',r'',briefBody) #print "briefBody = " + briefBody hasDateline = re.search('<dateline>',briefBody) #print "hasdateline = " + hasDateline if hasDateline: dateline = re.sub(r'(.*<.dateline>).*',r'\1',briefBody) briefBody = re.sub(r'.*<.dateline>(.*)',r'\1',briefBody) print "dateline = " + dateline dateline = re.sub(r'.*(<dateline>)',r'\1',dateline) print "dateline revised = " + dateline #print "briefbody = " + briefBody print >> fileXML, dateline briefBody = re.sub(r'#EOM#',r'',briefBody) #print "1. briefbody = " + briefBody briefBody = re.sub(r'<NO.*?>',r'<NO>',briefBody) #print "2. briefbody = " + briefBody briefBody = re.sub(r'<NO>.*?<NO>',r'',briefBody) #briefBody = re.sub(r'<EP>',r'</body_text><body_text>',briefBody) briefGrafs = briefBody.split('<EP>') for graf in briefGrafs: graf = signatureFixed(graf) graf = webFixed(graf) wrapAndWrite('body_text',graf,fileXML) #wrapAndWrite('body_text',briefBody,fileXML) closeArticle(fileXML) return
# Now that full dateline has been used to isolate thestory text, we localize it. # This really means taking out 'N.J.' for an in-state story. summary['dateline']=slugTools.localize(summary['dateline']) # testing to keep fake stories out of today's list #pubDate = '12/01/11' # <<<<<<< remove when live slugTools.openArticle(fileXML) slugTools.wrapAndWrite('filename',theSlug,fileXML) slugTools.wrapAndWrite('profileId',str(profileId),fileXML) slugTools.wrapAndWrite('Gns','',fileXML) slugTools.wrapAndWrite('keyword','topnews',fileXML) slugTools.wrapAndWrite('pubdate',pubDate,fileXML) slugTools.wrapAndWrite('pagenumber','',fileXML) slugTools.wrapAndWrite('edition','',fileXML) slugTools.wrapAndWrite('section','',fileXML) slugTools.wrapAndWrite('headline',summary['headline'],fileXML) slugTools.wrapAndWrite('dateline',summary['dateline'],fileXML) slugTools.wrapAndWrite('byline_name',slugTools.bylineName(summary['byline']),fileXML) slugTools.wrapAndWrite('byline_credit',slugTools.bylineCredit(summary['byline']),fileXML) #slugTools.wrapAndWrite('body_text','This is dummy text.',fileXML) APtext.printStoryText(pubText,fileXML) slugTools.closeArticle(fileXML)