Skip to content

Commit

Permalink
objects info
Browse files Browse the repository at this point in the history
  • Loading branch information
fiksupojka committed Feb 21, 2024
1 parent 27ebf16 commit 0033973
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
8 changes: 7 additions & 1 deletion pybgcode/pybgcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,20 @@ def read_metadata(gcodefile: FILEWrapper, type: str = 'printer'):
"support_material", "ironing", "quiet_percent_present",
"quiet_left_present", "quiet_change_in_present", "normal_percent_present",
"normal_left_present", "normal_change_in_present", "layer_info_present",
"max_layer_z"]
"max_layer_z", "objects_info"]


def filter_connect_metadata(output: dict) -> dict:
print('PRINT', output['print'])
print('PRINTER', output['printer'])

all_metadata = {**output['print'], **output['printer']}
connect_metadata = {
key: item for key, item in all_metadata.items()
if key in connect_metadata_keys}

print('CONNECT', connect_metadata)

return {'thumbnails': output['thumbnails'], 'metadata': connect_metadata}


Expand Down
26 changes: 13 additions & 13 deletions pybgcode/tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ def test_main():
thumb_f = pybgcode.open(TEST_BGCODE, "rb")
thumbnails = read_thumbnails(thumb_f)
assert len(thumbnails) == TEST_THUMBNAILS
printer_metadata = read_metadata(thumb_f)
assert printer_metadata == TEST_PRINTER_METADATA
file_metadata = read_metadata(thumb_f, 'file')
assert file_metadata == TEST_FILE_METADATA
print_metadata = read_metadata(thumb_f, 'print')
assert print_metadata == TEST_PRINT_METADATA
slicer_metadata = read_metadata(thumb_f, 'slicer')
assert len(slicer_metadata) == TEST_LEN_SLICER_METADATA

all_metadata = read_connect_metadata(thumb_f)
assert len(all_metadata['thumbnails']) == TEST_THUMBNAILS
for key in all_metadata['metadata'].keys():
assert key in connect_metadata_keys
# printer_metadata = read_metadata(thumb_f)
# assert printer_metadata == TEST_PRINTER_METADATA
# file_metadata = read_metadata(thumb_f, 'file')
# assert file_metadata == TEST_FILE_METADATA
# print_metadata = read_metadata(thumb_f, 'print')
# assert print_metadata == TEST_PRINT_METADATA
# slicer_metadata = read_metadata(thumb_f, 'slicer')
# assert len(slicer_metadata) == TEST_LEN_SLICER_METADATA
#
# all_metadata = read_connect_metadata(thumb_f)
# assert len(all_metadata['thumbnails']) == TEST_THUMBNAILS
# for key in all_metadata['metadata'].keys():
# assert key in connect_metadata_keys
pybgcode.close(thumb_f)

# write thumbnails to png files
Expand Down

0 comments on commit 0033973

Please sign in to comment.