1212def template (colors , input_file , output_file = None ):
1313 """Read template file, substitute markers and
1414 save the file elsewhere."""
15+ # pylint: disable-msg=too-many-locals
1516 template_data = util .read_file_raw (input_file )
1617 for i , l in enumerate (template_data ):
1718 for match in re .finditer (r"(?<=(?<!\{))(\{([^{}]+)\})(?=(?!\}))" , l ):
@@ -25,7 +26,7 @@ def template(colors, input_file, output_file=None):
2526 # Color to be modified copied into new one
2627 new_color = util .Color (colors [cname ].hex_color )
2728 # Execute each function to be done
28- for func in filter (None , re .split ("\)|\." , funcs )):
29+ for func in filter (None , re .split (r "\)|\." , funcs )):
2930 # Get function name and arguments
3031 func = func .split ("(" )
3132 fname = func [0 ]
@@ -52,12 +53,13 @@ def template(colors, input_file, output_file=None):
5253 replace_str += '.' + fname
5354 new_color = function
5455
55- if not isinstance (new_color , str ):
56+ if isinstance (new_color , util . Color ):
5657 new_color = new_color .strip
5758 # If the color was changed, replace with a unique identifier.
5859 if new_color is not colors [cname ]:
5960 new_color_clean = new_color .replace ('[' , '_' ).replace (']' , '_' )
60- template_data [i ] = l .replace (replace_str , "color" + new_color_clean )
61+ template_data [i ] = l .replace (replace_str ,
62+ "color" + new_color_clean )
6163 colors ["color" + new_color_clean ] = new_color
6264 try :
6365 template_data = "" .join (template_data ).format (** colors )
0 commit comments