def MOW( self ): # Using self.reco_action and self.reco_type to get reco_action_mow and reco_type_mow try: for i in self.ptag: header = i.get_text() body = i.get_text() ORIG = orig.Return_ORIG() string = "to\s+([A-Za-z]*)" string2 = "a\s+([A-Za-z]*)" ORIG.rec_type_mow(body) reco_type = ORIG.reco_type reco_action = re.findall(string, body) if (reco_action == []): reco_action = re.findall(string2, body) if (reco_action == []): reco_action = '' else: reco_action = reco_action[0] MOW1 = mow.MOW() MOW1.rec_act_mow(reco_action) reco_action_mow = MOW1.reco_action_mow MOW1.rec_type_mow(reco_type) reco_type_mow = MOW1.reco_type_mow self.reco_action.append(reco_action) self.reco_action_mow.append(reco_action_mow) self.reco_type.append(reco_type) self.reco_type_mow.append(reco_type_mow) except Exception, e: print str(e)
def Get_the_RecoAction_origmow_and_RecoType_origmow( self, Ticker, Ticker_Date ): ### Extracting the RecoAction and RecoType using regex self.Make_file_for_source_code(Ticker) with open("RecoAction_orig.txt", "r") as fo: data = fo.read().replace("\n", "") reg = re.findall(r'<tbody.*?>(.*?)</tbody>', data) reg1 = re.findall(r'<tr.*?>(.*?)</tr>', str(reg[0])) for li in reg1: row = re.findall(r'<td.*?>(.*?)</td>', li) date_format_change = date_format.convert_date(row[0]) date_format_change.convert_into_a_specific_format() date_changed = date_format_change.final count = 0 if date_changed in Ticker_Date or Ticker_Date in date_changed: if row[1] != "": splited_firm_name = row[1].split() length = len(splited_firm_name) for i in xrange(length): if splited_firm_name[i] in self.data: count = count + 1 if count != 0: self.firm = row[1] self.reco_type = row[2] self.reco_action = row[4] self.PriceTarget = row[5] break # Using self.reco_action and self.reco_type to get reco_action_mow and reco_type_mow MOW1 = mow.MOW() ### Might want to change this MOW1.rec_act_mow(self.reco_action) MOW1.rec_type_mow(self.reco_type) self.reco_action_mow = MOW1.reco_action_mow self.reco_type_mow = MOW1.reco_type_mow fo.close()
def MOW( self ): # Using self.reco_action and self.reco_type (from the header here) to get reco_action_mow and reco_type_mow ORIG = orig.Return_ORIG() ORIG.rec_type_mow(self.data) action1 = re.findall( 'from\s+[^ \t\n\r\f\v0-9]*\s+to\s+([^ \t\n\r\f\v0-9]*)', self.data) action2 = re.findall('([^ \t\n\r\f\v0-9]*)\s+rating', self.data) action3 = re.findall('at\s+([^ \t\n\r\f\v0-9]*)', self.data) if action1 == []: pass else: self.reco_action = action1[0] if (self.reco_action != '' and not (action2 == []) and not (rec_act_mow(self.reco_action))): self.reco_action = action2[0] if (self.reco_action != '' and not (action3 == []) and not (rec_act_mow(self.reco_action))): self.reco_action = action3[0] self.reco_type = ORIG.reco_type MOW1 = mow.MOW() MOW1.rec_act_mow(self.reco_action) self.reco_action_mow = MOW1.reco_action_mow #print self.rec_act_mow MOW1.rec_type_mow(self.reco_type) self.reco_type_mow = MOW1.reco_type_mow
def MOW(self): # Using self.reco_action and self.reco_type to get reco_action_mow and reco_type_mow MOW1 = mow.MOW() MOW1.rec_act_mow(self.header) self.reco_action_mow = MOW1.reco_action_mow MOW1.rec_type_mow(self.header) self.reco_type_mow = MOW1.reco_type_mow ORIG = orig.Return_ORIG() ORIG.rec_act_mow(self.header) ORIG.rec_type_mow(self.header) self.reco_action = ORIG.reco_action self.reco_type = ORIG.reco_type
def MOW(self): # Using self.reco_action and self.reco_type (from the header here) to get reco_action_mow and reco_type_mow ORIG = orig.Return_ORIG() ORIG.rec_type_mow(self.data) ORIG.rec_act_mow(self.data) self.reco_action = ORIG.reco_action self.reco_type = ORIG.reco_type MOW1 = mow.MOW() MOW1.rec_act_mow(self.reco_action) self.reco_action_mow = MOW1.reco_action_mow #print self.rec_act_mow MOW1.rec_type_mow(self.reco_type) self.reco_type_mow = MOW1.reco_type_mow
def MOW( self ): # Using self.reco_action and self.reco_type to get reco_action_mow and reco_type_mow try: #MOW(key[0].get_text().encode('utf-8'),value[0].get_text().encode('utf-8')) for i in range(0, len(self.value)): #print self.value[i] ORIG = orig.Return_ORIG() string = "to\s+([A-Za-z]*)" string2 = "a\s+([A-Za-z]*)" ORIG.rec_type_mow(self.value[i].get_text().encode('utf-8')) reco_type = ORIG.reco_type self.reco_type.append(reco_type) reco_action = re.findall( string, self.value[i].get_text().encode('utf-8')) #print reco_action if (reco_action == []): reco_action = re.findall( string2, self.value[i].get_text().encode('utf-8')) #print reco_action if (reco_action == []): reco_action = '' else: reco_action = reco_action[0] self.reco_action.append(reco_action) MOW1 = mow.MOW() MOW1.rec_act_mow(reco_action) reco_action_mow = MOW1.reco_action_mow #print reco_action_mow self.reco_action_mow.append(reco_action_mow) MOW1.rec_type_mow(reco_type) reco_type_mow = MOW1.reco_type_mow self.reco_type_mow.append(reco_type_mow) except Exception, e: print str(e)