libs.bootstrap.section

libs/bootstrap/section.py

  1"""
  2libs/bootstrap/section.py
  3"""
  4
  5import logging
  6from pathlib import Path
  7from typing import TYPE_CHECKING, Any, Optional, TypeAlias, Union
  8
  9from libs.domain.datamodels import CommandAttrs
 10
 11if TYPE_CHECKING:
 12    from configparser import ConfigParser, SectionProxy
 13
 14    from integrations.discord.config import SvcConfig as DiscordConfig
 15    from integrations.slack.config import SvcConfig as SlackConfig
 16    from integrations.standard_io.config import SvcConfig as StdConfig
 17    from integrations.web.config import SvcConfig as WebConfig
 18    from libs.bootstrap.app_config import BadgeDisplay
 19    from libs.commands.registry.member import MemberSection
 20    from libs.commands.registry.team import TeamSection
 21
 22ServiceClassType: TypeAlias = Union[
 23    "SlackConfig",
 24    "DiscordConfig",
 25    "WebConfig",
 26    "StdConfig",
 27]
 28"""連携サービスクラス"""
 29
 30SettingClassType: TypeAlias = Union[
 31    "SettingSection",
 32    "MemberSection",
 33    "TeamSection",
 34    "AliasSection",
 35    "BadgeDisplay",
 36]
 37"""設定関連クラス"""
 38
 39SubClassType: TypeAlias = Union[
 40    "SettingClassType",
 41    "SubCommands",
 42    "ServiceClassType",
 43]
 44
 45
 46class CommonMethodMixin:
 47    """共通メソッド"""
 48
 49    section_proxy: "SectionProxy"
 50    """読み込み先(パーサー + セクション名)"""
 51
 52    def get(self, key: str, fallback: Any = None) -> Any:
 53        """値の取得"""
 54        return self.section_proxy.get(key, fallback)
 55
 56    def getint(self, key: str, fallback: int = 0) -> int:
 57        """整数値の取得"""
 58        return self.section_proxy.getint(key, fallback)
 59
 60    def getfloat(self, key: str, fallback: float = 0.0) -> float:
 61        """数値の取得"""
 62        return self.section_proxy.getfloat(key, fallback)
 63
 64    def getboolean(self, key: str, fallback: bool = False) -> bool:
 65        """真偽値の取得"""
 66        return self.section_proxy.getboolean(key, fallback)
 67
 68    def getlist(self, key: str, fallback: str = "") -> list[str]:
 69        """リストの取得"""
 70        return [x.strip() for x in self.section_proxy.get(key, fallback).split(",")]
 71
 72    def keys(self) -> list[str]:
 73        """キーリストの返却"""
 74        return list(self.section_proxy.keys())
 75
 76    def values(self) -> list[str]:
 77        """値リストの返却"""
 78        return list(self.section_proxy.values())
 79
 80    def items(self) -> list[tuple[str, str]]:
 81        """ItemsViewを返却"""
 82        return list(self.section_proxy.items())
 83
 84
 85class BaseSection(CommonMethodMixin):
 86    """基底クラス"""
 87
 88    section: str
 89    """セクション名"""
 90    main_parser: "ConfigParser"
 91    """設定パーサー"""
 92    section_proxy: "SectionProxy"
 93    """読み込み先(パーサー + セクション名)"""
 94
 95    def __init__(self, outer: SubClassType) -> None:
 96        self.main_parser = outer.main_parser
 97        assert self.main_parser
 98        if not hasattr(self, "section") or self.section not in self.main_parser:
 99            return
