def test_langdb(options):
    inputdb  = options.ilangdb
    outputdb = options.olangdb
    loadonly = options.loadonly
    verbose  = options.verbose
    wordfile = options.wordfile

    log(verbose, '=== START ===')
    log(verbose, '* Loading DB: %s' % (inputdb))
    ldb = LanguageDB(filename=inputdb)
    log(verbose, '  Done')

    if loadonly:
        log(verbose, '=== END ===')
        return

    log(verbose, '* Importing word list: %s' % (wordfile))
    ldb.import_source(Source(filename=wordfile, import_user_id=2))
    log(verbose, '  Done')

    log(verbose, '* Saving %s: %s' % (ldb, outputdb))
    ldb.save(filename=outputdb)
    log(verbose, '  Done.')

    log(verbose, '=== END ===')
Beispiel #2
0
    def show(self):
        # Load last database
        db = LanguageDB(lang='')
        self.config.current_database = db

        if self.dbfilename:
            self.dbfilename = os.path.abspath(self.dbfilename)

        if os.path.exists(
                self.dbfilename
        ) and self.dbfilename != self.config.general['last_langdb_path']:
            if not self.load_langdb(self.dbfilename):
                self.quit()
        elif os.path.exists(self.config.general['last_langdb_path']):
            db.load(self.config.general['last_langdb_path'])
            fn = os.path.split(db.filename)[-1]
            self.main_window.set_title('Spelt - %(langdb_filename)s' %
                                       {'langdb_filename': fn})
        else:
            # If we couldn't find the previous database, act as if this is a
            # first run.
            if not self.load_langdb():
                self.quit()

        self.splash.hide()

        self.menu = Menu(self.glade, gui=self)
        self.word_list = WordList(self.glade, langdb=db, gui=self)
        self.edit_area = EditArea(self.glade,
                                  self.word_list,
                                  langdb=db,
                                  gui=self)

        self.word_list.word_selected_handlers.append(self.check_work_done)

        # Check if this is the first time the program is run
        if self.config.user['id'] == 0:
            if not self.load_langdb():
                self.quit()

        self.main_window.show_all()
        self.reload_database()
Beispiel #3
0
def test_langdb(options):
    inputdb = options.ilangdb
    outputdb = options.olangdb
    loadonly = options.loadonly
    verbose = options.verbose
    wordfile = options.wordfile

    log(verbose, '=== START ===')
    log(verbose, '* Loading DB: %s' % (inputdb))
    ldb = LanguageDB(filename=inputdb)
    log(verbose, '  Done')

    if loadonly:
        log(verbose, '=== END ===')
        return

    log(verbose, '* Importing word list: %s' % (wordfile))
    ldb.import_source(Source(filename=wordfile, import_user_id=2))
    log(verbose, '  Done')

    log(verbose, '* Saving %s: %s' % (ldb, outputdb))
    ldb.save(filename=outputdb)
    log(verbose, '  Done.')

    log(verbose, '=== END ===')