~kevang/mnemosyne-proj/grade-shortcuts-improvements

« back to all changes in this revision

Viewing changes to mnemosyne/mnemosyne/libmnemosyne/__init__.py

  • Committer: pbienst
  • Date: 2008-07-23 09:59:16 UTC
  • Revision ID: svn-v3-trunk0:e5e6b78b-db40-0410-9517-b98c64f8d2c1:trunk:467
Progress dump.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
# TODO: move these import to initialise, and automatically loop through
24
24
# all the contents of the directories?
25
25
 
26
 
from mnemosyne.libmnemosyne.databases.pickle import Pickle
 
26
 
27
27
 
28
28
log = logging.getLogger("mnemosyne")
29
29
 
42
42
 
43
43
    config.initialise(basedir)
44
44
    initialise_lockfile()
45
 
 
46
 
    # TODO: Create default database if none exists?
47
 
    
 
45
    initialise_new_empty_database()        
48
46
    initialise_logging()
49
47
    initialise_error_handling()
50
48
    initialise_system_plugins()
66
64
 
67
65
##############################################################################
68
66
#
69
 
# initialise_error_handling
 
67
# initialise_new_empty_database
70
68
#
71
69
##############################################################################
72
70
 
73
 
def initialise_error_handling():
74
 
 
75
 
    # Write errors to a file (otherwise this causes problem on Windows).
76
 
 
77
 
    if sys.platform == "win32":
78
 
        error_log = os.path.join(basedir, "error_log.txt")
79
 
        sys.stderr = file(error_log, 'a')    
80
 
 
81
 
 
 
71
def initialise_new_empty_database():
 
72
 
 
73
    from mnemosyne.libmnemosyne.plugin_manager import get_database  
 
74
 
 
75
    filename = config["path"]
 
76
 
 
77
    if not os.path.exists(os.path.join(config.basedir, filename)):
 
78
        get_database().new(os.path.join(config.basedir, filename))
 
79
 
 
80
        
82
81
 
83
82
##############################################################################
84
83
#
109
108
 
110
109
##############################################################################
111
110
#
 
111
# initialise_error_handling
 
112
#
 
113
##############################################################################
 
114
 
 
115
def initialise_error_handling():
 
116
 
 
117
    # Write errors to a file (otherwise this causes problem on Windows).
 
118
 
 
119
    if sys.platform == "win32":
 
120
        error_log = os.path.join(basedir, "error_log.txt")
 
121
        sys.stderr = file(error_log, 'a')    
 
122
 
 
123
 
 
124
 
 
125
##############################################################################
 
126
#
112
127
# initialise_system_plugins
113
128
#
114
129
#  These are now hard coded, but if needed, an application could
120
135
 
121
136
    # Database
122
137
 
 
138
    from mnemosyne.libmnemosyne.databases.pickle import Pickle
 
139
 
123
140
    plugin_manager.register_plugin("database", Pickle())    
124
141
 
125
142
    # UI controllers
126
 
 
 
143
    
 
144
    from mnemosyne.libmnemosyne.ui_controllers.SM2_controller \
 
145
                                                   import SM2Controller
 
146
    
 
147
    plugin_manager.register_plugin("ui_controller", SM2Controller())
 
148
    
127
149
    # Card types.
128
150
 
129
151
    # These are registered in the GUI, because it's easier to do so