Skip to content

misc/ Python スクリプトの整備(改行正規化・make_bib.py 修正・timeout 追加) - #176

Open
k-yoshimi wants to merge 3 commits into
developfrom
fix/170-misc-python
Open

misc/ Python スクリプトの整備(改行正規化・make_bib.py 修正・timeout 追加)#176
k-yoshimi wants to merge 3 commits into
developfrom
fix/170-misc-python

Conversation

@k-yoshimi

Copy link
Copy Markdown
Collaborator

概要

Fixes #170

改行の正規化

misc/*.py 全 7 ファイルを LF に統一しました(make_readme*.pymake_bib.py は CR のみ、残りは CRLF)。再発防止として .gitattributes*.py text eol=lf を追加。このため既存ファイルの diff が全行書き換えに見えますが、git diff -w --ignore-cr-at-eol 相当では改行以外の変更はありません(下記の個別修正を除く)。

make_bib.py(新規追加 + 修正)

  • \bibitem の cite キーを表示名(QUANTUM ESPRESSO など空白・非 ASCII を含み \cite 不能)から ASCII スラッグ(komega, espresso 等)に変更し、表示名は本文側に出力
  • 入出力パスをスクリプト位置基準に(従来はカレントディレクトリ依存で、repo ルート実行と misc/ 実行のどちらでも半分壊れていた)
  • HDF5 グループ欠落時は KeyError で落ちる代わりに警告してスキップ
  • 未使用の dirs_apps/dict_apps/list_read/import re 等を削除、shebang を #!/usr/bin/env python3
  • 再生成した mainstaller.bib もコミット(生成物を repo に置かない方針でしたら、この 1 ファイルは落として .gitignore に移します)

get_info.py / get_info_ja.py

  • requests.gettimeout=30 を追加(従来はタイムアウトなしでハングし得た)
  • 一覧ページの取得も詳細ページと同様に get_retry 経由にし、一時的な 5xx でリトライ

※ Issue #170 で「get_retry が未使用」と書きましたが、正しくは詳細ページ側では使用済みで、未使用だったのは一覧ページ側のみでした。訂正します。

検証

  • 全 7 ファイルが python3 -m py_compile を通過
  • python3 misc/make_bib.py を実際に実行し、コミットした mainstaller.bib が生成されることを確認(15 エントリ、全キー ASCII)

🤖 Generated with Claude Code

k-yoshimi and others added 3 commits July 7, 2026 18:03
- Normalize line endings of all misc/*.py to LF (make_readme*.py were
  CR-only, the rest CRLF) and add .gitattributes to keep them LF
- make_bib.py: use ASCII slugs as bibitem cite keys (names with spaces
  or non-ASCII cannot be \cite'd), resolve paths relative to the
  script, warn on missing HDF5 groups, drop unused code, and switch
  the shebang to /usr/bin/env python3
- get_info.py, get_info_ja.py: add a 30s timeout to HTTP requests and
  retry the list pages on transient 5xx like the detail pages
- Commit mainstaller.bib regenerated with the new cite keys

Fixes #170

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- get_retry (get_info.py, get_info_ja.py): the newly added timeout
  raised instead of being retried; now RequestException is retried
  with the same backoff and re-raised only after retries are
  exhausted (verified with mocked-requests unit tests)
- make_bib.py: open the bib with encoding='utf-8' and exit nonzero
  when expected HDF5 groups are missing instead of silently
  producing an incomplete bibliography

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- misc/README.md: document each generator script's expected working
  directory and inputs (they are inconsistent), and the procedure to
  regenerate the committed mainstaller.bib
- .gitattributes: also normalize *.sh to LF so Windows checkouts with
  autocrlf cannot introduce CRLF into POSIX sh scripts (verified no
  tracked .sh file currently has CRLF)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@k-yoshimi

Copy link
Copy Markdown
Collaborator Author

AI review cycle (Codex + Antigravity) 結果

Phase 1 (Codex): must_fix 0 / should_fix 2 / optional 2 → 全て追加コミット 5dd3df2 で対応:

  • get_retry が新設 timeout の例外(RequestException)をリトライせず即死する問題を修正(モックによるユニットテスト 4 ケースで検証: 5xx リトライ→成功、timeout リトライ→成功、恒常 timeout→リトライ枯渇後に re-raise、404 は即返却)
  • make_bib.pyencoding='utf-8' と、HDF5 グループ欠落時の非ゼロ終了を追加
  • Codex 再レビュー済み・指摘ゼロ。mainstaller.bib はバイト同一の再生成を確認

Phase 2 (Antigravity): must_fix_docs 0 → 追加コミットで対応:

  • misc/README.md を新設し、各生成スクリプトの実行ディレクトリ前提(make_readme*/make_rst* は cwd 依存のまま)と mainstaller.bib の再生成手順を文書化(陳腐化リスクの緩和)
  • .gitattributes*.sh text eol=lf を追加(Windows の autocrlf による CRLF 混入防止。既存 .sh に CRLF が無いことを確認済み)

→ 両フェーズ収束。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P2] misc/ の Python スクリプト整備(CR 改行・make_bib.py の bibitem キー・デッドコード等)

2 participants