(saved_id)
| 9921 | } |
| 9922 | const loaded_storages = new Map(); |
| 9923 | const persistent_load = (saved_id) => { |
| 9924 | switch (saved_id[0]) { |
| 9925 | case 'storage': { |
| 9926 | const [, storage_type, key, , numel] = saved_id; |
| 9927 | if (!loaded_storages.has(key)) { |
| 9928 | const storage = new storage_type(numel); |
| 9929 | if (!storage._set_cdata) { |
| 9930 | throw new python.Error(`'${storage_type.__name__}._set_cdata' is not a function.`); |
| 9931 | } |
| 9932 | const name = `data/${key}`; |
| 9933 | const stream = entries.get(name); |
| 9934 | if (!stream) { |
| 9935 | throw new python.Error(`Record '${name}' not found.`); |
| 9936 | } |
| 9937 | storage._set_cdata(stream); |
| 9938 | loaded_storages.set(key, storage); |
| 9939 | } |
| 9940 | return loaded_storages.get(key); |
| 9941 | } |
| 9942 | default: { |
| 9943 | throw new python.Error(`Unsupported persistent load type '${saved_id[0]}'.`); |
| 9944 | } |
| 9945 | } |
| 9946 | }; |
| 9947 | const data_file = entries.get('data.pkl'); |
| 9948 | const unpickler = new pickle.Unpickler(data_file); |
| 9949 | unpickler.persistent_load = persistent_load; |
no test coverage detected