cjklib.dictionary.install — Install dictionaries
New in version 0.3.
Installs dictionaries at runtime.
Example:
Functions
-
cjklib.dictionary.install.getDownloader(dictionaryName, **options)
Get a dictionary downloader instance by dictionary name.
Parameter: | dictionaryName (str) – dictionary name |
Return type: | type |
Returns: | downloader instance |
-
cjklib.dictionary.install.getDownloaderClass(dictionaryName)
Get a dictionary downloader class by dictionary name.
Parameter: | dictionaryName (str) – dictionary name |
Return type: | type |
Returns: | downloader class |
-
cjklib.dictionary.install.getDownloaderClasses()
Gets all classes in module that implement
DownloaderBase.
Return type: | set |
Returns: | list of all classes inheriting form
DownloaderBase |
Classes
-
class cjklib.dictionary.install.CEDICTDownloader(downloadFunc=None, quiet=True)
Bases: cjklib.dictionary.install.PageDownloaderBase
Downloader for the CEDICT dictionary.
-
download(**options)
Downloads the dictionary and returns the path to the local file.
Parameters: |
- options – extra options
- targetName – target file name for downloaded file
- targetPath – target directory for downloaded file, file name
will be used as provided online
- temporary – if True a temporary file will be created
retaining the last extension (i.e. for .tar.gz only .gz will be
guaranteed.
|
Return type: | str
|
Returns: | path to local file
|
-
getDownloadLink(*args, **kwargs)
-
getDownloadPage(*args, **kwargs)
-
getVersion(*args, **kwargs)
-
class cjklib.dictionary.install.CEDICTGRDownloader(downloadFunc=None, quiet=True)
Bases: cjklib.dictionary.install.DownloaderBase
Downloader for the Gwoyeu Romatzyh version of the CEDICT dictionary.
-
download(**options)
Downloads the dictionary and returns the path to the local file.
Parameters: |
- options – extra options
- targetName – target file name for downloaded file
- targetPath – target directory for downloaded file, file name
will be used as provided online
- temporary – if True a temporary file will be created
retaining the last extension (i.e. for .tar.gz only .gz will be
guaranteed.
|
Return type: | str
|
Returns: | path to local file
|
-
getDownloadLink()
-
getVersion(*args, **kwargs)
- Version of the online available dictionary.
-
class cjklib.dictionary.install.CFDICTDownloader(downloadFunc=None, quiet=True)
Bases: cjklib.dictionary.install.PageDownloaderBase
Downloader for the CFDICT dictionary.
-
download(**options)
Downloads the dictionary and returns the path to the local file.
Parameters: |
- options – extra options
- targetName – target file name for downloaded file
- targetPath – target directory for downloaded file, file name
will be used as provided online
- temporary – if True a temporary file will be created
retaining the last extension (i.e. for .tar.gz only .gz will be
guaranteed.
|
Return type: | str
|
Returns: | path to local file
|
-
getDownloadLink(*args, **kwargs)
-
getDownloadPage(*args, **kwargs)
-
getVersion(*args, **kwargs)
-
class cjklib.dictionary.install.CommandLineInstaller
Bases: object
Command line dictionary installer.
-
buildParser()
-
classmethod getBuilderConfigSettings()
Gets the builder settings from the section Builder from cjklib.conf.
Return type: | dict |
Returns: | dictionary of builder options |
-
classmethod getDefaultOptions()
-
run()
- Runs the builder
-
class cjklib.dictionary.install.DictionaryInstaller(quiet=True)
Bases: object
Dictionary installer for downloading and installing a dictionary to a SQL
database.
-
classmethod getDefaultDatabaseUrl(dictionaryName, prefix=None, local=False, projectName='cjklib')
-
install(dictionaryName, **options)
Installs the given dictionary to a database.
Different installation methods are possible:
Parameters: |
- options – extra options
- databaseUrl – database connection setting in the format
driver://user:pass@host/database.
- dbConnectInst – instance of a
DatabaseConnector
- local – if True the SQLite file will be installed in the
user’s home directory.
- prefix – installation prefix for a global install (Unix only).
- forceUpdate – dictionary will be installed even if a newer
version already exists
- quiet – if True no status information will be printed to
stdout
|
-
class cjklib.dictionary.install.DownloaderBase(downloadFunc=None, quiet=True)
Bases: object
Abstract class for downloading dictionaries.
-
download(**options)
Downloads the dictionary and returns the path to the local file.
Parameters: |
- options – extra options
- targetName – target file name for downloaded file
- targetPath – target directory for downloaded file, file name
will be used as provided online
- temporary – if True a temporary file will be created
retaining the last extension (i.e. for .tar.gz only .gz will be
guaranteed.
|
Return type: | str
|
Returns: | path to local file
|
-
getDownloadLink()
Gets the download link for the online dictionary.
Needs to be implemented by subclasses.
-
getVersion(*args, **kwargs)
- Version of the online available dictionary.
-
class cjklib.dictionary.install.EDICTDownloader(downloadFunc=None, quiet=True)
Bases: cjklib.dictionary.install.DownloaderBase
Downloader for the EDICT dictionary.
-
download(**options)
Downloads the dictionary and returns the path to the local file.
Parameters: |
- options – extra options
- targetName – target file name for downloaded file
- targetPath – target directory for downloaded file, file name
will be used as provided online
- temporary – if True a temporary file will be created
retaining the last extension (i.e. for .tar.gz only .gz will be
guaranteed.
|
Return type: | str
|
Returns: | path to local file
|
-
getDownloadLink()
-
getVersion(*args, **kwargs)
- Version of the online available dictionary.
-
class cjklib.dictionary.install.HanDeDictDownloader(downloadFunc=None, quiet=True)
Bases: cjklib.dictionary.install.PageDownloaderBase
Downloader for the HanDeDict dictionary.
-
download(**options)
Downloads the dictionary and returns the path to the local file.
Parameters: |
- options – extra options
- targetName – target file name for downloaded file
- targetPath – target directory for downloaded file, file name
will be used as provided online
- temporary – if True a temporary file will be created
retaining the last extension (i.e. for .tar.gz only .gz will be
guaranteed.
|
Return type: | str
|
Returns: | path to local file
|
-
getDownloadLink(*args, **kwargs)
-
getDownloadPage(*args, **kwargs)
-
getVersion(*args, **kwargs)
-
class cjklib.dictionary.install.PageDownloaderBase(downloadFunc=None, quiet=True)
Bases: cjklib.dictionary.install.DownloaderBase
Abstract class for downloading dictionaries by scraping the URL from a web
page.
-
download(**options)
Downloads the dictionary and returns the path to the local file.
Parameters: |
- options – extra options
- targetName – target file name for downloaded file
- targetPath – target directory for downloaded file, file name
will be used as provided online
- temporary – if True a temporary file will be created
retaining the last extension (i.e. for .tar.gz only .gz will be
guaranteed.
|
Return type: | str
|
Returns: | path to local file
|
-
getDownloadLink(*args, **kwargs)
-
getDownloadPage(*args, **kwargs)
-
getVersion(*args, **kwargs)