todonotifier.config
Configuration for custom application of todo_notifier. This module provides a base configuration that can be inherited. And a default configuration that blows all the whistles of defining a configuration while being equally extensible.
1"""Configuration for custom application of todo_notifier. This module provides a base 2configuration that can be inherited. And a default configuration that blows all the 3whistles of defining a configuration while being equally extensible. 4""" 5 6from copy import deepcopy 7from typing import Dict, List, Union 8 9from todonotifier.constants import DEFAULT_EXCLUDE_DIRS, DEFAULT_EXCLUDE_FILES 10from todonotifier.notifier import BaseNotifier 11from todonotifier.summary_generators import ( 12 BaseSummaryGenerator, 13 ByModuleSummaryGenerator, 14 ExpiredTodosByUserSummaryGenerator, 15 UpcomingWeekTodosByUserSummaryGenerator, 16) 17from todonotifier.utils import recursive_update 18 19 20class BaseConfig: 21 """Base Config class that can be inherited to spawn any new config class""" 22 23 def __init__( 24 self, 25 exclude_dirs: Dict[str, List[str]], 26 exclude_files: Dict[str, List[str]], 27 summary_generators: List[BaseSummaryGenerator], 28 generate_html: bool, 29 save_html_reports: bool, 30 ignore_todo_case: bool, 31 notifier: Union[BaseNotifier, None], 32 ) -> None: 33 """Initializer for `BaseConfig` class 34 35 Args: 36 exclude_dirs (Dict[str, List[str]]): Dictionary containing details about directories to be ignored 37 exclude_files (Dict[str, List[str]]): Dictionary containing details about files to be ignored 38 summary_generators (List[BaseSummaryGenerator]): List of summary generator instance to generate various kind of summary of todo items 39 generate_html (bool): Boolean to control whether to generate the html reports 40 save_html_reports (bool): Boolean to control whether to save html reports. Works only if `generate_html` is `True` 41 ignore_todo_case (bool): Boolean whether to look for case insensitive todo items like todo, Todo etc. 42 notifier (Union[BaseNotifier, None], optional): Object of class `BaseNotifier` to deal with sending notifications. Defaults to None 43 """ 44 self._exclude_dirs = exclude_dirs 45 self._exclude_files = exclude_files 46 self._summary_generators = summary_generators 47 self._generate_html = generate_html 48 self._save_html_reports = save_html_reports 49 self._ignore_todo_case = ignore_todo_case 50 self._notifier = notifier 51 52 @property 53 def exclude_dirs(self) -> Dict[str, List[str]]: 54 """Getter for `exclude_dirs` 55 56 Returns: 57 Dict[str, List[str]]: Dictionary containing details about directories to be ignored 58 """ 59 return self._exclude_dirs 60 61 @property 62 def exclude_files(self) -> Dict[str, List[str]]: 63 """Getter for `exclude_files` 64 65 Returns: 66 Dict[str, List[str]]: Dictionary containing details about files to be ignored 67 """ 68 return self._exclude_files 69 70 @property 71 def summary_generators(self) -> List[BaseSummaryGenerator]: 72 """Getter for `summary_generators` 73 74 Returns: 75 List[BaseSummaryGenerator]: List of summary generators to generate various kind of summary of todo items 76 """ 77 return self._summary_generators 78 79 @property 80 def generate_html(self) -> bool: 81 """Getter for `generate_html` 82 83 Returns: 84 bool: Boolean whether to generate HTML summary for each summary generator 85 """ 86 return self._generate_html 87 88 @property 89 def save_html_reports(self) -> bool: 90 """Getter for `save_html_reports` 91 92 Returns: 93 bool: Boolean whether to save generated HTML summary for each summary generator 94 """ 95 return self._save_html_reports 96 97 @property 98 def ignore_todo_case(self) -> bool: 99 """Getter for `ignore_todo_case` 100 101 Returns: 102 bool: Boolean whether to look for case insensitive todo items like todo, Todo etc. 103 """ 104 return self._ignore_todo_case 105 106 @property 107 def notifier(self) -> Union[BaseNotifier, None]: 108 """Getter for `notifier` 109 110 Returns: 111 bool: Boolean whether to send notifications of the generated reports 112 """ 113 return self._notifier 114 115 116class DefaultConfig(BaseConfig): 117 """Allows easy way to setup config by allowing to pass new dirs/files to exclude along with default ones 118 119 It by default adds `DEFAULT_EXCLUDE_DIRS` and `DEFAULT_EXCLUDE_FILES` to list of dirs and files to be ignored respectively 120 """ 121 122 def __init__( 123 self, 124 exclude_dirs: Dict[str, List[str]] = None, 125 flag_default_exclude_dirs: bool = True, 126 exclude_files: Dict[str, List[str]] = None, 127 flag_default_exclude_files: bool = True, 128 summary_generators: List[BaseSummaryGenerator] = None, 129 flag_default_summary_generators: bool = True, 130 generate_html: bool = True, 131 save_html_reports: bool = False, 132 ignore_todo_case: bool = False, 133 notifier: Union[BaseNotifier, None] = None, 134 ) -> None: 135 """Initializer for `DefaultConfig` class 136 137 Args: 138 exclude_dirs (Dict[str, List[str]], optional): Dictionary containing details about directories to be ignored. Defaults to {} 139 flag_default_exclude_dirs (bool, optional): Flag to control whether to use `DEFAULT_EXCLUDE_DIRS` to exclude default directories. Defaults to True. 140 exclude_files (Dict[str, List[str]], optional): Dictionary containing details about files to be ignored. Defaults to {} 141 flag_default_exclude_files (bool, optional): Flag to control whether to use `DEFAULT_EXCLUDE_FILES` to exclude default files. Defaults to True. 142 summary_generators (List[BaseSummaryGenerator], optional): List of summary generator instances. Defaults to [] 143 flag_default_summary_generators (bool, optional): Flag to control whether to use default summary generators viz. `ByModuleSummaryGenerator`, 144 `ExpiredTodosByUserSummaryGenerator`, `UpcomingWeekTodosByUserSummaryGenerator` 145 generate_html (bool, optional): Boolean controlling whether to generate HTML report for each summary generator. Defaults to True 146 save_html_reports (bool, optional): Boolean controlling whether to store the generated HTML reports by each summary generator. Defaults to False 147 ignore_todo_case (bool, optional): Boolean whether to look for case insensitive todo items like todo, Todo etc. Defaults to False 148 notifier (Union[BaseNotifier, None], optional): Object of class `BaseNotifier` to deal with sending notifications. Defaults to None 149 """ 150 exclude_dirs = exclude_dirs or {} 151 exclude_files = exclude_files or {} 152 summary_generators = summary_generators or [] 153 154 if flag_default_exclude_dirs: 155 # Means include the default exclude list of directories 156 default_exclude_dirs = deepcopy(DEFAULT_EXCLUDE_DIRS) 157 recursive_update(default_exclude_dirs, exclude_dirs) 158 exclude_dirs = default_exclude_dirs 159 160 if flag_default_exclude_files: 161 # Means include the default exclude list of files 162 default_exclude_files = deepcopy(DEFAULT_EXCLUDE_FILES) 163 recursive_update(default_exclude_files, exclude_files) 164 exclude_files = default_exclude_files 165 166 if flag_default_summary_generators: 167 # Means include the default summary generator list of files 168 # Instantiate the summary generators 169 default_summary_generators = [ 170 ByModuleSummaryGenerator(), 171 ExpiredTodosByUserSummaryGenerator(), 172 UpcomingWeekTodosByUserSummaryGenerator(), 173 ] 174 175 default_summary_generators.extend(summary_generators) 176 summary_generators = default_summary_generators 177 178 super().__init__(exclude_dirs, exclude_files, summary_generators, generate_html, save_html_reports, ignore_todo_case, notifier) 179 180 181default_config = DefaultConfig()
21class BaseConfig: 22 """Base Config class that can be inherited to spawn any new config class""" 23 24 def __init__( 25 self, 26 exclude_dirs: Dict[str, List[str]], 27 exclude_files: Dict[str, List[str]], 28 summary_generators: List[BaseSummaryGenerator], 29 generate_html: bool, 30 save_html_reports: bool, 31 ignore_todo_case: bool, 32 notifier: Union[BaseNotifier, None], 33 ) -> None: 34 """Initializer for `BaseConfig` class 35 36 Args: 37 exclude_dirs (Dict[str, List[str]]): Dictionary containing details about directories to be ignored 38 exclude_files (Dict[str, List[str]]): Dictionary containing details about files to be ignored 39 summary_generators (List[BaseSummaryGenerator]): List of summary generator instance to generate various kind of summary of todo items 40 generate_html (bool): Boolean to control whether to generate the html reports 41 save_html_reports (bool): Boolean to control whether to save html reports. Works only if `generate_html` is `True` 42 ignore_todo_case (bool): Boolean whether to look for case insensitive todo items like todo, Todo etc. 43 notifier (Union[BaseNotifier, None], optional): Object of class `BaseNotifier` to deal with sending notifications. Defaults to None 44 """ 45 self._exclude_dirs = exclude_dirs 46 self._exclude_files = exclude_files 47 self._summary_generators = summary_generators 48 self._generate_html = generate_html 49 self._save_html_reports = save_html_reports 50 self._ignore_todo_case = ignore_todo_case 51 self._notifier = notifier 52 53 @property 54 def exclude_dirs(self) -> Dict[str, List[str]]: 55 """Getter for `exclude_dirs` 56 57 Returns: 58 Dict[str, List[str]]: Dictionary containing details about directories to be ignored 59 """ 60 return self._exclude_dirs 61 62 @property 63 def exclude_files(self) -> Dict[str, List[str]]: 64 """Getter for `exclude_files` 65 66 Returns: 67 Dict[str, List[str]]: Dictionary containing details about files to be ignored 68 """ 69 return self._exclude_files 70 71 @property 72 def summary_generators(self) -> List[BaseSummaryGenerator]: 73 """Getter for `summary_generators` 74 75 Returns: 76 List[BaseSummaryGenerator]: List of summary generators to generate various kind of summary of todo items 77 """ 78 return self._summary_generators 79 80 @property 81 def generate_html(self) -> bool: 82 """Getter for `generate_html` 83 84 Returns: 85 bool: Boolean whether to generate HTML summary for each summary generator 86 """ 87 return self._generate_html 88 89 @property 90 def save_html_reports(self) -> bool: 91 """Getter for `save_html_reports` 92 93 Returns: 94 bool: Boolean whether to save generated HTML summary for each summary generator 95 """ 96 return self._save_html_reports 97 98 @property 99 def ignore_todo_case(self) -> bool: 100 """Getter for `ignore_todo_case` 101 102 Returns: 103 bool: Boolean whether to look for case insensitive todo items like todo, Todo etc. 104 """ 105 return self._ignore_todo_case 106 107 @property 108 def notifier(self) -> Union[BaseNotifier, None]: 109 """Getter for `notifier` 110 111 Returns: 112 bool: Boolean whether to send notifications of the generated reports 113 """ 114 return self._notifier
Base Config class that can be inherited to spawn any new config class
24 def __init__( 25 self, 26 exclude_dirs: Dict[str, List[str]], 27 exclude_files: Dict[str, List[str]], 28 summary_generators: List[BaseSummaryGenerator], 29 generate_html: bool, 30 save_html_reports: bool, 31 ignore_todo_case: bool, 32 notifier: Union[BaseNotifier, None], 33 ) -> None: 34 """Initializer for `BaseConfig` class 35 36 Args: 37 exclude_dirs (Dict[str, List[str]]): Dictionary containing details about directories to be ignored 38 exclude_files (Dict[str, List[str]]): Dictionary containing details about files to be ignored 39 summary_generators (List[BaseSummaryGenerator]): List of summary generator instance to generate various kind of summary of todo items 40 generate_html (bool): Boolean to control whether to generate the html reports 41 save_html_reports (bool): Boolean to control whether to save html reports. Works only if `generate_html` is `True` 42 ignore_todo_case (bool): Boolean whether to look for case insensitive todo items like todo, Todo etc. 43 notifier (Union[BaseNotifier, None], optional): Object of class `BaseNotifier` to deal with sending notifications. Defaults to None 44 """ 45 self._exclude_dirs = exclude_dirs 46 self._exclude_files = exclude_files 47 self._summary_generators = summary_generators 48 self._generate_html = generate_html 49 self._save_html_reports = save_html_reports 50 self._ignore_todo_case = ignore_todo_case 51 self._notifier = notifier
Initializer for BaseConfig
class
Arguments:
- exclude_dirs (Dict[str, List[str]]): Dictionary containing details about directories to be ignored
- exclude_files (Dict[str, List[str]]): Dictionary containing details about files to be ignored
- summary_generators (List[BaseSummaryGenerator]): List of summary generator instance to generate various kind of summary of todo items
- generate_html (bool): Boolean to control whether to generate the html reports
- save_html_reports (bool): Boolean to control whether to save html reports. Works only if
generate_html
isTrue
- ignore_todo_case (bool): Boolean whether to look for case insensitive todo items like todo, Todo etc.
- notifier (Union[BaseNotifier, None], optional): Object of class
BaseNotifier
to deal with sending notifications. Defaults to None
Getter for exclude_dirs
Returns:
Dict[str, List[str]]: Dictionary containing details about directories to be ignored
Getter for exclude_files
Returns:
Dict[str, List[str]]: Dictionary containing details about files to be ignored
Getter for summary_generators
Returns:
List[BaseSummaryGenerator]: List of summary generators to generate various kind of summary of todo items
Getter for generate_html
Returns:
bool: Boolean whether to generate HTML summary for each summary generator
Getter for save_html_reports
Returns:
bool: Boolean whether to save generated HTML summary for each summary generator
Getter for ignore_todo_case
Returns:
bool: Boolean whether to look for case insensitive todo items like todo, Todo etc.
117class DefaultConfig(BaseConfig): 118 """Allows easy way to setup config by allowing to pass new dirs/files to exclude along with default ones 119 120 It by default adds `DEFAULT_EXCLUDE_DIRS` and `DEFAULT_EXCLUDE_FILES` to list of dirs and files to be ignored respectively 121 """ 122 123 def __init__( 124 self, 125 exclude_dirs: Dict[str, List[str]] = None, 126 flag_default_exclude_dirs: bool = True, 127 exclude_files: Dict[str, List[str]] = None, 128 flag_default_exclude_files: bool = True, 129 summary_generators: List[BaseSummaryGenerator] = None, 130 flag_default_summary_generators: bool = True, 131 generate_html: bool = True, 132 save_html_reports: bool = False, 133 ignore_todo_case: bool = False, 134 notifier: Union[BaseNotifier, None] = None, 135 ) -> None: 136 """Initializer for `DefaultConfig` class 137 138 Args: 139 exclude_dirs (Dict[str, List[str]], optional): Dictionary containing details about directories to be ignored. Defaults to {} 140 flag_default_exclude_dirs (bool, optional): Flag to control whether to use `DEFAULT_EXCLUDE_DIRS` to exclude default directories. Defaults to True. 141 exclude_files (Dict[str, List[str]], optional): Dictionary containing details about files to be ignored. Defaults to {} 142 flag_default_exclude_files (bool, optional): Flag to control whether to use `DEFAULT_EXCLUDE_FILES` to exclude default files. Defaults to True. 143 summary_generators (List[BaseSummaryGenerator], optional): List of summary generator instances. Defaults to [] 144 flag_default_summary_generators (bool, optional): Flag to control whether to use default summary generators viz. `ByModuleSummaryGenerator`, 145 `ExpiredTodosByUserSummaryGenerator`, `UpcomingWeekTodosByUserSummaryGenerator` 146 generate_html (bool, optional): Boolean controlling whether to generate HTML report for each summary generator. Defaults to True 147 save_html_reports (bool, optional): Boolean controlling whether to store the generated HTML reports by each summary generator. Defaults to False 148 ignore_todo_case (bool, optional): Boolean whether to look for case insensitive todo items like todo, Todo etc. Defaults to False 149 notifier (Union[BaseNotifier, None], optional): Object of class `BaseNotifier` to deal with sending notifications. Defaults to None 150 """ 151 exclude_dirs = exclude_dirs or {} 152 exclude_files = exclude_files or {} 153 summary_generators = summary_generators or [] 154 155 if flag_default_exclude_dirs: 156 # Means include the default exclude list of directories 157 default_exclude_dirs = deepcopy(DEFAULT_EXCLUDE_DIRS) 158 recursive_update(default_exclude_dirs, exclude_dirs) 159 exclude_dirs = default_exclude_dirs 160 161 if flag_default_exclude_files: 162 # Means include the default exclude list of files 163 default_exclude_files = deepcopy(DEFAULT_EXCLUDE_FILES) 164 recursive_update(default_exclude_files, exclude_files) 165 exclude_files = default_exclude_files 166 167 if flag_default_summary_generators: 168 # Means include the default summary generator list of files 169 # Instantiate the summary generators 170 default_summary_generators = [ 171 ByModuleSummaryGenerator(), 172 ExpiredTodosByUserSummaryGenerator(), 173 UpcomingWeekTodosByUserSummaryGenerator(), 174 ] 175 176 default_summary_generators.extend(summary_generators) 177 summary_generators = default_summary_generators 178 179 super().__init__(exclude_dirs, exclude_files, summary_generators, generate_html, save_html_reports, ignore_todo_case, notifier)
Allows easy way to setup config by allowing to pass new dirs/files to exclude along with default ones
It by default adds DEFAULT_EXCLUDE_DIRS
and DEFAULT_EXCLUDE_FILES
to list of dirs and files to be ignored respectively
123 def __init__( 124 self, 125 exclude_dirs: Dict[str, List[str]] = None, 126 flag_default_exclude_dirs: bool = True, 127 exclude_files: Dict[str, List[str]] = None, 128 flag_default_exclude_files: bool = True, 129 summary_generators: List[BaseSummaryGenerator] = None, 130 flag_default_summary_generators: bool = True, 131 generate_html: bool = True, 132 save_html_reports: bool = False, 133 ignore_todo_case: bool = False, 134 notifier: Union[BaseNotifier, None] = None, 135 ) -> None: 136 """Initializer for `DefaultConfig` class 137 138 Args: 139 exclude_dirs (Dict[str, List[str]], optional): Dictionary containing details about directories to be ignored. Defaults to {} 140 flag_default_exclude_dirs (bool, optional): Flag to control whether to use `DEFAULT_EXCLUDE_DIRS` to exclude default directories. Defaults to True. 141 exclude_files (Dict[str, List[str]], optional): Dictionary containing details about files to be ignored. Defaults to {} 142 flag_default_exclude_files (bool, optional): Flag to control whether to use `DEFAULT_EXCLUDE_FILES` to exclude default files. Defaults to True. 143 summary_generators (List[BaseSummaryGenerator], optional): List of summary generator instances. Defaults to [] 144 flag_default_summary_generators (bool, optional): Flag to control whether to use default summary generators viz. `ByModuleSummaryGenerator`, 145 `ExpiredTodosByUserSummaryGenerator`, `UpcomingWeekTodosByUserSummaryGenerator` 146 generate_html (bool, optional): Boolean controlling whether to generate HTML report for each summary generator. Defaults to True 147 save_html_reports (bool, optional): Boolean controlling whether to store the generated HTML reports by each summary generator. Defaults to False 148 ignore_todo_case (bool, optional): Boolean whether to look for case insensitive todo items like todo, Todo etc. Defaults to False 149 notifier (Union[BaseNotifier, None], optional): Object of class `BaseNotifier` to deal with sending notifications. Defaults to None 150 """ 151 exclude_dirs = exclude_dirs or {} 152 exclude_files = exclude_files or {} 153 summary_generators = summary_generators or [] 154 155 if flag_default_exclude_dirs: 156 # Means include the default exclude list of directories 157 default_exclude_dirs = deepcopy(DEFAULT_EXCLUDE_DIRS) 158 recursive_update(default_exclude_dirs, exclude_dirs) 159 exclude_dirs = default_exclude_dirs 160 161 if flag_default_exclude_files: 162 # Means include the default exclude list of files 163 default_exclude_files = deepcopy(DEFAULT_EXCLUDE_FILES) 164 recursive_update(default_exclude_files, exclude_files) 165 exclude_files = default_exclude_files 166 167 if flag_default_summary_generators: 168 # Means include the default summary generator list of files 169 # Instantiate the summary generators 170 default_summary_generators = [ 171 ByModuleSummaryGenerator(), 172 ExpiredTodosByUserSummaryGenerator(), 173 UpcomingWeekTodosByUserSummaryGenerator(), 174 ] 175 176 default_summary_generators.extend(summary_generators) 177 summary_generators = default_summary_generators 178 179 super().__init__(exclude_dirs, exclude_files, summary_generators, generate_html, save_html_reports, ignore_todo_case, notifier)
Initializer for DefaultConfig
class
Arguments:
- exclude_dirs (Dict[str, List[str]], optional): Dictionary containing details about directories to be ignored. Defaults to {}
- flag_default_exclude_dirs (bool, optional): Flag to control whether to use
DEFAULT_EXCLUDE_DIRS
to exclude default directories. Defaults to True. - exclude_files (Dict[str, List[str]], optional): Dictionary containing details about files to be ignored. Defaults to {}
- flag_default_exclude_files (bool, optional): Flag to control whether to use
DEFAULT_EXCLUDE_FILES
to exclude default files. Defaults to True. - summary_generators (List[BaseSummaryGenerator], optional): List of summary generator instances. Defaults to []
- flag_default_summary_generators (bool, optional): Flag to control whether to use default summary generators viz.
ByModuleSummaryGenerator
,ExpiredTodosByUserSummaryGenerator
,UpcomingWeekTodosByUserSummaryGenerator
- generate_html (bool, optional): Boolean controlling whether to generate HTML report for each summary generator. Defaults to True
- save_html_reports (bool, optional): Boolean controlling whether to store the generated HTML reports by each summary generator. Defaults to False
- ignore_todo_case (bool, optional): Boolean whether to look for case insensitive todo items like todo, Todo etc. Defaults to False
- notifier (Union[BaseNotifier, None], optional): Object of class
BaseNotifier
to deal with sending notifications. Defaults to None