def test_wrong_string2(self):
     test_string = '''
     <html></a></html>
     '''
     all_tags = find_all_tags(test_string)
     with self.assertRaises(ValueError):
         new_string = partition_and_replace(test_string, all_tags)
 def test_standard_string2(self):
     test_string = '''
     <img src="www.example.com" />
     '''
     all_tags = find_all_tags(test_string)
     new_string = partition_and_replace(test_string, all_tags)
     self.assertEqual(test_string, new_string)
 def test_standard_string(self):
     test_string = '''
     <html>
       <head>
       </head>
       <body>
       </body>
     </html>
     '''
     all_tags = find_all_tags(test_string)
     new_string = partition_and_replace(test_string, all_tags)
     self.assertEqual(test_string, new_string)
Esempio n. 4
0
def enex(db_path, enex_file):
    """Convert Evernote .enex exports to SQLite"""
    file_length = os.path.getsize(enex_file)
    fp = open(enex_file, "r", encoding="utf-8")
    db = sqlite_utils.Database(db_path)
    with click.progressbar(length=file_length,
                           label="Importing from ENEX") as bar:
        for tag, note in find_all_tags(fp, ["note"],
                                       progress_callback=bar.update):
            save_note(db, note)
    fp.close()
    ensure_indexes(db)
 def test_nested_non_standard_string(self):
     test_string = '''
     <html>
       <head></>
     </>
     '''
     expected_new_string = '''
     <html>
       <head></head>
     </html>
     '''
     all_tags = find_all_tags(test_string)
     new_string = partition_and_replace(test_string, all_tags)
     self.assertEqual(new_string, expected_new_string)