100
101        self.initialization(self.main_parser[self.section])
102
103    def __repr__(self) -> str:
104        return str({k: v for k, v in vars(self).items() if not str(k).startswith("_")})
105
106    def initialization(self, section_proxy: "SectionProxy") -> None:
107        """
108        設定ファイルから値の取り込み
109
110        Args:
111            section_proxy (SectionProxy): 読み込み先(パーサー + セクション名)
112
113        """
114        self.section_proxy = section_proxy
115        for k in self.section_proxy.keys():
116            if k not in self.to_dict():
117                continue  # インスタンス変数と一致しない項目はスキップ
118            current_value = self.__dict__.get(k)
119            match current_value:
120                case _ if k in self.__dict__ and isinstance(current_value, str):
121                    setattr(self, k, self.get(k))
122                case _ if isinstance(current_value, bool):
123                    setattr(self, k, self.section_proxy.getboolean(k))
124                case _ if k in self.__dict__ and isinstance(current_value, int):
125                    setattr(self, k, self.getint(k))
126                case _ if k in self.__dict__ and isinstance(current_value, float):
127                    setattr(self, k, self.getfloat(k))
128                case _ if k in self.__dict__ and isinstance(current_value, list):
129                    v_list = self.getlist(k)
130                    if current_value:  # 設定済みリストは追加
131                        current_value.extend(v_list)
132                    else:
133                        setattr(self, k, v_list)
134                case _ if k in self.__dict__ and isinstance(current_value, Path):
135                    setattr(self, k, Path(self.get(k)))
136                case None if k in self.__dict__:
137                    if k in ["backup_dir", "rule_config"]:  # Optional[Path]
138                        setattr(self, k, Path(self.get(k)))
139                    else:
140                        setattr(self, k, self.get(k))
141                case _:
142                    setattr(self, k, current_value)
143
144    def _before_config_load(self) -> None:
145        """設定値取り込み前の初期化処理"""
146        if (reset_method := getattr(self, "default_reset", None)) and callable(reset_method):
147            reset_method()
148
149    def _after_config_load(self, _section_proxy: "SectionProxy") -> None:
150        """設定値取り込み後の追加処理"""
151
152    def config_load(self, section_proxy: "SectionProxy") -> None:
153        """
154        設定値取り込み
155
156        Args:
157            section_proxy (SectionProxy): 読み込み先(パーサー + セクション名)
158
159        """
160        self._before_config_load()
161        self.initialization(section_proxy)
162        self._after_config_load(section_proxy)
163
164        logging.trace("%s: %s", self.section, self)  # type: ignore
165
166    def to_dict(self, drop_items: Optional[list[str]] = None) -> dict[str, str]:
167        """
168        必要なパラメータを辞書型で返す
169
170        Args:
171            drop_items (Optional[list[str]], optional): 返却に含めないキーリスト. Defaults to None.
172
173        Returns:
174             dict[str, str]: 返却値
175
176        """
177        ret_dict: dict[str, str] = {}
178        for key in vars(self):
179            if key.startswith("_"):
180                continue
181            ret_dict[key] = getattr(self, key)
182
183        if drop_items:
184            for item in drop_items:
185                if item in ret_dict:
186                    ret_dict.pop(item)
187
188        return ret_dict
189
190
191class SettingSection(BaseSection):
192    """settingセクション処理"""
193
194    remarks_word: str
195    """メモ記録用キーワード"""
196    remarks_suffix: list[str]
197    """メモ記録用キーワードサフィックス"""
198    rule_config: Optional[Path]
199    """ルール設定ファイル"""
200    default_rule: str
201    """ルール識別子未指定時に使用される識別子"""
202    separate: bool
203    """スコア入力元識別子別集計フラグ
204    - *True*: 識別子別に集計
205    - *False*: すべて集計
206    """
207    channel_id: Optional[str]
208    """チャンネルIDを上書きする"""
209    time_adjust: int
210    """日付変更後、集計範囲に含める追加時間"""
211    search_word: str
212    """コメント固定(検索時の検索文字列)"""
213    group_length: int
214    """コメント固定(検索時の集約文字数)"""
215    guest_mark: str
216    """ゲスト無効時に未登録メンバーに付与する印"""
217    database_file: Union[str, Path]
218    """成績管理データベースファイル名"""
219    backup_dir: Optional[Path]
220    """バックアップ先ディレクトリ"""
221    font_file: Path
222    """グラフ描写に使用するフォントファイル"""
223    graph_style: str
224    """グラフスタイル"""
225    work_dir: Path
226    """作業ディレクトリ"""
227
228    def __init__(self) -> None:
229        self.section: str = "setting"
230        self.default_reset()
231
232    def default_reset(self) -> None:
233        """パラメータ初期化"""
234        self.remarks_word = str("麻雀メモ")
235        self.remarks_suffix = []
236        self.rule_config = None
237        self.time_adjust = int(12)
238        self.default_rule = str("")
239        self.separate = bool(False)
240        self.channel_id = None
241        self.search_word = str("")
242        self.group_length = int(0)
243        self.guest_mark = str("※")
244        self.database_file = Path("mahjong.db")
245        self.backup_dir = None
246        self.font_file = Path("ipaexg.ttf")
247        self.graph_style = str("ggplot")
248        self.work_dir = Path("work")
249
250
251class AliasSection(BaseSection):
252    """aliasセクション処理"""
253
254    results: list[str]
255    """成績サマリ出力コマンド"""
256    graph: list[str]
257    """成績グラフ出力コマンド"""
258    ranking: list[str]
259    """ランキング出力コマンド"""
260    report: list[str]
261    """レポート出力コマンド"""
262    download: list[str]
263    member: list[str]
264    """メンバーリスト表示コマンド"""
265    add: list[str]
266    delete: list[str]
267    team_create: list[str]
268    team_del: list[str]
269    team_add: list[str]
270    team_remove: list[str]
271    team_list: list[str]
272    """チームリスト出力コマンド"""
273    team_clear: list[str]
274
275    def __init__(self) -> None:
276        self.section = "alias"
277        self.default_reset()
278
279    def default_reset(self) -> None:
280        """パラメータ初期化"""
281        self.results = ["results", "成績"]
282        self.graph = ["graph", "グラフ"]
283        self.ranking = ["ranking", "ランキング"]
284        self.report = ["report", "レポート"]
285        self.download = ["download", "ダウンロード"]
286        self.member = ["member", "userlist", "member_list"]
287        self.add = ["add"]
288        self.delete = ["del"]
289        self.team_create = ["team_create"]
290        self.team_del = ["team_del"]
291        self.team_add = ["team_add"]
292        self.team_remove = ["team_remove"]
293        self.team_list = ["team_list"]
294        self.team_clear = ["team_clear"]
295
296    def _after_config_load(self, _section_proxy: "SectionProxy") -> None:
297        """AliasSection専用の追加処理"""
298
299        # delのエイリアス取り込み(設定ファイルに`delete`と書かれていない)
300        self.delete.extend(self.getlist("del", fallback="del"))
301
302
303class SubCommands(BaseSection, CommandAttrs):
304    """サブコマンドセクション処理"""
305
306    default_commandword: str
307    """コマンドワードデフォルト値"""
ServiceClassType: TypeAlias = ForwardRef('SlackConfig') | ForwardRef('DiscordConfig') | ForwardRef('WebConfig') | ForwardRef('StdConfig')

