11import yaml
22import re
33import os
4- import difflib
54
65# -----------------------
76# Load YAML data
87# -----------------------
98with open ('data/plugins-and-themes.yml' , 'r' ) as f :
109 data = yaml .safe_load (f )
11- print (f"Loaded { len (data .get ('plugins' , []))} plugins and { len (data .get ('themes' , []))} themes." )
1210
1311# -----------------------
1412# Markdown generator for each plugin/theme entry
@@ -17,7 +15,6 @@ def generate_entry_md(entry, is_plugin=True, index=0):
1715 owner , repo_name = entry ['repo' ].split ('/' )
1816 sanitized_name = entry ['name' ].replace (' ' , '%20' )
1917
20- # Title + Badges (only once)
2118 md = f"- ### [{ entry ['name' ]} ](https://github.com/{ entry ['repo' ]} ) <br>\n "
2219 md += f" [](https://github.com/{ entry ['repo' ]} /releases) "
2320 md += f"[](https://github.com/{ entry ['repo' ]} /releases/download/{ entry .get ('latest_release_tag' , 'latest' )} /{ sanitized_name } .jar)<br>\n "
@@ -53,7 +50,6 @@ def generate_entry_md(entry, is_plugin=True, index=0):
5350# -----------------------
5451plugin_count = len (data .get ("plugins" , []))
5552theme_count = len (data .get ("themes" , []) or [])
56- print (f"Plugin count: { plugin_count } , Theme count: { theme_count } " )
5753
5854# -----------------------
5955# Update PLUGINS.md
@@ -72,7 +68,6 @@ def generate_entry_md(entry, is_plugin=True, index=0):
7268
7369with open ('PLUGINS.md' , 'w' ) as f :
7470 f .write (plugins_content )
75- print ("β
Updated PLUGINS.md" )
7671
7772# -----------------------
7873# Update THEMES.md
@@ -91,24 +86,13 @@ def generate_entry_md(entry, is_plugin=True, index=0):
9186
9287with open ('THEMES.md' , 'w' ) as f :
9388 f .write (themes_content )
94- print ("β
Updated THEMES.md" )
9589
9690# -----------------------
97- # Update badge counts in README.md (flexible)
91+ # Update badge counts in README.md
9892# -----------------------
99- print ("π Working directory:" , os .getcwd ())
100- print ("π README.md path:" , os .path .abspath ('README.md' ))
101-
10293with open ('README.md' , 'r' ) as f :
10394 readme_original = f .read ()
10495
105- # Check for matches
106- plugin_match = re .search (r'\[!\[Plugins\]\(.*?shields\.io/badge/Plugins-\d+-green.*?\)\]\([^)]+\)' , readme_original )
107- theme_match = re .search (r'\[!\[Themes\]\(.*?shields\.io/badge/Themes-\d+-green.*?\)\]\([^)]+\)' , readme_original )
108- print ("π Plugin badge found:" , bool (plugin_match ))
109- print ("π Theme badge found:" , bool (theme_match ))
110-
111- # Apply replacements
11296readme_updated = re .sub (
11397 r'\[!\[Plugins\]\(.*?shields\.io/badge/Plugins-\d+-green.*?\)\]\([^)]+\)' ,
11498 f'[](./PLUGINS.md)' ,
@@ -123,17 +107,6 @@ def generate_entry_md(entry, is_plugin=True, index=0):
123107 count = 1
124108)
125109
126- # Diff check
127- if readme_original == readme_updated :
128- print ("β
README.md was already up to date." )
129- else :
130- print ("βοΈ README.md was changed. Writing changes..." )
110+ if readme_original != readme_updated :
131111 with open ('README.md' , 'w' ) as f :
132112 f .write (readme_updated )
133- print ("β
README.md updated." )
134- print ("--- README.md DIFF ---" )
135- for line in difflib .unified_diff (readme_original .splitlines (), readme_updated .splitlines (), fromfile = 'before' , tofile = 'after' , lineterm = '' ):
136- print (line )
137- print ("--- END DIFF ---" )
138-
139- print ("π README.md last modified:" , os .path .getmtime ('README.md' ))
0 commit comments