def test_udo_statement_gen__not_raises(self): p = parse_pch2(self.data, self.poly_mix2_fn) p.cables = [transform_in2in_cables(p, c) for c in p.cables] zak = ZakSpace() udos = zak.connect_patch(p) csd = Csd(p, zak, udos) csd.get_code()
def parse_pch2(data: ProjectData, pch2_file: str, convert_in2in=True) -> Patch: patch = Patch(data) with open(pch2_file, 'rb') as pch2: parse_header(pch2, patch) context = {'head_4d_count': 0} while True: object_header = pch2.read(3) if len(object_header) == 3: obj_header, obj_len = unpack('>BH', object_header) blob = pch2.read(obj_len) blob_bits = bitarray(endian='big') blob_bits.frombytes(blob) parse_data_object(obj_header, blob_bits, patch, context) else: break if convert_in2in: patch.cables = [c for c in [transform_in2in_cables(patch, c) for c in patch.cables] if c is not None] return patch
def test_in2in__all_cables_from_the_first_module(self): pch2 = get_test_resource('test_in2in.pch2') patch = parse_pch2(self.data, pch2) patch.cables = [transform_in2in_cables(patch, c) for c in patch.cables] for c in patch.cables: self.assertEqual(c.module_from, 1)