Ejemplo n.º 1
0
def runCopyFile(conf: ConfigData, isBaoli=True):
    thedate = conf.test_date()  #"20181101"
    root_path = conf.get_zip_path(1)
    destdir = conf.get_data_path(1)
    destdir = os.path.join(destdir, thedate)

    f_name = conf.get_zip_name("*", 1)  # "t1_trxrecord_"  # "_V2.csv"

    print("Start\n")

    branchs = MyLocalFile.get_child(root_path)
    for aBranch in branchs:
        if MyLocalFile.check_branch(aBranch):
            monthes = MyLocalFile.get_child(aBranch)
            for aMonth in monthes:
                theMonth = MyLocalFile.check_month(aMonth)
                if theMonth > 0:
                    days = MyLocalFile.get_child(aMonth)
                    for aDay in days:
                        theDay = MyLocalFile.check_day(aDay)
                        if theDay > 0:
                            files = MyLocalFile.get_child(aDay)
                            for aFile in files:
                                if MyLocalFile.check_file(aFile,
                                                          p_name=f_name):
                                    copyTheFile(destdir, aBranch, theMonth,
                                                theDay, aFile, 1)
Ejemplo n.º 2
0
def run_unzip_file(conf: ConfigData, the_date, folder_type=2):
    the_date = StrTool.get_the_date_str(the_date)
    if (type(the_date) is str) and len(the_date) == 8:
        m_month = the_date[0:6]
        m_day = the_date[6:8]
    else:
        return

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

    f_name = conf.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, m_month + m_day,
                                            short_name)
                                        # "{:0>6d}{:0>2d}".format(month, day)
                                    p_name = conf.get_file_name(m_month +
                                                                m_day)
                                    MyLocalFile.unzip_the_file(
                                        aFile, new_path, p_name)