kopia lustrzana https://github.com/EmbroidePy/pyembroidery
Error-catch Non-UTF8 DST header
Corrects a defect that would cause a non-utf8 header to prevent the reading of the body.pull/84/head
rodzic
2df482ddfa
commit
2ee9b209dd
|
@ -52,10 +52,13 @@ def process_header_info(out, prefix, value):
|
|||
|
||||
def dst_read_header(f, out):
|
||||
header = f.read(512)
|
||||
header_string = header.decode('utf8')
|
||||
for line in [x.strip() for x in header_string.split('\r')]:
|
||||
if len(line) > 3:
|
||||
process_header_info(out, line[0:2].strip(), line[3:].strip())
|
||||
try:
|
||||
header_string = header.decode('utf8')
|
||||
for line in [x.strip() for x in header_string.split('\r')]:
|
||||
if len(line) > 3:
|
||||
process_header_info(out, line[0:2].strip(), line[3:].strip())
|
||||
except UnicodeDecodeError: # The header contains non-utf8 information and omitted. See #83
|
||||
pass
|
||||
|
||||
|
||||
def dst_read_stitches(f, out, settings=None):
|
||||
|
@ -90,7 +93,7 @@ def dst_read_stitches(f, out, settings=None):
|
|||
trim_distance = settings.get("trim_distance", trim_distance)
|
||||
clipping = settings.get('clipping', clipping)
|
||||
if trim_distance is not None:
|
||||
trim_distance *= 10 # Pixels per mm. Native units are 1/10 mm.
|
||||
trim_distance *= 10 # Pixels per mm. Native units are 1/10 mm.
|
||||
out.interpolate_trims(count_max, trim_distance, clipping)
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
def expand(data, uncompressed_size=None):
|
||||
compress = EmbCompress()
|
||||
return compress.decompress(data, uncompressed_size)
|
||||
emb_compress = EmbCompress()
|
||||
return emb_compress.decompress(data, uncompressed_size)
|
||||
|
||||
|
||||
def compress(data):
|
||||
size = len(data)
|
||||
return bytearray([(size >> 0) & 0xFF, (size >> 8) & 0xFF, 0x02, 0xA0, 0x01, 0xFE]) + data
|
||||
|
||||
|
||||
class Huffman:
|
||||
|
|
Ładowanie…
Reference in New Issue