| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6609c1c commit d7d9f12
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,7 +50,7 @@ class ConfigManager(object): | |||
| 50 | 50 | """Config Management class used to create a config file.""" | |
| 51 | 51 | ||
| 52 | 52 | 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'): | ||
| 54 | 54 | """Initialized the configuration manager. | |
| 55 | 55 | ||
| 56 | 56 | :param str filepath: | |
@@ -75,6 +75,7 @@ def __init__( | |||
| 75 | 75 | self._cvar_prefix = cvar_prefix | |
| 76 | 76 | self._indention = indention | |
| 77 | 77 | self._max_line_length = max_line_length | |
| 78 | + self._encoding = encoding | ||
| 78 | 79 | ||
| 79 | 80 | # Store the header and separator | |
| 80 | 81 | self.header = '' | |
@@ -263,7 +264,7 @@ def write(self): | |||
| 263 | 264 | self.fullpath.parent.makedirs() | |
| 264 | 265 | ||
| 265 | 266 | # 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: | ||
| 267 | 268 | ||
| 268 | 269 | # Get the number of spaces to indent after // | |
| 269 | 270 | spaces = ' ' * (self.indention - 2) | |
@@ -329,7 +330,7 @@ def execute(self): | |||
| 329 | 330 | self.fullpath)) | |
| 330 | 331 | ||
| 331 | 332 | # Open/close the file | |
| 332 | - with self.fullpath.open() as open_file: | ||
| 333 | + with self.fullpath.open(encoding=self._encoding) as open_file: | ||
| 333 | 334 | ||
| 334 | 335 | # Loop through all lines in the file | |
| 335 | 336 | for line in open_file.readlines(): | |
@@ -385,7 +386,7 @@ def _parse_old_file(self): | |||
| 385 | 386 | return _old_config | |
| 386 | 387 | ||
| 387 | 388 | # Open/close the file | |
| 388 | - with self.fullpath.open() as open_file: | ||
| 389 | + with self.fullpath.open(encoding=self._encoding) as open_file: | ||
| 389 | 390 | ||
| 390 | 391 | # Get all lines from the file | |
| 391 | 392 | _all_lines = [line.strip() for line in open_file.readlines()] | |
| Back | FazBrowse Home | New Git URL |
0 commit comments