11#!/usr/bin/env python3
22"""
33pack.mcmeta düzenleyici.
4- Kullanım: edit_pack_mcmeta.py <pack_format> <supported_min> <supported_max> [overlay_file]
5- overlay_file: her satır "<directory>=<min>:<max>" formatında
4+ Kullanım: edit_pack_mcmeta.py <pack_format> <supported_min> <supported_max>
5+ overlay_updates: GITHUB_EVENT_PATH üzerinden okunur (workflow_dispatch input).
66"""
77
88import json
9+ import os
910import sys
1011
1112
1213def main ():
1314 if len (sys .argv ) < 4 :
14- print ("Kullanım: edit_pack_mcmeta.py <pack_format> <supported_min> <supported_max> [overlay_file] " )
15+ print ("Kullanım: edit_pack_mcmeta.py <pack_format> <supported_min> <supported_max>" )
1516 sys .exit (1 )
1617
1718 pf = int (sys .argv [1 ])
1819 smin = int (sys .argv [2 ])
1920 smax = int (sys .argv [3 ])
20- overlay_file = sys .argv [4 ] if len (sys .argv ) > 4 else None
2121
22+ # overlay_updates'i GITHUB_EVENT_PATH'ten oku (jq/heredoc sorunlarını önler)
2223 overlay_raw = ""
23- if overlay_file :
24- with open (overlay_file , "r" , encoding = "utf-8" ) as f :
25- overlay_raw = f .read ().strip ()
24+ event_path = os .environ .get ("GITHUB_EVENT_PATH" , "" )
25+ if event_path and os .path .exists (event_path ):
26+ with open (event_path , "r" , encoding = "utf-8" ) as f :
27+ event = json .load (f )
28+ overlay_raw = event .get ("inputs" , {}).get ("overlay_updates" , "" ) or ""
2629
2730 with open ("pack.mcmeta" , "r" , encoding = "utf-8" ) as f :
2831 meta = json .load (f )
@@ -45,7 +48,7 @@ def main():
4548 print (f"pack_format : { old_pf } → { pf } " )
4649 print (f"supported_formats: [{ old_smin } , { old_smax } ] → [{ smin } , { smax } ]" )
4750
48- if overlay_raw :
51+ if overlay_raw . strip () :
4952 entries = {e ["directory" ]: e for e in meta .get ("overlays" , {}).get ("entries" , [])}
5053 for line in overlay_raw .splitlines ():
5154 line = line .strip ()
@@ -54,7 +57,8 @@ def main():
5457 directory , fmt = line .split ("=" , 1 )
5558 directory = directory .strip ()
5659 o_min , o_max = fmt .strip ().split (":" , 1 )
57- o_min , o_max = int (o_min ), int (o_max )
60+ o_min = int (o_min .strip ())
61+ o_max = int (o_max .strip ())
5862
5963 if directory in entries :
6064 old_fmt = entries [directory ].get ("formats" , {})
0 commit comments