@@ -33,35 +33,17 @@ def __init__(self, config: BaseConfig):
3333 raise MissingCzCustomizeConfigError ()
3434 self .custom_settings = self .config .settings ["customize" ]
3535
36- custom_bump_pattern = self .custom_settings .get ("bump_pattern" )
37- if custom_bump_pattern :
38- self .bump_pattern = custom_bump_pattern
39- 40- custom_bump_map = self .custom_settings .get ("bump_map" )
41- if custom_bump_map :
42- self .bump_map = custom_bump_map
43- 44- custom_bump_map_major_version_zero = self .custom_settings .get (
45- "bump_map_major_version_zero"
46- )
47- if custom_bump_map_major_version_zero :
48- self .bump_map_major_version_zero = custom_bump_map_major_version_zero
49- 50- custom_change_type_order = self .custom_settings .get ("change_type_order" )
51- if custom_change_type_order :
52- self .change_type_order = custom_change_type_order
53- 54- commit_parser = self .custom_settings .get ("commit_parser" )
55- if commit_parser :
56- self .commit_parser = commit_parser
57- 58- changelog_pattern = self .custom_settings .get ("changelog_pattern" )
59- if changelog_pattern :
60- self .changelog_pattern = changelog_pattern
61- 62- change_type_map = self .custom_settings .get ("change_type_map" )
63- if change_type_map :
64- self .change_type_map = change_type_map
36+ for attr_name in [
37+ "bump_pattern" ,
38+ "bump_map" ,
39+ "bump_map_major_version_zero" ,
40+ "change_type_order" ,
41+ "commit_parser" ,
42+ "changelog_pattern" ,
43+ "change_type_map" ,
44+ ]:
45+ if value := self .custom_settings .get (attr_name ):
46+ setattr (self , attr_name , value )
6547
6648 def questions (self ) -> Questions :
6749 return self .custom_settings .get ("questions" , [{}])
@@ -70,8 +52,7 @@ def message(self, answers: dict) -> str:
7052 message_template = Template (self .custom_settings .get ("message_template" , "" ))
7153 if getattr (Template , "substitute" , None ):
7254 return message_template .substitute (** answers ) # type: ignore
73- else :
74- return message_template .render (** answers )
55+ return message_template .render (** answers )
7556
7657 def example (self ) -> str :
7758 return self .custom_settings .get ("example" ) or ""
@@ -83,12 +64,7 @@ def schema(self) -> str:
8364 return self .custom_settings .get ("schema" ) or ""
8465
8566 def info (self ) -> str :
86- info_path = self .custom_settings .get ("info_path" )
87- info = self .custom_settings .get ("info" )
88- if info_path :
67+ if info_path := self .custom_settings .get ("info_path" ):
8968 with open (info_path , encoding = self .config .settings ["encoding" ]) as f :
90- content = f .read ()
91- return content
92- elif info :
93- return info
94- return ""
69+ return f .read ()
70+ return self .custom_settings .get ("info" ) or ""
0 commit comments