連携サービスクラス

SettingClassType: TypeAlias = ForwardRef('SettingSection') | ForwardRef('MemberSection') | ForwardRef('TeamSection') | ForwardRef('AliasSection') | ForwardRef('BadgeDisplay')

設定関連クラス

SubClassType: TypeAlias = ForwardRef('SettingClassType') | ForwardRef('SubCommands') | ForwardRef('ServiceClassType')
class CommonMethodMixin:
47class CommonMethodMixin:
48    """共通メソッド"""
49
50    section_proxy: "SectionProxy"
51    """読み込み先(パーサー + セクション名)"""
52
53    def get(self, key: str, fallback: Any = None) -> Any:
54        """値の取得"""
55        return self.section_proxy.get(key, fallback)
56
57    def getint(self, key: str, fallback: int = 0) -> int:
58        """整数値の取得"""
59        return self.section_proxy.getint(key, fallback)
60
61    def getfloat(self, key: str, fallback: float = 0.0) -> float:
62        """数値の取得"""
63        return self.section_proxy.getfloat(key, fallback)
64
65    def getboolean(self, key: str, fallback: bool = False) -> bool:
66        """真偽値の取得"""
67        return self.section_proxy.getboolean(key, fallback)
68
69    def getlist(self, key: str, fallback: str = "") -> list[str]:
70        """リストの取得"""
71        return [x.strip() for x in self.section_proxy.get(key, fallback).split(",")]
72
73    def keys(self) -> list[str]:
74        """キーリストの返却"""
75        return list(self.section_proxy.keys())
76
77    def values(self) -> list[str]:
78        """値リストの返却"""
79        return list(self.section_proxy.values())
80
81    def items(self) -> list[tuple[str, str]]:
82        """ItemsViewを返却"""
83        return list(self.section_proxy.items())

