blashork, (edited )
@blashork@hexbear.net avatar

I have made a python script and ran it on a clone of your git repo to confirm it works, simply run it at the root directory of wherever the files are, it will walk through and find module.json and do the replace.


<span style="color:#323232;">#!/usr/bin/env python3
</span><span style="color:#323232;">
</span><span style="color:#323232;">import re
</span><span style="color:#323232;">import os
</span><span style="color:#323232;">
</span><span style="color:#323232;">import fileinput
</span><span style="color:#323232;">
</span><span style="color:#323232;">pattern = re.compile(r'(?P.+)"compatibility":{"minimum":"(?P\d+)","verified":"(?P\d+)"},(?P.+)')
</span><span style="color:#323232;">
</span><span style="color:#323232;">def make11(match):
</span><span style="color:#323232;">    if match.groupdict().get('min', None) and match.groupdict().get('ver', None):
</span><span style="color:#323232;">        return f"{match.groupdict()['pre']}"compatibility":{{"minimum":"11","verified":"11"}},{match.groupdict()['post']}"
</span><span style="color:#323232;">
</span><span style="color:#323232;">for root, dirs, files in os.walk("."):
</span><span style="color:#323232;">    for file in files:
</span><span style="color:#323232;">        if file == "module.json":
</span><span style="color:#323232;">            for line in fileinput.input(f"{root}/{file}", inplace=True):
</span><span style="color:#323232;">                print(re.sub(pattern, make11, line))
</span>

edit: lemmy is fucking with the formatting and removing the fucking regex group names, which will bork it. I’ve tried fixing it, dm me if you want me to send a downloadable link to the script

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • [email protected]
  • aaaaaaacccccccce
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • oklahoma
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • Ask_kbincafe
  • SuperSentai
  • feritale
  • KamenRider
  • All magazines