Whittaker's History (1910), reviewed › The review's files › sim/whittaker/partD/

partD_common.py

In the investigation at sim/whittaker/partD/partD_common.py · last changed in commit c5090e3, 22 November 2026 · 952 bytes


"""Shared header for the Part D scripts (Whittaker 1910, chapters VIII and IX).

Every script prints the repository's HEAD commit first, as the investigation's
practice requires, so the output carries the commit it was run under.
Only numpy and scipy are used.
"""
import subprocess
import sys
import time


def header(title):
    try:
        r = subprocess.run(['git', 'rev-parse', 'HEAD'], cwd='/home/doug/aetherscience.org',
                           capture_output=True, text=True, timeout=20)
        head = r.stdout.strip() or ('unavailable: ' + r.stderr.strip())
    except Exception as exc:  # pragma: no cover
        head = 'unavailable: %s' % exc
    print('git rev-parse HEAD:', head)
    print('run at:', time.strftime('%Y-%m-%d %H:%M:%S %Z'))
    print('python:', sys.version.split()[0])
    print('=' * 78)
    print(title)
    print('=' * 78)


def section(title):
    print()
    print('-' * 78)
    print(title)
    print('-' * 78)