def WikiUpdate(self, wikipage): import Keyword re_firstchar = re.compile(r'(\w)', re.UNICODE).search # signs of UTF8 mojibake if isinstance(wikipage,unicode) and u'\xc3' in wikipage: wikipage = wikipage.encode('latin-1').decode('utf-8') import Wiki wikimgr = Wiki.WikiManager() wikimgr.Download(wikipage) wikimgr.Parse(wikipage) wikimgr.Relate(wikipage) if wikipage.startswith("SFS/"): import SFS sfsnr = wikipage.split("/",1)[1] sfsmgr = SFS.SFSManager() sfsmgr.config['sfs']['generate_force'] = 'True' sfsmgr.Generate(sfsnr) elif wikipage.startswith("Dom/"): pass elif ":" in wikipage: # not in default namespace, probably (namespace,localpage) = wikipage.split(":",1) if namespace == "Kategori": firstletter = re_firstchar(localpage).group(0) basefile = u'%s/%s' % (firstletter,localpage) kwmgr = Keyword.KeywordManager() kwmgr.config['keyword']['parse_force'] = 'True' kwmgr.config['keyword']['generate_force'] = 'True' kwmgr.Parse(basefile,wiki_keyword=True) # needed for new terms kwmgr.Generate(basefile) elif namespace == "Lagen.nu" and localpage == "Huvudsida": self._prep_frontpage() infile = Util.relpath(os.path.sep.join([__scriptdir__,'static','index.xht2'])) outfile = Util.relpath(os.path.sep.join([self.baseDir,'site','generated','index.html'])) print "in %s, out %s" % (infile,outfile) Util.transform(__scriptdir__+"/xsl/static.xsl", infile, outfile, validate=False, xinclude=True) else: firstletter = re_firstchar(wikipage).group(0) basefile = u'%s/%s' % (firstletter,wikipage) kwmgr = Keyword.KeywordManager() kwmgr.config['keyword']['parse_force'] = 'True' kwmgr.config['keyword']['generate_force'] = 'True' kwmgr.Parse(basefile,wiki_keyword=True) # needed for new terms # raise ValueError(repr(basefile)) kwmgr.Generate(basefile)
def __init__(self): super(KeywordManager, self).__init__() # we use the display_title function import SFS self.sfsmgr = SFS.SFSManager()