# Path: fooltrader/contract/files_contract.py
# def get_code_from_path(the_path, security_type='stock'):
#     the_dir = os.path.join(settings.FOOLTRADER_STORE_PATH, security_type)
#     if the_dir in the_path:
#         strs = the_path[len(the_dir):].split('/')
#         if len(strs) > 2:
#             return strs[2]
# 
# Path: fooltrader/settings.py
# FOOLTRADER_STORE_PATH = os.environ.get('FOOLTRADER_STORE_PATH')
# 
# STOCK_END_CODE = '666666'
# 
# STOCK_START_CODE = '000001'


import datetime
import os
import zipfile
from fooltrader.contract.files_contract import get_code_from_path
from fooltrader.settings import FOOLTRADER_STORE_PATH, STOCK_END_CODE, STOCK_START_CODE
    else:
        dst_path = os.path.abspath(os.path.join(src_dir, os.pardir, zip_file_name))

    the_zip_file = zipfile.ZipFile(dst_path, 'w')

    for folder, subfolders, files in os.walk(src_dir):
        for file in files:
            the_path = os.path.join(folder, file)
            # 过滤code
            current_code = get_code_from_path(the_path=the_path)
            if current_code:
                if current_code > end_code or current_code < start_code:
                    continue

            # 只打包tick
            if just_tick:
                if not 'tick' in the_path:
                    continue
            # 不打包tick
            elif not include_tick and 'tick' in the_path:
                continue

            print("zip {}".format(the_path))
            the_zip_file.write(the_path,
                               os.path.relpath(the_path, src_dir),
                               compress_type=zipfile.ZIP_DEFLATED)

    the_zip_file.close()



# Path: fooltrader/contract/files_contract.py
# def get_code_from_path(the_path, security_type='stock'):
#     the_dir = os.path.join(settings.FOOLTRADER_STORE_PATH, security_type)
#     if the_dir in the_path:
#         strs = the_path[len(the_dir):].split('/')
#         if len(strs) > 2:
#             return strs[2]
# 
# Path: fooltrader/settings.py
# FOOLTRADER_STORE_PATH = os.environ.get('FOOLTRADER_STORE_PATH')
# 
# STOCK_END_CODE = '666666'
# 
# STOCK_START_CODE = '000001'


# Path: fooltrader/datamanager/zipdata.py
import datetime
import os
import zipfile
from fooltrader.contract.files_contract import get_code_from_path
from fooltrader.settings import FOOLTRADER_STORE_PATH, STOCK_END_CODE, STOCK_START_CODE

    else:
        dst_path = os.path.abspath(os.path.join(src_dir, os.pardir, zip_file_name))

    the_zip_file = zipfile.ZipFile(dst_path, 'w')

    for folder, subfolders, files in os.walk(src_dir):
        for file in files:
            the_path = os.path.join(folder, file)
            # 过滤code
            current_code = get_code_from_path(the_path=the_path)
            if current_code:
                if current_code > end_code or current_code < start_code:
                    continue

            # 只打包tick
            if just_tick:
                if not 'tick' in the_path:
                    continue
            # 不打包tick
            elif not include_tick and 'tick' in the_path:
                continue

            print("zip {}".format(the_path))
            the_zip_file.write(the_path,
                               os.path.relpath(the_path, src_dir),
                               compress_type=zipfile.ZIP_DEFLATED)

    the_zip_file.close()



def zip_data(src_dir=FOOLTRADER_STORE_PATH, dst_dir=None, zip_file_name=None):