本文整理汇总了Python中mnemosyne.libmnemosyne.Mnemosyne类的典型用法代码示例。如果您正苦于以下问题:Python Mnemosyne类的具体用法?Python Mnemosyne怎么用?Python Mnemosyne使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mnemosyne类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, datadir=None, category=None):
Mnemosyne.__init__(self)
self.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget",
"ReviewWidget"))
self.components.append(\
("mnemosyne.libmnemosyne.ui_components.main_widget",
"MainWidget"))
self.components.append(("mnemosyne.maemo_ui.factory", "ConfigHook"))
if datadir:
datadir = os.path.abspath(datadir)
elif os.path.exists(os.path.join(os.getcwdu(), ".mnemosyne")):
datadir = os.path.abspath(os.path.join(os.getcwdu(), ".mnemosyne"))
else:
datadir = os.path.abspath(os.path.join(os.path.expanduser("~"),
".mnemosyne"))
self.initialise(datadir)
self.review_controller().reset()
self.card_type = [ct for ct in self.card_types() \
if ct.name == "Front-to-back only"][0]
self.saved = False
self.category = category #Category(category)
示例2: TestSmconvImport
class TestSmconvImport(MnemosyneTest):
def setup(self):
self.initialise_data_dir()
self.mnemosyne = Mnemosyne(upload_science_logs=False, interested_in_old_reps=True, asynchronous_database=True)
self.mnemosyne.components.insert(
0, ("mnemosyne.libmnemosyne.translators.gettext_translator", "GetTextTranslator")
)
self.mnemosyne.components.append(("mnemosyne_test", "TestReviewWidget"))
self.mnemosyne.components.append(("test_smconv_import", "Widget"))
self.mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
self.review_controller().reset()
def sm7_importer(self):
for format in self.mnemosyne.component_manager.all("file_format"):
if format.__class__.__name__ == "Smconv_XML":
return format
def test_1(self):
global last_error
filename = os.path.join(os.getcwd(), "tests", "files", "smconv.xml")
self.sm7_importer().do_import(filename)
assert last_error is ""
assert len([c for c in self.database().cards()]) == 3
def teardown(self):
filename = os.path.join(os.getcwd(), "dot_test", "default.db_media", "a.png")
if os.path.exists(filename):
os.remove(filename)
filename = os.path.join(os.getcwd(), "dot_test", "test.txt")
if os.path.exists(filename):
os.remove(filename)
MnemosyneTest.teardown(self)
示例3: MnemosyneTest
class MnemosyneTest():
def setup(self):
os.system("rm -fr dot_test")
self.restart()
def restart(self):
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.main_widget", "MainWidget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ProgressDialog"))
self.mnemosyne.initialise(os.path.abspath("dot_test"))
self.review_controller().reset()
def teardown(self):
self.mnemosyne.finalise()
def config(self):
return self.mnemosyne.component_manager.get_current("config")
def log(self):
return self.mnemosyne.component_manager.get_current("log")
def database(self):
return self.mnemosyne.component_manager.get_current("database")
def scheduler(self):
return self.mnemosyne.component_manager.get_current("scheduler")
def main_widget(self):
return self.mnemosyne.component_manager.get_current("main_widget")
def review_widget(self):
return self.mnemosyne.component_manager.get_current("review_widget")
def controller(self):
return self.mnemosyne.component_manager.get_current("controller")
def review_controller(self):
return self.mnemosyne.component_manager.get_current("review_controller")
def card_types(self):
return self.mnemosyne.component_manager.get_all("card_type")
def filters(self):
return self.mnemosyne.component_manager.get_all("filter")
def plugins(self):
return self.mnemosyne.component_manager.get_all("plugin")
def card_type_by_id(self, id):
return self.mnemosyne.component_manager.card_type_by_id[id]
示例4: TestMainController
class TestMainController(MnemosyneTest):
def setup(self):
os.system("rm -fr dot_test")
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(\
("test_main_controller", "Widget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "AddCardsDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "EditFactDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "BrowseCardsDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "CardAppearanceDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ActivatePluginsDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ManageCardTypesDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "StatisticsDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ConfigurationDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ActivateCardsDialog"))
self.mnemosyne.initialise(os.path.abspath("dot_test"))
self.review_controller().reset()
def test_coverage(self):
self.controller().heartbeat()
self.controller().add_cards()
card_type = self.card_type_by_id("2")
fact_data = {"q": "q", "a": "a"}
card_1, card_2 = self.controller().create_new_cards(fact_data,
card_type, grade=-1, tag_names=["default"])
self.review_controller().new_question()
self.controller().edit_current_card()
self.controller().file_new()
self.controller().file_open()
self.controller().file_save_as()
self.controller().card_appearance()
self.controller().activate_plugins()
self.controller().manage_card_types()
self.controller().browse_cards()
self.controller().configure()
self.controller().show_statistics()
self.controller().activate_cards()
def test_2(self):
self.controller().file_save_as()
self.controller().file_open()
示例5: __init__
def __init__(self, data_dir=None):
MnemosyneParent.__init__(self, upload_science_logs=False,
interested_in_old_reps=True)
self.components.insert(0,
("mnemosyne.libmnemosyne.translators.gettext_translator",
"GetTextTranslator"))
self.components.append(\
("mnemosyne.script", "ScriptMainWidget"))
self.components.append(\
("mnemosyne.script", "ScriptReviewWidget"))
self.initialise(data_dir)
示例6: MyClient
class MyClient(Client):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
def __init__(self):
os.system("rm -fr dot_benchmark")
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(("test_sync", "Widget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ProgressDialog"))
self.mnemosyne.initialise(os.path.abspath(os.path.join(os.getcwdu(),
"dot_benchmark")))
self.mnemosyne.review_controller().reset()
Client.__init__(self, "client_machine_id", self.mnemosyne.database(),
self.mnemosyne.main_widget())
def do_sync(self):
self.sync("127.0.0.1", 8190, "user", "pass")
self.mnemosyne.database().save()
示例7: test_setup
def test_setup():
shutil.rmtree("dot_test", ignore_errors=True)
global mnemosyne
mnemosyne = Mnemosyne(upload_science_logs=False, interested_in_old_reps=True)
mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translators.gettext_translator",
"GetTextTranslator"))
mnemosyne.components.append(\
("test_add_cards", "Widget"))
mnemosyne.components.append(\
("mnemosyne_test", "TestReviewWidget"))
mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "EditCardDialog"))
mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
mnemosyne.review_controller().reset()
示例8: TestDBImport
class TestDBImport(MnemosyneTest):
def setup(self):
self.initialise_data_dir()
self.mnemosyne = Mnemosyne(upload_science_logs=False, interested_in_old_reps=True,
asynchronous_database=True)
self.mnemosyne.components.insert(0,
("mnemosyne.libmnemosyne.translators.gettext_translator", "GetTextTranslator"))
self.mnemosyne.components.append(\
("mnemosyne_test", "TestReviewWidget"))
self.mnemosyne.components.append(\
("test_db_import", "Widget"))
self.mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
self.review_controller().reset()
def db_importer(self):
for format in self.mnemosyne.component_manager.all("file_format"):
if format.__class__.__name__ == "Mnemosyne2Db":
return format
def test_1(self):
filename = os.path.join(os.getcwd(), "tests", "files", "basedir_to_merge", "config.db")
self.db_importer().do_import(filename)
assert "configuration database" in last_error
def test_2(self):
fact_data = {"f": "question",
"b": "answer"}
card_type = self.card_type_with_id("1")
old_card = self.controller().create_new_cards(fact_data, card_type,
grade=-1, tag_names=["default"])[0]
assert len([self.database().cards()]) == 1
filename = os.path.join(os.getcwd(), "tests", "files", "basedir_to_merge", "to_merge.db")
global last_error
last_error = ""
self.db_importer().do_import(filename)
assert last_error == ""
db = self.database()
assert db.con.execute("select count() from log where event_type != 26").fetchone()[0] == 258
self.review_controller().reset()
assert self.database().card_count() == 7
assert self.database().active_count() == 6
assert self.database().fact_count() == 5
card_type = self.database().card_type("2::new clone", is_id_internal=False)
assert self.config().card_type_property("background_colour", card_type) == 4278233600
示例9: test_upgrade
def test_upgrade(self):
os.system("rm -fr dot_test")
basedir = os.path.join(os.getcwd(), "tests", "files", "basedir_bz2")
shutil.copytree(basedir, "dot_test")
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ProgressDialog"))
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(\
("test_mem_import", "Widget"))
self.mnemosyne.initialise(os.path.abspath("dot_test"))
assert self.config()["grade_0_cards_in_hand"] == 7
assert "grade_0_items_at_once" not in self.config()
assert self.config()["dvipng"].rstrip() == \
"dvipng -D 300 -T tight tmp.dvi\necho"
assert "14pt" in self.config()["latex_preamble"]
assert os.path.exists(os.path.join("dot_test", "latex",
"dvipng.NO_LONGER_USED"))
assert not os.path.exists(os.path.join("dot_test", "latex", "dvipng"))
self.review_controller().reset()
示例10: load_mnemosyne
def load_mnemosyne(self):
self.mnemosyne = Mnemosyne(upload_science_logs=True,
interested_in_old_reps=True)
self.mnemosyne.components.insert(0, (
("mnemosyne.libmnemosyne.translators.gettext_translator",
"GetTextTranslator")))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.main_widget",
"MainWidget"))
self.mnemosyne.components.append(\
("mnemosyne.web_server.review_wdgt",
"ReviewWdgt"))
self.mnemosyne.components.append(\
("mnemosyne.web_server.web_server_render_chain",
"WebServerRenderChain"))
self.mnemosyne.initialise(self.data_dir, config_dir=self.config_dir,
filename=self.filename, automatic_upgrades=False)
self.mnemosyne.review_controller().set_render_chain("web_server")
self.save_after_n_reps = self.mnemosyne.config()["save_after_n_reps"]
self.mnemosyne.config()["save_after_n_reps"] = 1
self.mnemosyne.start_review()
self.mnemosyne.review_widget().set_is_server_local(\
self.is_server_local)
self.is_mnemosyne_loaded = True
self.release_database_after_timeout = \
ReleaseDatabaseAfterTimeout(self.port)
self.release_database_after_timeout.start()
示例11: setup
def setup(self):
os.system("rm -fr dot_test")
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(\
("test_main_controller", "Widget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "AddCardsDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "EditFactDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "BrowseCardsDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "CardAppearanceDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ActivatePluginsDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ManageCardTypesDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "StatisticsDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ConfigurationDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ActivateCardsDialog"))
self.mnemosyne.initialise(os.path.abspath("dot_test"))
self.review_controller().reset()
示例12: restart
def restart(self):
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(\
("test_logging", "MyMainWidget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
self.mnemosyne.initialise(os.path.abspath("dot_test"))
self.review_controller().reset()
示例13: test_log_upload
def test_log_upload(self):
machine_id_file = os.path.join(self.mnemosyne.config().config_dir, "machine.id")
f = file(machine_id_file, "w")
print >> f, "TESTMACHINE"
f.close()
self.config().change_user_id("UPLOADTEST")
self.config()["max_log_size_before_upload"] = 1
MnemosyneTest.teardown(self)
self.mnemosyne = Mnemosyne(upload_science_logs=True, interested_in_old_reps=True,
asynchronous_database=True)
self.mnemosyne.components.insert(0,
("mnemosyne.libmnemosyne.translators.gettext_translator", "GetTextTranslator"))
self.mnemosyne.components.append(\
("test_logging", "MyMainWidget"))
self.mnemosyne.components.append(\
("mnemosyne_test", "TestReviewWidget"))
self.mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
self.mnemosyne.start_review()
MnemosyneTest.teardown(self)
self.mnemosyne = Mnemosyne(upload_science_logs=True, interested_in_old_reps=True,
asynchronous_database=True)
self.mnemosyne.components.insert(0,
("mnemosyne.libmnemosyne.translators.gettext_translator", "GetTextTranslator"))
self.mnemosyne.components.append(\
("test_logging", "MyMainWidget"))
self.mnemosyne.components.append(\
("mnemosyne_test", "TestReviewWidget"))
self.mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
self.mnemosyne.start_review()
MnemosyneTest.teardown(self)
self.mnemosyne = Mnemosyne(upload_science_logs=True, interested_in_old_reps=True,
asynchronous_database=True)
self.mnemosyne.components.insert(0,
("mnemosyne.libmnemosyne.translators.gettext_translator", "GetTextTranslator"))
self.mnemosyne.components.append(\
("test_logging", "MyMainWidget"))
self.mnemosyne.components.append(\
("mnemosyne_test", "TestReviewWidget"))
self.mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
self.mnemosyne.start_review()
示例14: setup
def setup(self):
self.initialise_data_dir()
self.mnemosyne = Mnemosyne(upload_science_logs=False, interested_in_old_reps=True, asynchronous_database=True)
self.mnemosyne.components.insert(
0, ("mnemosyne.libmnemosyne.translators.gettext_translator", "GetTextTranslator")
)
self.mnemosyne.components.append(("mnemosyne_test", "TestReviewWidget"))
self.mnemosyne.components.append(("test_smconv_import", "Widget"))
self.mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
self.review_controller().reset()
示例15: __init__
def __init__(self):
Thread.__init__(self)
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(("test_sync", "Widget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ProgressDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))