Skip to content

Commit

Permalink
Fix nightly compatibility and json utf errors
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1ck committed Feb 28, 2021
1 parent a63e4a0 commit e47db71
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions InteractiveHtmlBom/ecad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def get_parser_by_extension(file_name, config, logger):
""".json file may be from EasyEDA or a generic json format"""
import io
import json
with io.open(file_name, 'r') as f:
obj = json.load(f)
with io.open(file_name, 'r', encoding='utf-8') as f:
obj = json.load(f, encoding='utf-8')
if 'pcbdata' in obj:
return get_generic_json_parser(file_name, config, logger)
else:
Expand Down
8 changes: 4 additions & 4 deletions InteractiveHtmlBom/ecad/genericjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class GenericJsonParser(EcadParser):

def get_generic_json_pcb(self):
from os import path
with io.open(self.file_name, 'r') as f:
pcb = json.load(f)
with io.open(self.file_name, 'r', encoding='utf-8') as f:
pcb = json.load(f, encoding='utf-8')

if 'spec_version' not in pcb:
raise ValidationError("'spec_version' is a required property")
Expand All @@ -25,8 +25,8 @@ def get_generic_json_pcb(self):
'genericjsonpcbdata_v{}.schema'
.format(pcb['spec_version']))

with io.open(schema_file_name, 'r') as f:
schema = json.load(f)
with io.open(schema_file_name, 'r', encoding='utf-8') as f:
schema = json.load(f, encoding='utf-8')

validate(instance=pcb, schema=schema)

Expand Down
11 changes: 7 additions & 4 deletions InteractiveHtmlBom/ecad/kicad.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def parse_pad(self, pad):
def parse_footprints(self):
# type: () -> list
footprints = []
for f in self.footprints:
for f in self.footprints: # type: pcbnew.FOOTPRINT
ref = f.GetReference()

# bounding box
Expand All @@ -330,11 +330,14 @@ def parse_footprints(self):
f_copy = pcbnew.FOOTPRINT(f)
f_copy.SetOrientation(0)
f_copy.SetPosition(pcbnew.wxPoint(0, 0))
mrect = f_copy.GetFootprintRect()
if hasattr(f_copy, 'GetFootprintRect'):
footprint_rect = f_copy.GetFootprintRect()
else:
footprint_rect = f_copy.GetBoundingBox(False, False)
bbox = {
"pos": self.normalize(f.GetPosition()),
"relpos": self.normalize(mrect.GetPosition()),
"size": self.normalize(mrect.GetSize()),
"relpos": self.normalize(footprint_rect.GetPosition()),
"size": self.normalize(footprint_rect.GetSize()),
"angle": f.GetOrientation() * 0.1,
}

Expand Down

0 comments on commit e47db71

Please sign in to comment.