You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.1 KiB
32 lines
1.1 KiB
import os
|
|
|
|
|
|
def generate_file_list(directory, output_file):
|
|
"""
|
|
Generate a list of files in a directory in the specified format and write it to a file.
|
|
|
|
Args:
|
|
directory (str): The directory to list the files from.
|
|
output_file (str): The file to write the output to.
|
|
"""
|
|
with open(output_file, "w") as f:
|
|
for root, dirs, files in os.walk(directory):
|
|
for file in files:
|
|
if file.endswith(".md"):
|
|
# Remove the directory from the file path and replace slashes with dots
|
|
file_path = (
|
|
os.path.join(root, file)
|
|
.replace(directory + "/", "")
|
|
.replace("/", ".")
|
|
)
|
|
# Remove the file extension
|
|
file_name, _ = os.path.splitext(file)
|
|
# Write the file name and path to the output file
|
|
f.write(
|
|
f'- {file_name}: "swarms/utils/{file_path}"\n'
|
|
)
|
|
|
|
|
|
# Use the function to generate the file list
|
|
generate_file_list("docs/swarms/structs", "file_list.txt")
|