Skip to content

Commit 1b02f10

Browse files
committed
Fix more unicode issues
1 parent 61b200a commit 1b02f10

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

InteractiveHtmlBom/core/ibom.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import absolute_import
22

3+
import io
34
import json
45
import logging
56
import os
@@ -526,7 +527,7 @@ def process_substitutions(bom_name_format, pcb_file_name, metadata):
526527
def generate_file(pcb_file_dir, pcb_file_name, pcbdata, config):
527528
def get_file_content(file_name):
528529
path = os.path.join(os.path.dirname(__file__), "..", "web", file_name)
529-
with open(path, "r") as f:
530+
with io.open(path, 'r', encoding='utf-8') as f:
530531
return f.read()
531532

532533
loginfo("Dumping pcb json data")
@@ -545,13 +546,14 @@ def get_file_content(file_name):
545546
html = get_file_content("ibom.html")
546547
html = html.replace('///CSS///', get_file_content('ibom.css'))
547548
html = html.replace('///SPLITJS///', get_file_content('split.js'))
548-
html = html.replace('///POINTER_EVENTS_POLYFILL///', get_file_content('pep.js'))
549+
html = html.replace('///POINTER_EVENTS_POLYFILL///',
550+
get_file_content('pep.js'))
549551
html = html.replace('///CONFIG///', config_js)
550552
html = html.replace('///PCBDATA///', pcbdata_js)
551553
html = html.replace('///UTILJS///', get_file_content('util.js'))
552554
html = html.replace('///RENDERJS///', get_file_content('render.js'))
553555
html = html.replace('///IBOMJS///', get_file_content('ibom.js'))
554-
with open(bom_file_name, "wt") as bom:
556+
with io.open(bom_file_name, 'wt', encoding='utf-8') as bom:
555557
bom.write(html)
556558
loginfo("Created file %s", bom_file_name)
557559
return bom_file_name

InteractiveHtmlBom/schematic_data/netlistparser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import io
2+
13
from .parser_base import ParserBase
24
from .sexpressions import parse_sexpression
35

46

57
class NetlistParser(ParserBase):
68
def get_extra_field_data(self):
7-
with open(self.file_name, 'r') as f:
9+
with io.open(self.file_name, 'r', encoding='utf-8') as f:
810
sexpression = parse_sexpression(f.read())
911
components = None
1012
for s in sexpression:

0 commit comments

Comments
 (0)