#! /usr/bin/python3 # -*- coding: utf-8 -*- last_edit = "Last edited on 2026-09-13 21:07:39 by stolfi" import sys, re, os, string, glob from sys import stderr as err import html_gen as h from process_funcs import bash, run_command, basic_line_loop import html_report_funcs as hr import bencao_starps_report_funcs as repf import bencao_starps_size_position_funcs as spf from math import sqrt, hypot, exp, log, floor, ceil, isfinite, isnan, inf, nan def add_intro(code_ch, loc_ch, name_ch, name_py, name_en): name_en = re.sub(r"_", " ", name_en.lower()) name_en_uscore = re.sub(r"[ ]+", "_", name_en) name_en_caps = string.capwords(name_en) tvar_ch, source_ch, tags, itms_wh, itms_py, itms_en = \ repf.fetch_bencao_entry_wh_py_en(f"clean", code_ch, loc_ch) assert tvar_ch == "full" # For now. assert source_ch == 'ZHB' or source_ch == 'CTP' title = f"[{code_ch}.071] The '{name_en_caps}' entry of the SBJ [{source_ch}]" color = "#ddeeff" if source_ch == 'ZHB' else "#eeffdd" st = h.new_doc(title, color, text_width = 1600) h.section(st, 2, "Summary") h.parags(st, f"""This webpage discusses the SBJ entry titled {name_ch} {name_py} = "{name_en}", parsed into its sub-entries and their fields. The modern Mandarin reading of the text and an English translation are also shown. This entry may be referred as "{code_ch}" in tables.""") repf.add_formatted_entry_table(st, tags, itms_wh, itms_py, itms_en) return \ st, code_ch, loc_ch, tvar_ch, source_ch, \ name_ch, name_py, name_en, \ tags, itms_wh, itms_py, itms_en # ---------------------------------------------------------------------- def test_stuff(): err.write("BEGIN TESTING\n") err.write("----------------------------------------\n") err.write("----------------------------------------\n") err.write("END TESTING\n") return # ---------------------------------------------------------------------- if len(sys.argv) == 2 and sys.argv[1] == "R71.TEST": test_stuff()