def getDictionaryVersions(self): dictionaries = getAvailableDictionaryNames(self.db, includePseudo=False) if self.db.hasTable('UpdateVersion'): table = self.db.tables['UpdateVersion'] versionDict = dict( [(tableName, datetime.min) for tableName in dictionaries]) versionDict.update(dict(self.db.selectRows( select([table.c.TableName, table.c.ReleaseDate], table.c.TableName.in_(dictionaries))))) return versionDict else: return dict([(table, None) for table in dictionaries])
def __init__(self, dictionary=None, dbConnectInst=None, databaseUrl=None, strokeOrderType=None, showAlternativeHeadwords=True, **options): self.db = dbConnectInst or getDBConnector( util.getDatabaseConfiguration(databaseUrl)) self.showAlternativeHeadwords = showAlternativeHeadwords self.useExtraReadingInformation = options.get( 'useExtraReadingInformation', False) self.availableDictionaryNames = getAvailableDictionaryNames(self.db) # get ditionary if dictionary in self.availableDictionaryNames: self._dictionary = getDictionary(dictionary, dbConnectInst=self.db, ignoreIllegalSettings=True, **options) else: translationLanguage = getTranslationLanguage() self._dictionary = getDefaultDictionary(translationLanguage, dbConnectInst=self.db, ignoreIllegalSettings=True, **options) self.dictionary = self._dictionary.PROVIDES self.reading = self._dictionary.reading self.language = self._dictionary.language self.characterDomain = self._dictionary.charDB.characterDomain self.compatibleCharacterDomains \ = self._dictionary.charDB.getCompatibleCharacterDomains() # stroke order availableStrokeOrder = self.getAvailableStrokeOrderTypes() if strokeOrderType and strokeOrderType in availableStrokeOrder: self.strokeOrderType = strokeOrderType else: # don't show BIG_STROKE_ORDER_TYPE twice if self.BIG_STROKE_ORDER_TYPE in availableStrokeOrder: index = availableStrokeOrder.index(self.BIG_STROKE_ORDER_TYPE) del availableStrokeOrder[index] originalType = self.BIG_STROKE_ORDER_TYPE.replace('.segment', '') if originalType in availableStrokeOrder: index = availableStrokeOrder.index(originalType) del availableStrokeOrder[index] if availableStrokeOrder: self.strokeOrderType = availableStrokeOrder[0] else: self.strokeOrderType = None