共通メソッド

section_proxy: configparser.SectionProxy

読み込み先(パーサー + セクション名)

def get(self, key: str, fallback: Any = None) -> Any:
53    def get(self, key: str, fallback: Any = None) -> Any:
54        """値の取得"""
55        return self.section_proxy.get(key, fallback)

値の取得

def getint(self, key: str, fallback: int = 0) -> int:
57    def getint(self, key: str, fallback: int = 0) -> int:
58        """整数値の取得"""
59        return self.section_proxy.getint(key, fallback)

整数値の取得

def getfloat(self, key: str, fallback: float = 0.0) -> float:
61    def getfloat(self, key: str, fallback: float = 0.0) -> float:
62        """数値の取得"""
63        return self.section_proxy.getfloat(key, fallback)

数値の取得

def getboolean(self, key: str, fallback: bool = False) -> bool:
65    def getboolean(self, key: str, fallback: bool = False) -> bool:
66        """真偽値の取得"""
67        return self.section_proxy.getboolean(key, fallback)

真偽値の取得

def getlist(self, key: str, fallback: str = '') -> list[str]:
69    def getlist(self, key: str, fallback: str = "") -> list[str]:
70        """リストの取得"""
71        return [x.strip() for x in self.section_proxy.get(key, fallback).split(",")]

リストの取得

def keys(self) -> list[str]:
73    def keys(self) -> list[str]:
74        """キーリストの返却"""
75        return list(self.section_proxy.keys())

キーリストの返却

def values(self) -> list[str]:
77    def values(self) -> list[str]:
78        """値リストの返却"""
79        return list(self.section_proxy.values())

値リストの返却

def items(self) -> list[tuple[str, str]]:
81    def items(self) -> list[tuple[str, str]]:
82        """ItemsViewを返却"""
83        return list(self.section_proxy.items())

ItemsViewを返却

class BaseSection(CommonMethodMixin):
 86class BaseSection(CommonMethodMixin):
 87    """基底クラス"""
 88
 89    section: str
 90    """セクション名"""
 91    main_parser: "ConfigParser"
 92    """設定パーサー"""
 93    section_proxy: "SectionProxy"
 94    """読み込み先(パーサー + セクション名)"""
 95
 96    def __init__(self, outer: SubClassType) -> None:
 97        self.main_parser = outer.main_parser
 98        assert self.main_parser
 99        if not hasattr(self, "section") or self.section not in self.main_parser:
100            return
101
102        self.initialization(self.main_parser[self.section])
103
104    def __repr__(self) -> str:
105        return str({k: v for k, v in vars(self).items() if not str(k).startswith("_")})
106
107    def initialization(self, section_proxy: "SectionProxy") -> None:
108        """
109        設定ファイルから値の取り込み
110
111        Args:
112            section_proxy (SectionProxy): 読み込み先(パーサー + セクション名)
113
114        """
115        self.section_proxy = section_proxy
116        for k in self.section_proxy.keys():
117            if k not in self.to_dict():
118                continue  # インスタンス変数と一致しない項目はスキップ
119            current_value = self.__dict__.get(k)
120            match current_value:
121                case _ if k in self.__dict__ and isinstance(current_value, str):
122                    setattr(self, k, self.get(k))
123                case _ if isinstance(current_value, bool):
124                    setattr(self, k, self.section_proxy.getboolean(k))
125                case _ if k in self.__dict__ and isinstance(current_value, int):
126                    setattr(self, k, self.getint(k))
127                case _ if k in self.__dict__ and isinstance(current_value, float):
128                    setattr(self, k, self.getfloat(k))
129                case _ if k in self.__dict__ and isinstance(current_value, list):
130                    v_list = self.getlist(k)
131                    if current_value:  # 設定済みリストは追加
132                        current_value.extend(v_list)
133                    else:
134                        setattr(self, k, v_list)
135                case _ if k in self.__dict__ and isinstance(current_value, Path):
136                    setattr(self, k, Path(self.get(k)))
137                case None if k in self.__dict__:
138                    if k in ["backup_dir", "rule_config"]:  # Optional[Path]
139                        setattr(self, k, Path(self.get(k)))
140                    else:
141                        setattr(self, k, self.get(k))
142                case _:
143                    setattr(self, k, current_value)
144
145    def _before_config_load(self) -> None:
146        """設定値取り込み前の初期化処理"""
147        if (reset_method := getattr(self, "default_reset", None)) and callable(reset_method):
148            reset_method()
149
150    def _after_config_load(self, _section_proxy: "SectionProxy") -> None:
151        """設定値取り込み後の追加処理"""
152
153    def config_load(self, section_proxy: "SectionProxy") -> None:
154        """
155        設定値取り込み
156
157        Args:
158            section_proxy (SectionProxy): 読み込み先(パーサー + セクション名)
159
160        """
161        self._before_config_load()
162        self.initialization(section_proxy)
163        self._after_config_load(section_proxy)
164
165        logging.trace("%s: %s", self.section, self)  # type: ignore
166
167    def to_dict(self, drop_items: Optional[list[str]] = None) -> dict[str, str]:
168        """
169        必要なパラメータを辞書型で返す
170
171        Args:
172            drop_items (Optional[list[str]], optional): 返却に含めないキーリスト. Defaults to None.
173
174        Returns:
175             dict[str, str]: 返却値
176
177        """
178        ret_dict: dict[str, str] = {}
179        for key in vars(self):
180            if key.startswith("_"):
181                continue
182            ret_dict[key] = getattr(self, key)
183
184        if drop_items:
185            for item in drop_items:
186                if item in ret_dict:
187                    ret_dict.pop(item)
188
189        return ret_dict

