Ejemplo n.º 1
0
def meta_dict(meta_dict, brand_dict, name, b_type, status, time, bid, tree):
    if not pd.isnull(name):
        tree.add(sim_model.resub_string(str(name) + '_' + b_type, resub_list))
        meta_dict['brand_name'] = name
        meta_dict['brand_type'] = b_type
        meta_dict['status'] = status
        meta_dict['last_insert'] = time
        meta_dict['brand_id'] = bid
        wrong = 0
        try:
            brand_dict[safe_unicode(str(name) + '_' + b_type)] = meta_dict
        except:
            wrong += 1
Ejemplo n.º 2
0
def add_info_tree(table, name, companyid, cn_table, opendate_col):
    if cn_table == 'ENGINEE_SITE':
        table_index = '1'
    elif cn_table == 'budget_cf_company':
        table_index = '2'
    elif cn_table == 'MERCHANT_PLAZAINFO':
        table_index = '3'
    elif cn_table == 'field_w_org_ds':
        table_index = '4'
    elif cn_table == 'entactmgt_tpm_project':
        table_index = '5'
    elif cn_table == 'lease_bf_plaza':
        table_index = '6'
    elif cn_table == 'PASSENGERODS_PLAZAINFO':
        table_index = '7'
    else:
        table_index = '8'
    for i in range(len(table[name])):
        if pd.isnull(table[name][i]):
            continue
        if pd.isnull(table[opendate_col][i]):
            #print table[opendate_col][i]
            table[opendate_col][i] = datetime.datetime.now()
        if isinstance(table[name][i], unicode):
            company_name = add_string(table[name][i], _list)
            #print table[opendate_col][i]

            if cn_table in [
                    'PASSENGER_DIMPLAZA', 'lease_bf_plaza',
                    'PASSENGERODS_PLAZAINFO'
            ]:
                opendate = pd.to_datetime(
                    str(table[opendate_col][i]).split()[0])
            else:
                opendate = table[opendate_col][i]
            #print type(company_name)
            #company_name = "hello,world!!%[545]你好234世界。。。"
            company_name2 = re.sub("[A-Za-z0-9\!\%\[\]\,\。\(\)]", "",
                                   company_name)
            #print type(company_name)
            tree.add(
                sim_model.resub_string(company_name2 + '_' + table_index,
                                       resub_list))

            company_info_dict[company_name2 + '_' + table_index] = meta_info(
                table[name][i], companyid, table[companyid][i], cn_table,
                opendate)
            #COMPANYNAME
        else:
            continue
Ejemplo n.º 3
0
    def insert(self, brand_name, status, brand_type, brand_id):
        #print('ddddddd:',brand_name)
        meta_info = {}
        self.tree.add(
            sim_model.resub_string(
                str(brand_name) + '_' + brand_type, resub_list))
        last_insert = convert_dt_to_epoch(datetime.datetime.now())
        meta_info['brand_name'] = brand_name
        meta_info['brand_type'] = brand_type
        meta_info['status'] = status
        meta_info['last_insert'] = last_insert
        meta_info['brand_id'] = brand_id

        self.brand_info_dict[safe_unicode(str(brand_name) + '_' +
                                          brand_type)] = meta_info
Ejemplo n.º 4
0
    def insert(self, brand_name, status, brand_type):

        self.tree.add(
            sim_model.resub_string(brand_name + '_' + brand_type, resub_list))
        last_insert = convert_dt_to_epoch(datetime.datetime.now())
        self.meta_info['brand_name'] = brand_name
        self.meta_info['brand_type'] = brand_type
        self.meta_info['status'] = status
        self.meta_info['last_insert'] = last_insert

        self.brand_info_dict['brand_index'] = brand_name + '_' + brand_type
        self.brand_info_dict['brand_index_info'] = self.meta_info
        print(self.brand_info_dict)
        db.table(brand_TABLE).insert(self.brand_info_dict)
        return self.tree