@@ -50,7 +50,7 @@ class ConfigManager(object):
5050 """Config Management class used to create a config file."""
5151
5252 def __init__ (
53- self , filepath , cvar_prefix = '' , indention = 3 , max_line_length = 79 ):
53+ self , filepath , cvar_prefix = '' , indention = 3 , max_line_length = 79 , encoding = 'utf-8' ):
5454 """Initialized the configuration manager.
5555
5656 :param str filepath:
@@ -75,6 +75,7 @@ def __init__(
7575 self ._cvar_prefix = cvar_prefix
7676 self ._indention = indention
7777 self ._max_line_length = max_line_length
78+ self ._encoding = encoding
7879
7980 # Store the header and separator
8081 self .header = ''
@@ -263,7 +264,7 @@ def write(self):
263264 self .fullpath .parent .makedirs ()
264265
265266 # Open/close the file to write to it
266- with self .fullpath .open ('w' ) as open_file :
267+ with self .fullpath .open ('w' , encoding = self . _encoding ) as open_file :
267268
268269 # Get the number of spaces to indent after //
269270 spaces = ' ' * (self .indention - 2 )
@@ -329,7 +330,7 @@ def execute(self):
329330 self .fullpath ))
330331
331332 # Open/close the file
332- with self .fullpath .open () as open_file :
333+ with self .fullpath .open (encoding = self . _encoding ) as open_file :
333334
334335 # Loop through all lines in the file
335336 for line in open_file .readlines ():
@@ -385,7 +386,7 @@ def _parse_old_file(self):
385386 return _old_config
386387
387388 # Open/close the file
388- with self .fullpath .open () as open_file :
389+ with self .fullpath .open (encoding = self . _encoding ) as open_file :
389390
390391 # Get all lines from the file
391392 _all_lines = [line .strip () for line in open_file .readlines ()]
0 commit comments