基底クラス

 96    def __init__(self, outer: SubClassType) -> None:
 97        self.main_parser = outer.main_parser
 98        assert self.main_parser
 99        if not hasattr(self, "section") or self.section not in self.main_parser:
100            return
101
102        self.initialization(self.main_parser[self.section])
section: str

セクション名

main_parser: configparser.ConfigParser

設定パーサー

section_proxy: configparser.SectionProxy

読み込み先(パーサー + セクション名)

def initialization(self, section_proxy: configparser.SectionProxy) -> None:
107    def initialization(self, section_proxy: "SectionProxy") -> None:
108        """
109        設定ファイルから値の取り込み
110
111        Args:
112            section_proxy (SectionProxy): 読み込み先(パーサー + セクション名)
113
114        """
115        self.section_proxy = section_proxy
116        for k in self.section_proxy.keys():
117            if k not in self.to_dict():
118                continue  # インスタンス変数と一致しない項目はスキップ
119            current_value = self.__dict__.get(k)
120            match current_value:
121                case _ if k in self.__dict__ and isinstance(current_value, str):
122                    setattr(self, k, self.get(k))
123                case _ if isinstance(current_value, bool):
124                    setattr(self, k, self.section_proxy.getboolean(k))
125                case _ if k in self.__dict__ and isinstance(current_value, int):
126                    setattr(self, k, self.getint(k))
127                case _ if k in self.__dict__ and isinstance(current_value, float):
128                    setattr(self, k, self.getfloat(k))
129                case _ if k in self.__dict__ and isinstance(current_value, list):
130                    v_list = self.getlist(k)
131                    if current_value:  # 設定済みリストは追加
132                        current_value.extend(v_list)
133                    else:
134                        setattr(self, k, v_list)
135                case _ if k in self.__dict__ and isinstance(current_value, Path):
136                    setattr(self, k, Path(self.get(k)))
137                case None if k in self.__dict__:
138                    if k in ["backup_dir", "rule_config"]:  # Optional[Path]
139                        setattr(self, k, Path(self.get(k)))
140                    else:
141                        setattr(self, k, self.get(k))
142                case _:
143                    setattr(self, k, current_value)

設定ファイルから値の取り込み

Arguments:
  • section_proxy (SectionProxy): 読み込み先(パーサー + セクション名)
def config_load(self, section_proxy: configparser.SectionProxy) -> None:
153    def config_load(self, section_proxy: "SectionProxy") -> None:
154        """
155        設定値取り込み
156
157        Args:
158            section_proxy (SectionProxy): 読み込み先(パーサー + セクション名)
159
160        """
161        self._before_config_load()
162        self.initialization(section_proxy)
163        self._after_config_load(section_proxy)
164
165        logging.trace("%s: %s", self.section, self)  # type: ignore

