Skip to content

Commit 6120b25

Browse files
committed
Pass encoding='utf-8' when opening text files
1 parent faefa55 commit 6120b25

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/config_generator/config_generator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def __init__(self, config, logger, config_file_dir):
140140
if not os.path.isabs(config_template_path):
141141
config_template_path = os.path.join(config_file_dir, config_template_path)
142142
try:
143-
with open(config_template_path, 'r') as fh:
143+
with open(config_template_path, 'r', encoding='utf-8') as fh:
144144
config_template_data = fh.read().replace('$tenant$', self.tenant)
145145
config_template = json.loads(config_template_data, object_pairs_hook=OrderedDict)
146146

@@ -204,7 +204,7 @@ def __init__(self, config, logger, config_file_dir):
204204
try:
205205
if not os.path.isabs(themes_config):
206206
themes_config = os.path.join(config_file_dir, themes_config)
207-
with open(themes_config) as f:
207+
with open(themes_config, encoding='utf-8') as f:
208208
themes_config = json.load(f)
209209
except:
210210
msg = "Failed to read themes configuration %s" % themes_config
@@ -243,7 +243,7 @@ def __init__(self, config, logger, config_file_dir):
243243
'schema-versions.json'
244244
)
245245
try:
246-
with open(schema_versions_path) as f:
246+
with open(schema_versions_path, encoding='utf-8') as f:
247247
schema_versions = json.load(f)
248248
except Exception as e:
249249
msg = (
@@ -522,7 +522,7 @@ def validate_schema(self, config, schema_url):
522522
# parse schema URL
523523
file_name = os.path.basename(urlparse(schema_url).path)
524524
file_path = os.path.join(self.json_schemas_path, file_name)
525-
with open(file_path) as f:
525+
with open(file_path, encoding='utf-8') as f:
526526
schema = json.load(f)
527527
except Exception as e:
528528
self.logger.warning(
@@ -751,7 +751,7 @@ def search_print_layouts(self, generator_config):
751751
continue
752752

753753
path = os.path.join(qgis_print_layouts_dir, dirpath, filename)
754-
with open(path) as fh:
754+
with open(path, encoding='utf-8') as fh:
755755
doc = ElementTree.parse(fh)
756756

757757
layout = doc.getroot()

src/config_generator/map_viewer_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ def copy_index_html(self):
916916
# read index.html
917917
index_file = cfg_qwc2_config.get('qwc2_index_file', 'index.html')
918918
index_contents = None
919-
with open(index_file) as f:
919+
with open(index_file, encoding='utf-8') as f:
920920
index_contents = f.read()
921921

922922
# write to tenant dir

src/config_generator_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def timestamp(self):
4646

4747
# read ConfigGenerator config file
4848
try:
49-
with open(args.config_file) as f:
49+
with open(args.config_file, encoding='utf-8') as f:
5050
# parse config JSON with original order of keys
5151
config = json.load(f, object_pairs_hook=OrderedDict)
5252
except Exception as e:

src/download_json_schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
f'schemas/schema-versions.json'
2222
)
2323
try:
24-
with open(schema_versions_path) as f:
24+
with open(schema_versions_path, encoding='utf-8') as f:
2525
schema_versions = json.load(f)
2626
except Exception as e:
2727
print(

0 commit comments

Comments
 (0)