def run_unzip_file(configData: ConfigData):
    f_date_str = configData.get_f_date()  # "20181101"

    zip_path = os.path.join(configData.get_zip_path(), f_date_str)
    # root_path = configData.get_data("allinpay_data_zc")
    data_path = os.path.join(configData.get_data_path(), f_date_str)   # allinpay_data_zc

    #    ifile = '/home/testFolder/logflow/bl_shouyinbao/20181101/9999100000/t1_trxrecord_20181101_V2.csv'
    #    ofile = '/home/testFolder/logflow/bl_shouyinbao/UTF8/20181101/9999100000/t1_trxrecord_20181101_V2.csv'

    print("Start\n")

    # os.path.join(root_path, the_date) # real SYB folder don't have date folder

    f_name = configData.get_zip_name(f_date_str)  # 3= the_date+".zip" # 5 = the_date+"_agt.zip"
    a_file = os.path.join(zip_path, f_name)
    p_name = configData.get_file_name(f_date_str)  # p_date+"*"
    if MyLocalFile.check_file(a_file):
        MyLocalFile.unzip_the_file(a_file, data_path, p_name=p_name)
示例#2
0
def run_unzip_file(configData: ConfigData, folder_type=2):
    f_date_str = configData.get_f_date()  # "20181101"

    if (type(f_date_str) is str) and len(f_date_str) == 8:
        m_month = f_date_str[0:6]
        m_day = f_date_str[6:8]
    else:
        return

    zip_path = configData.get_zip_path()
    data_path = configData.get_data_path()

    f_name = configData.get_zip_name("")  # "t1_trxrecord_" the_date # "_V2.csv"

    print("Start\n")

    # os.path.join(root_path, the_date) # real SYB folder don't have date folder
    branches = MyLocalFile.get_child_dir(zip_path)
    for aBranch in branches:
        if MyLocalFile.check_branch(aBranch):
            months = MyLocalFile.get_child_dir(aBranch)
            for aMonth in months:
                the_month = MyLocalFile.check_month(aMonth)
                if the_month > 0 and "{:0>6d}".format(the_month) == m_month:
                    day_list = MyLocalFile.get_child_dir(aMonth)
                    for aDay in day_list:
                        the_day = MyLocalFile.check_day(aDay)
                        if the_day > 0 and "{:0>2d}".format(the_day) == m_day:
                            files = MyLocalFile.get_child_file(aDay)
                            for aFile in files:
                                if MyLocalFile.check_file(aFile, p_name=f_name):
                                    short_name = os.path.basename(aBranch)
                                    if folder_type == 1:
                                        new_path = os.path.join(data_path, m_month, m_day, short_name)
                                        # "{:0>6d}".format(month)  "{:0>2d}".format(day)
                                    else:
                                        new_path = os.path.join(data_path, f_date_str, short_name)
                                        # "{:0>6d}{:0>2d}".format(month, day)
                                    p_name = configData.get_file_name(f_date_str)
                                    MyLocalFile.unzip_the_file(aFile, new_path, p_name)