def gupdateNONEtoV1_0_0(export_sSet): export_version = '1.0.0' #added in updates to 1.0.0: # added versioning to exports # made latex pathing independent of platform # update latex type to prevent pathing issues for simp in export_sSet.rawSimps: #check if export_math_data is of filetype 'latex' if simp.math_data().exported_math_data.type == 'latex': new_file_dict = update_latex('sm(C)', simp.math_data().exported_math_data()) simp.math_data().exported_math_data = Math_Data( type='latex', math_data=new_file_dict) # #^export_data #^orig math_data export_simplex = Simplex( 0, math_data=Math_Data( type='exported golog', math_data=export_sSet)) #create a simplex from the export_sSet export_meta = golog_export.export_data( export_simplex, export_version=export_version ) # create meta_data in the form of export_data return export_meta
def transform(self, base, **kwargs): if self.exported_math_data.type == 'exported golog': golog_dict = { 'golog': sSet_to_golog(base, self.exported_math_data()['golog']), 'folder_path': self.exported_math_data()['folder_path'] } return Math_Data(type='golog', math_data=golog_dict) else: return self.exported_math_data
def golog_to_sSet(golog): old_to_new = stripsSet(golog.sSet) for simp in old_to_new.dom.rawSimps: # exported_data = export_data(golog, simp, graphics_kwargs = golog.Simplex_to_Graphics[simp].graphics_kwargs) #create some pickleable export_data exported_data = export_data( simp, graphics_kwargs=golog.Simplex_to_Graphics[simp].graphics_kwargs ) #create some pickleable export_data old_to_new(simp).math_data = Math_Data( type='export_data', math_data=exported_data ) #set math_data of new simplex to export_data return old_to_new.codom
def __init__(self, old_simplex, **kwargs): #if math_data is a golog, transform it to an sSet for exporting if old_simplex.math_data.type == 'golog': export_golog = golog_to_sSet(old_simplex.math_data()['golog']) golog_dict = { 'golog': export_golog, 'folder_path': old_simplex.math_data()['folder_path'] } self.exported_math_data = Math_Data(type='exported golog', math_data=golog_dict) else: self.exported_math_data = old_simplex.math_data # for key in kwargs.keys(): setattr(self, key, kwargs[key])
def gexport(golog, location_string): ''' takes a golog and a absolute path, and exports it to that path ''' #check if location exists golog_folder = os.path.join(location_string, golog.label) if os.path.exists(golog_folder): print('MAY OVERRIDE GOLOG OF SAME NAME') export_sSet = golog_to_sSet(golog) # create pickle-able sSet export_simplex = Simplex( 0, math_data=Math_Data( type='exported golog', math_data=export_sSet)) #create a simplex from the export_sSet export_meta = export_data(export_simplex, export_version=export_version ) # create meta_data in the form of export_data #pickle it to location with open(location_string, 'wb') as file: pickle.dump(export_meta, file) return location_string