Spaces:
Running
Running
Upload utils.py
Browse files120 unmodified lines121122123124125126127128129120 unmodified linesif not os.path.exists(target_dir_for_contents):os.makedirs(target_dir_for_contents)src_root = temp_dirif len(os.listdir(temp_dir)) == 1 and os.path.isdir(os.path.join(temp_dir, os.listdir(temp_dir)[0])):src_root = os.path.join(temp_dir, os.listdir(temp_dir)[0])for item in os.listdir(src_root):shutil.move(os.path.join(src_root, item), os.path.join(target_dir_for_contents, item))120 unmodified lines121122123124125126127128129130131132133134135136137120 unmodified linesif not os.path.exists(target_dir_for_contents):os.makedirs(target_dir_for_contents)downloaded_items = os.listdir(temp_dir)src_root = temp_dir# gdown often creates a single wrapper directory for the downloaded folder.# Flatten that wrapper for normal source folders, but preserve app_faqs/ so# sources/app_faqs/faqs.csv stays separate from the main knowledgebase.if len(downloaded_items) == 1:single_item = downloaded_items[0]single_path = os.path.join(temp_dir, single_item)if os.path.isdir(single_path) and single_item != "app_faqs":src_root = single_pathfor item in os.listdir(src_root):shutil.move(os.path.join(src_root, item), os.path.join(target_dir_for_contents, item))
utils.py+10-2