53
64
self.basedir = basedir
55
# Load config file from basedir if it exists.
57
if os.path.exists(os.path.join(self.basedir, "config")):
66
# Fill basedir with configuration files. Do this even if basedir
67
# already exists, because we might have added new files since the
72
# Load config file from basedir.
60
76
# Set defaults, even if a previous file exists, because we might
61
77
# have added new keys since the last version.
137
153
##########################################################################
157
##########################################################################
159
def fill_basedir(self)
162
exists = os.path.exists
164
# Create default paths.
166
if not exists(self.basedir):
167
os.mkdir(self.basedir)
169
if not exists(join(self.basedir, "history")):
170
os.mkdir(join(self.basedir, "history"))
172
if not exists(join(self.basedir, "latex")):
173
os.mkdir(join(self.basedir, "latex"))
175
if not exists(join(self.basedir, "plugins")):
176
os.mkdir(join(self.basedir, "plugins"))
178
if not exists(join(self.basedir, "backups")):
179
os.mkdir(join(self.basedir, "backups"))
181
# Create default latex preamble and postamble.
183
latexdir = join(self.basedir, "latex")
184
preamble = join(latexdir, "preamble")
185
postamble = join(latexdir, "postamble")
186
dvipng = join(latexdir, "dvipng")
188
if not os.path.exists(preamble):
189
f = file(preamble, 'w')
190
print >> f, "\\documentclass[12pt]{article}"
191
print >> f, "\\pagestyle{empty}"
192
print >> f, "\\begin{document}"
195
if not os.path.exists(postamble):
196
f = file(postamble, 'w')
197
print >> f, "\\end{document}"
200
if not os.path.exists(dvipng):
201
f = file(dvipng, 'w')
202
print >> f, "dvipng -D 200 -T tight tmp.dvi"
205
# Create default config.py.
207
configfile = os.path.join(self.basedir, "config.py")
208
if not os.path.exists(configfile):
209
f = file(configfile, 'w')
211
"""# Mnemosyne configuration file.
213
# Align question/answers to the left (True/False)
216
# Keep detailed logs (True/False).
219
# Upload server. Only change when prompted by the developers.
220
upload_server = "mnemosyne-proj.dyndns.org:80"
222
# Set to True to prevent you from accidentally revealing the answer
223
# when clicking the edit button.
224
only_editable_when_answer_shown = False
226
# The translation to use, e.g. 'de' for German (including quotes).
227
# See http://www.mnemosyne-proj.org/help/translations.php for a list
228
# of available translations.
229
# If locale is set to None, the system's locale will be used.
232
# The number of daily backups to keep. Set to -1 for no limit.
235
# The moment the new day starts. Defaults to 3 am. Could be useful to
236
# change if you are a night bird.
242
##########################################################################
141
246
# TODO: prune unneeded keys.