# Path: ramjet/tasks/twitter/base.py
# def get_md5_hierachy_dir(fname: str) -> str:
#     hashed = md5(fname.encode("utf8")).hexdigest()
#     c1, c2 = hashed[:2], hashed[2:4]
#     return os.path.join(c1, c2, fname)


import os
import time
from pathlib import Path
from shutil import copy2
from typing import Generator, Iterator
from kipp.options import opt
from kipp.utils import setup_logger
from ramjet.tasks.twitter.base import get_md5_hierachy_dir


logger = setup_logger("move_files", debug=True)


def main():
    start_at = time.time()
    opt.add_argument("--path", type=str, required=True)
    opt.parse_args()

    for f in gen_all_files(opt.path):
        p = Path(f)
        p = Path(p.parent, get_md5_hierachy_dir(p.name))

# Path: ramjet/tasks/twitter/base.py
# def get_md5_hierachy_dir(fname: str) -> str:
#     hashed = md5(fname.encode("utf8")).hexdigest()
#     c1, c2 = hashed[:2], hashed[2:4]
#     return os.path.join(c1, c2, fname)


# Path: ramjet/tasks/twitter/move_files.py
import os
import time
from pathlib import Path
from shutil import copy2
from typing import Generator, Iterator
from kipp.options import opt
from kipp.utils import setup_logger
from ramjet.tasks.twitter.base import get_md5_hierachy_dir



logger = setup_logger("move_files", debug=True)


def main():
    start_at = time.time()
    opt.add_argument("--path", type=str, required=True)
    opt.parse_args()

    for f in gen_all_files(opt.path):
        p = Path(f)
        p = Path(p.parent, get_md5_hierachy_dir(p.name))

        p.parent.mkdir(parents=True, exist_ok=True)