def savexml(self, file_name=None): """ Save a category under the format Moodle XML """ self.compilation() if file_name is None: file_name = self.get_name() category_xml = xmltodict.unparse(self.dict, pretty=True) strtools.savestr(unescape(category_xml), file_name + ".xml")
def import_latextomoodle(): # Importing a local template : idea taken from # https://stackoverflow.com/questions/6028000/how-to-read-a-static-file-from-inside-a-python-package import pkgutil, io if not os.path.isfile('latextomoodle.sty') : string = pkgutil.get_data("moodlexport", "templates/latextomoodle.sty").decode() savestr(string, 'latextomoodle.sty')
def savexml(self, file_name=None): """ Save a category under the format Moodle XML """ self.compilation() if file_name is None: file_name = self.get_name() file_name = strtools.filename_protect(file_name) category_xml = xmltodict.unparse( self.dict, pretty=True) # here all bools are converted to strings strtools.savestr(unescape(category_xml), file_name + ".xml")
def savetex(self, file_name=None): """ Save a category under the format TEX """ import moodlexport.python_to_latex # SO ANNOYING CIRCULAR IMPORT self.compilation() if file_name is None: file_name = self.get_name() file_name = strtools.filename_protect(file_name) string = moodlexport.python_to_latex.latexfile_document(self) string = strtools.html_to_latex( string) # we clean the file from all the html tags strtools.savestr(string, file_name + ".tex")