36 lines
1.1 KiB
Python
Executable file
36 lines
1.1 KiB
Python
Executable file
"""Add expand before closing ); when config has pdfEndpoint after defaultSortDesc (top suppliers/customers style)."""
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent / "lib" / "pages"
|
|
|
|
PAT = re.compile(
|
|
r"( defaultSortDesc: (?:true|false),\n excelEndpoint:[^\n]+\n pdfEndpoint:[^\n]+\n)( \);\n \}\n\n @override\n Widget build\(BuildContext context\) \{)",
|
|
re.MULTILINE,
|
|
)
|
|
|
|
|
|
def main() -> None:
|
|
for path in sorted(ROOT.rglob("*.dart")):
|
|
raw = path.read_text(encoding="utf-8")
|
|
if "expandBodyHeightToFitRows" in raw:
|
|
continue
|
|
if "DataTableWidget" not in raw:
|
|
continue
|
|
m = PAT.search(raw)
|
|
if not m:
|
|
continue
|
|
new_raw = PAT.sub(
|
|
r"\1 expandBodyHeightToFitRows: true,\n\2",
|
|
raw,
|
|
count=1,
|
|
)
|
|
if new_raw != raw:
|
|
path.write_text(new_raw, encoding="utf-8")
|
|
print(path.relative_to(ROOT.parent))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|