當前位置: 首頁>>代碼示例>>Python>>正文


Python Suspect.getSource方法代碼示例

本文整理匯總了Python中fuglu.shared.Suspect.getSource方法的典型用法代碼示例。如果您正苦於以下問題:Python Suspect.getSource方法的具體用法?Python Suspect.getSource怎麽用?Python Suspect.getSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fuglu.shared.Suspect的用法示例。


在下文中一共展示了Suspect.getSource方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_modified_message

# 需要導入模塊: from fuglu.shared import Suspect [as 別名]
# 或者: from fuglu.shared.Suspect import getSource [as 別名]
 def test_modified_message(self):
     """Test if the modified message gets archived correctly"""
     from fuglu.shared import Suspect
     import shutil
     import tempfile
     
     tempfilename=tempfile.mktemp(suffix='archive', prefix='fuglu-unittest', dir='/tmp')
     shutil.copy('testdata/helloworld.eml',tempfilename)
     self.tempfiles.append(tempfilename)
     
     #
     self.config.set('ArchivePlugin', 'storeoriginal', '0')
     candidate=ArchivePlugin(self.config)
     suspect=Suspect('[email protected]', '[email protected]', tempfilename)
     origmessage=suspect.getSource()
     #modify the mesg
     msgrep= suspect.get_message_rep()
     msgrep['X-Changed-Something']='Yes'
     suspect.setMessageRep(msgrep)
     
     filename=candidate.archive(suspect)
     self.assertTrue(filename!=None and filename)
     
     self.tempfiles.append(filename)
     
     archivedmessage=open(filename,'r').read()
     self.assertNotEqual(origmessage.strip(),archivedmessage.strip()),'Archived message should have stored modified message' 
     
開發者ID:gryphius,項目名稱:fuglu-travis-test,代碼行數:29,代碼來源:archive.py

示例2: type

# 需要導入模塊: from fuglu.shared import Suspect [as 別名]
# 或者: from fuglu.shared.Suspect import getSource [as 別名]
    #now run examine
    logging.info("Running plugin: %s"%pluginstance)
    
    if opts.appender:
        #todo: maybe make DUNNO configurable? 2nd argument?
        pluginstance.process(suspect,DUNNO)
        
    else:
        ans = pluginstance.examine(suspect)
        message=""
        if type(ans) is tuple:
            result,message=ans
        else:
            result=ans
        
        if result==None:
            result=DUNNO
    
        logging.info("Result: %s %s",actioncode_to_string(result), message)
        logging.info(suspect)
        
        if suspect.is_modified():
            outfilename='/tmp/fuglu_dummy_message_out.eml'
            out=open(outfilename,'wb')
            out.write(suspect.getSource())
            out.close()
            logging.info("Plugin modified the source -> modified message available as %s"%outfilename)
        
    if opts.console:
        run_debugconsole(suspect=suspect, plugin=pluginstance, result=result, config=config)
開發者ID:gryphius,項目名稱:fuglu-travis-test,代碼行數:32,代碼來源:plugdummy.py


注:本文中的fuglu.shared.Suspect.getSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。