compliant with Python 2.7

This commit is contained in:
opiopan 2019-04-01 22:07:56 +09:00
parent b7320a6b58
commit eda7527550
2 changed files with 4 additions and 2 deletions

View file

@ -128,7 +128,7 @@ ctx.dump('merged_drill.txt')
``` ```
## Panelizing Example ## Panelizing Example
This example board image is generated by following scripts This example board image is generated by following scripts from [these source data](examples).
- [panelizing script](examples/panelize.py) - [panelizing script](examples/panelize.py)
- [imaging script](examples/genimage.py) - [imaging script](examples/genimage.py)

View file

@ -3,7 +3,7 @@
# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com> # Copyright 2019 Hiroshi Murayama <opiopan@gmail.com>
import io import io, sys
from math import pi, cos, sin, tan, atan, atan2, acos, asin, sqrt from math import pi, cos, sin, tan, atan, atan2, acos, asin, sqrt
import dxfgrabber import dxfgrabber
from gerber.cam import CamFile, FileSettings from gerber.cam import CamFile, FileSettings
@ -561,6 +561,8 @@ class DxfFile(CamFile):
raise Exception('Not supported') raise Exception('Not supported')
def loads(data, filename=None): def loads(data, filename=None):
if sys.version_info.major == 2:
data = unicode(data)
stream = io.StringIO(data) stream = io.StringIO(data)
dxf = dxfgrabber.read(stream) dxf = dxfgrabber.read(stream)
return DxfFile(dxf) return DxfFile(dxf)