-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-readme.py
More file actions
74 lines (58 loc) · 2.69 KB
/
Copy pathupdate-readme.py
File metadata and controls
74 lines (58 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os
import glob
import re
pre = '''
## List
'''
def updateReadme():
print("Updating README.md...")
# Get the repo root directory
repo_root = os.path.dirname(os.path.abspath(__file__))
# Dictionary to store folders with .blend files
blend_folders = {}
# Walk through all directories recursively
for root, dirs, files in os.walk(repo_root):
# Skip the .git directory if it exists
if '.git' in dirs:
dirs.remove('.git')
# Check if there are any .blend files in the current directory
blend_files = [f for f in files if f.endswith('.blend')]
if blend_files:
# Get relative path to the repo root
rel_path = os.path.relpath(root, repo_root)
if rel_path == '.':
folder_name = os.path.basename(repo_root)
else:
folder_name = os.path.basename(root)
# Find render-output images
render_output_images = [f for f in files
if f.lower().startswith('render-output') and
f.lower().endswith(('.png', '.jpg', '.jpeg', '.gif', '.bmp', '.tiff', '.webp'))]
# Store information about this folder
blend_folders[rel_path] = {
'name': folder_name,
'blend_files': blend_files,
'render_output_images': render_output_images,
}
# Generate the README content
readme_content = pre
# Add sections for each folder with .blend files
for rel_path, folder_info in sorted(blend_folders.items()):
readme_content += f"### {folder_info['name']}\n\n"
# Add links to blend files
for blend_file in sorted(folder_info['blend_files']):
file_path = os.path.join(rel_path, blend_file).replace('\\', '/')
readme_content += f"- [{blend_file}]({file_path})\n"
# Add render-output images with max height 200
if folder_info['render_output_images']:
readme_content += "\n**Render Output:**\n\n"
for image in sorted(folder_info['render_output_images']):
image_path = os.path.join(rel_path, image).replace('\\', '/')
readme_content += f"<img src=\"{image_path}\" alt=\"{image}\" height=\"200\">\n"
readme_content += "\n"
# Write the updated content to README.md
with open(os.path.join(repo_root, 'readme.md'), 'w', encoding='utf-8') as f:
f.write(readme_content)
print("README.md updated successfully!")
if __name__ == "__main__":
updateReadme()