refactor: apply Template Method pattern to ADIFParser#12
Draft
Copilot wants to merge 2 commits into
Draft
Conversation
…date_loaded and _finalize_read helpers Agent-Logs-Url: https://github.com/JS2IIU-MH/adiftools-dev/sessions/5d462340-914a-449b-8e28-1ab5f3ba57cf Co-authored-by: JS2IIU-MH <146515386+JS2IIU-MH@users.noreply.github.com>
Agent-Logs-Url: https://github.com/JS2IIU-MH/adiftools-dev/sessions/5d462340-914a-449b-8e28-1ab5f3ba57cf Co-authored-by: JS2IIU-MH <146515386+JS2IIU-MH@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
JS2IIU-MH
April 12, 2026 00:56
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
変更概要 / Summary
ADIFParserクラスにデザインパターン(Template Method パターン)と DRY 原則を適用し、重複コードを削除しました。変更内容 / Changes
1.
_validate_loaded()の抽出(Template Method / DRY)to_csv、to_excel、to_pickle、to_adi、call_to_txt、plot_monthly、plot_band_percentageの 7 メソッドに散在していた同一のガード節を 1 か所に集約しました。2.
_finalize_read()の抽出(Template Method)read_adi・read_adi_streaming・read_adi_parallelが共通して持っていた「DataFrame 構築 → 状態更新 → バリデーション → タイムスタンプ追加 → 返却」という不変なアルゴリズム骨格を一元化しました。各メソッドはレコード収集(可変部分)に集中できます。3.
_process_chunkの重複正規表現を修正並列処理用の
_process_chunkがself._adif_patternとは異なるパターンをローカルに再コンパイルしていた問題を修正し、クラスで事前コンパイル済みの共有パターンを使うよう統一しました。4.
read_adi_streamingのコードスメル解消hasattr(self, '_temp_dfs')というインスタンスを一時的に汚染するパターンをローカル変数temp_dfs = []に置き換えました。.upper()呼び出しを 1 回(upper_line)に削減しました。5.
is_loadedプロパティの簡略化テスト結果 / Test Results
既存の 107 テストがすべてパスしています。動作変更はありません。