| 1140 | |
| 1141 | |
| 1142 | def _json_decode(o): |
| 1143 | cls = o.pop('__class__', None) |
| 1144 | if cls is None: |
| 1145 | return o |
| 1146 | elif cls == 'FontManager': |
| 1147 | r = FontManager.__new__(FontManager) |
| 1148 | r.__dict__.update(o) |
| 1149 | return r |
| 1150 | elif cls == 'FontEntry': |
| 1151 | if not os.path.isabs(o['fname']): |
| 1152 | o['fname'] = os.path.join(mpl.get_data_path(), o['fname']) |
| 1153 | r = FontEntry(**o) |
| 1154 | return r |
| 1155 | else: |
| 1156 | raise ValueError("Don't know how to deserialize __class__=%s" % cls) |
| 1157 | |
| 1158 | |
| 1159 | def json_dump(data, filename): |