jackfirth / rebellion

A collection of core libraries for Racket
https://pkgs.racket-lang.org/package/rebellion
Apache License 2.0
80 stars 16 forks source link

Remove reprovide-lang dep #495

Closed 9999years closed 3 years ago

9999years commented 3 years ago

rebellion doesn't use any advanced features, so we can get away with a simple replacement with (require ...) (provide (all-from-out ...)).

Python (sorry!!!!) script I used to refactor:

import subprocess

files = subprocess.run(["grep", "-rlZ", "#lang reprovide"], check=True, capture_output=True).stdout.split(b"\0")

for filename in files:
    if not filename:
        continue
    print(filename)
    with open(filename) as f:
        contents = f.read().split()
    if contents[:2] != ["#lang", "reprovide"]:
        print('not a reprovide file:', filename)
        continue

    contents = contents[2:]

    with open(filename, 'w', encoding='utf-8') as f:
        if contents:
            f.write("#lang racket/base"
                    + "\n\n(require "
                    + "\n         ".join(contents)
                    + ")\n"
                    + "\n(provide (all-from-out "
                    + "\n                       ".join(contents)
                    + "))\n")
        else:
            f.write("#lang racket/base\n")
9999years commented 3 years ago

Update: fixed the parens I messed up.