設定値取り込み

Arguments:
  • section_proxy (SectionProxy): 読み込み先(パーサー + セクション名)
def to_dict(self, drop_items: list[str] | None = None) -> dict[str, str]:
167    def to_dict(self, drop_items: Optional[list[str]] = None) -> dict[str, str]:
168        """
169        必要なパラメータを辞書型で返す
170
171        Args:
172            drop_items (Optional[list[str]], optional): 返却に含めないキーリスト. Defaults to None.
173
174        Returns:
175             dict[str, str]: 返却値
176
177        """
178        ret_dict: dict[str, str] = {}
179        for key in vars(self):
180            if key.startswith("_"):
181                continue
182            ret_dict[key] = getattr(self, key)
183
184        if drop_items:
185            for item in drop_items:
186                if item in ret_dict:
187                    ret_dict.pop(item)
188
189        return ret_dict

必要なパラメータを辞書型で返す

Arguments:
  • drop_items (Optional[list[str]], optional): 返却に含めないキーリスト. Defaults to None.
Returns:

dict[str, str]: 返却値

class SettingSection(BaseSection):
192class SettingSection(BaseSection):
193    """settingセクション処理"""
194
195    remarks_word: str
196    """メモ記録用キーワード"""
197    remarks_suffix: list[str]
198    """メモ記録用キーワードサフィックス"""
199    rule_config: Optional[Path]
200    """ルール設定ファイル"""
201    default_rule: str
202    """ルール識別子未指定時に使用される識別子"""
203    separate: bool
204    """スコア入力元識別子別集計フラグ
205    - *True*: 識別子別に集計
206    - *False*: すべて集計
207    """
208    channel_id: Optional[str]
209    """チャンネルIDを上書きする"""
210    time_adjust: int
211    """日付変更後、集計範囲に含める追加時間"""
212    search_word: str
213    """コメント固定(検索時の検索文字列)"""
214    group_length: int
215    """コメント固定(検索時の集約文字数)"""
216    guest_mark: str
217    """ゲスト無効時に未登録メンバーに付与する印"""
218    database_file: Union[str, Path]
219    """成績管理データベースファイル名"""
220    backup_dir: Optional[Path]
221    """バックアップ先ディレクトリ"""
222    font_file: Path
223    """グラフ描写に使用するフォントファイル"""
224    graph_style: str
225    """グラフスタイル"""
226    work_dir: Path
227    """作業ディレクトリ"""
228
229    def __init__(self) -> None:
230        self.section: str = "setting"
231        self.default_reset()
232
233    def default_reset(self) -> None:
234        """パラメータ初期化"""
235        self.remarks_word = str("麻雀メモ")
236        self.remarks_suffix = []
237        self.rule_config = None
238        self.time_adjust = int(12)
239        self.default_rule = str("")
240        self.separate = bool(False)
241        self.channel_id = None
242        self.search_word = str("")
243        self.group_length = int(0)
244        self.guest_mark = str("※")
245        self.database_file = Path("mahjong.db")
246        self.backup_dir = None
247        self.font_file = Path("ipaexg.ttf")
248        self.graph_style = str("ggplot")
249        self.work_dir = Path("work")

settingセクション処理

remarks_word: str

メモ記録用キーワード

remarks_suffix: list[str]

メモ記録用キーワードサフィックス

rule_config: pathlib.Path | None

ルール設定ファイル

default_rule: str

ルール識別子未指定時に使用される識別子

separate: bool

スコア入力元識別子別集計フラグ

  • True: 識別子別に集計
  • False: すべて集計
channel_id: str | None

チャンネルIDを上書きする

time_adjust: int

日付変更後、集計範囲に含める追加時間

search_word: str

コメント固定(検索時の検索文字列)

group_length: int

コメント固定(検索時の集約文字数)

guest_mark: str

ゲスト無効時に未登録メンバーに付与する印

database_file: str | pathlib.Path

成績管理データベースファイル名

backup_dir: pathlib.Path | None

バックアップ先ディレクトリ

font_file: pathlib.Path

グラフ描写に使用するフォントファイル

