MCPcopy Create free account
hub / github.com/TeleHuman/TextOp / process_directory

Function process_directory

dataset/process_retarget_data.py:112–131  ·  view source on GitHub ↗
(source_dir, target_dir, file_extension='.pkl')

Source from the content-addressed store, hash-verified

110
111
112def process_directory(source_dir, target_dir, file_extension='.pkl'):
113 os.makedirs(target_dir, exist_ok=True)
114
115 pkl_files = []
116 for root, _, files in os.walk(source_dir):
117 for file in files:
118 if file.endswith(file_extension):
119 full_path = os.path.join(root, file)
120 pkl_files.append(full_path)
121
122 total_files = len(pkl_files)
123 print(f"Find {total_files} files!")
124
125 for file_path in tqdm(pkl_files, desc="Processing"):
126 relative_path = os.path.relpath(file_path, source_dir)
127 output_path = os.path.join(target_dir, relative_path)
128
129 os.makedirs(os.path.dirname(output_path), exist_ok=True)
130
131 process_pkl_file(file_path, output_path)
132
133
134if __name__ == "__main__":

Callers 1

Calls 1

process_pkl_fileFunction · 0.85

Tested by

no test coverage detected