datetime.now().strftime('%y-%m-%d_%H-%M-%S.db')) MakeDB(db_path, f.data) if latest_backup_symlink: os.remove(latest_backup_symlink) if os.path.exists( latest_backup_symlink) else None try: os.symlink(db_path, latest_backup_symlink) except OSError: print('[WARNING] Failed to create a latest_backup_symlink!') if report_path: print('Validating...') report_md = "%s\n===\n\n" % os.path.basename(db_path) report_md += Validator().validate(db_path) try: import markdown except ImportError: print( '[WARNING] Execute `pip install markdown` to generate true HTML !!!' ) report_html = '<pre>%s</pre>' % report_md else: print('Converting report to HTML...') report_html = markdown.markdown(report_md) report_html = '<!DOCTYPE html><html><head><meta charset="utf-8"></head>' \ '<body>%s</body></html>' % report_html print('Saving report...') with open(report_path, 'w', encoding='utf-8') as f: f.write(report_html)