def pttBuild(self, d): dbHandler = MySQLHandler() mysqlData = dbHandler.getOnePttSource(d['b_author'], d['d_date'])[0] oracletDict = {} print mysqlData['title'] print type(mysqlData['title']) codeInfo = self.newFindCode(mysqlData['title'], mysqlData['content']) if codeInfo != False: oracletDict['name'] = mysqlData['author'].split(u'(')[0] oracletDict['date'] = mysqlData['date'].date() oracletDict['code'] = codeInfo[0] oracletDict['targetName'] = codeInfo[1] oracletDict['type'] = codeInfo[2] oracletDict['event'] = self.newgetEvent(mysqlData['content'], mysqlData['title']) print 'event:', oracletDict['event'] oracletDict['occurTime'] = self.getOccurTime( mysqlData['content'], oracletDict['date']) oracletDict['nowprice'] = None # if oracletDict['type']==5: # oracletDict['nowprice']=TwseHandler().getNowPrice(oracletDict['date'],oracletDict['code']) # elif oracletDict['type']==6: # oracletDict['nowprice']= GtsmHandler().getNowPrice(oracletDict['date'],oracletDict['code']) # if oracletDict['name']==u'bbs3379': # print 'test' # 4/5問題集1,目前先用==None代替 # if oracletDict['nowprice']==False or oracletDict['nowprice'] == 0 \ # or oracletDict['nowprice'] ==None or oracletDict['event']==False: # return False if oracletDict['event'] == False: return False else: # 需判斷有沒有預測人啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if dbHandler.getPredictPeople(oracletDict['name']) == False: dbHandler.setOnePredictPeople(oracletDict['name'], '2') pass dbHandler.setOneOraclet(oracletDict) return oracletDict else: return False pass
def dataToMYsql(self, d): dbHandler = MySQLHandler() pttSource = dbHandler.getOnePttSource(d['b_author'], d['d_date']) if pttSource == False: # 新增ptt_source dbHandler.setOnePttSource(d) # 卜卦立案 oracletDict = self.pttBuild(d) if oracletDict != False: # 毛盾卜卦找尋集更新、更新留言庫 dbHandler.setOneContradiction(oracletDict) messagestr = d['g_message'].replace('\\', '') message = SetOracletHandler.normalizeMessage(messagestr) dbHandler.setNewMessage(message, oracletDict) else: # 拿取oracelt 沒拿到代表不用做更新 dbHandler.updatePttsource(d['b_author'], d['d_date'], d['g_message']) self.updatePttAndMessage(pttSource, d) # 檢查是否需要更新ptt_source、更新留言庫 pass pass