tricu

A lazy functional language based on Tree Calculus
Log | Files | Refs | README | LICENSE

library_format.py (1101B)


      1 #!/usr/bin/env python3
      2 """Check every current library with an explicitly prepared portable formatter."""
      3 import argparse
      4 import json
      5 from pathlib import Path
      6 import subprocess
      7 
      8 ROOT = Path(__file__).resolve().parent.parent
      9 
     10 
     11 def main():
     12     parser = argparse.ArgumentParser(description=__doc__)
     13     parser.add_argument('tricu', type=Path)
     14     parser.add_argument('--formatter-directory', type=Path, required=True)
     15     args = parser.parse_args()
     16     preparation = args.formatter_directory.resolve()
     17     metadata = json.loads((preparation/'report.json').read_text())
     18     if not metadata['complete']:
     19         raise ValueError('formatter preparation incomplete')
     20     paths = sorted((ROOT/'lib').rglob('*.tri'))
     21     for path in paths:
     22         subprocess.run([str(args.tricu.resolve()), 'format', str(path), '--check',
     23             '--formatter', metadata['formatter_manifest'], '--tool-store', str(preparation/'store'),
     24             '+RTS', '-N1', '-M8192m', '-RTS'], check=True, timeout=90)
     25     print(f'{len(paths)} current libraries pass equation-alignment checks')
     26 
     27 
     28 if __name__ == '__main__':
     29     main()