graph_style: str

グラフスタイル

work_dir: pathlib.Path

作業ディレクトリ

section: str

セクション名

def default_reset(self) -> None:
233    def default_reset(self) -> None:
234        """パラメータ初期化"""
235        self.remarks_word = str("麻雀メモ")
236        self.remarks_suffix = []
237        self.rule_config = None
238        self.time_adjust = int(12)
239        self.default_rule = str("")
240        self.separate = bool(False)
241        self.channel_id = None
242        self.search_word = str("")
243        self.group_length = int(0)
244        self.guest_mark = str("※")
245        self.database_file = Path("mahjong.db")
246        self.backup_dir = None
247        self.font_file = Path("ipaexg.ttf")
248        self.graph_style = str("ggplot")
249        self.work_dir = Path("work")

パラメータ初期化

class AliasSection(BaseSection):
252class AliasSection(BaseSection):
253    """aliasセクション処理"""
254
255    results: list[str]
256    """成績サマリ出力コマンド"""
257    graph: list[str]
258    """成績グラフ出力コマンド"""
259    ranking: list[str]
260    """ランキング出力コマンド"""
261    report: list[str]
262    """レポート出力コマンド"""
263    download: list[str]
264    member: list[str]
265    """メンバーリスト表示コマンド"""
266    add: list[str]
267    delete: list[str]
268    team_create: list[str]
269    team_del: list[str]
270    team_add: list[str]
271    team_remove: list[str]
272    team_list: list[str]
273    """チームリスト出力コマンド"""
274    team_clear: list[str]
275
276    def __init__(self) -> None:
277        self.section = "alias"
278        self.default_reset()
279
280    def default_reset(self) -> None:
281        """パラメータ初期化"""
282        self.results = ["results", "成績"]
283        self.graph = ["graph", "グラフ"]
284        self.ranking = ["ranking", "ランキング"]
285        self.report = ["report", "レポート"]
286        self.download = ["download", "ダウンロード"]
287        self.member = ["member", "userlist", "member_list"]
288        self.add = ["add"]
289        self.delete = ["del"]
290        self.team_create = ["team_create"]
291        self.team_del = ["team_del"]
292        self.team_add = ["team_add"]
293        self.team_remove = ["team_remove"]
294        self.team_list = ["team_list"]
295        self.team_clear = ["team_clear"]
296
297    def _after_config_load(self, _section_proxy: "SectionProxy") -> None:
298        """AliasSection専用の追加処理"""
299
300        # delのエイリアス取り込み(設定ファイルに`delete`と書かれていない)
301        self.delete.extend(self.getlist("del", fallback="del"))

aliasセクション処理

results: list[str]

成績サマリ出力コマンド

graph: list[str]

成績グラフ出力コマンド

ranking: list[str]

ランキング出力コマンド

report: list[str]

レポート出力コマンド

download: list[str]
member: list[str]

メンバーリスト表示コマンド

add: list[str]
delete: list[str]
team_create: list[str]
team_del: list[str]
team_add: list[str]
team_remove: list[str]
team_list: list[str]

チームリスト出力コマンド

team_clear: list[str]
section

セクション名

def default_reset(self) -> None:
280    def default_reset(self) -> None:
281        """パラメータ初期化"""
282        self.results = ["results", "成績"]
283        self.graph = ["graph", "グラフ"]
284        self.ranking = ["ranking", "ランキング"]
285        self.report = ["report", "レポート"]
286        self.download = ["download", "ダウンロード"]
287        self.member = ["member", "userlist", "member_list"]
288        self.add = ["add"]
289        self.delete = ["del"]
290        self.team_create = ["team_create"]
291        self.team_del = ["team_del"]
292        self.team_add = ["team_add"]
293        self.team_remove = ["team_remove"]
294        self.team_list = ["team_list"]
295        self.team_clear = ["team_clear"]

パラメータ初期化

class SubCommands(BaseSection, libs.domain.datamodels.CommandAttrs):
304class SubCommands(BaseSection, CommandAttrs):
305    """サブコマンドセクション処理"""
306
307    default_commandword: str
308    """コマンドワードデフォルト値"""

サブコマンドセクション処理

default_commandword: str

コマンドワードデフォルト値