pycrossword  0.4
Pure-Python implementation of a crossword puzzle generator and editor
Public Member Functions | Public Attributes | Private Member Functions | List of all members
pycross.dbapi.HunspellDownloadTask Class Reference

A single download task to download one Hunspell dictionary from the remote repo and store it as a DIC file. More...

Inheritance diagram for pycross.dbapi.HunspellDownloadTask:

Public Member Functions

def __init__ (self, settings, dicfolder, url, lang, overwrite=True, on_stopcheck=None, id=0)
 
def get_filesize_url (self, url)
 Gets the file size (in bytes) of a given web resource by URL. More...
 
def run (self)
 Overridden worker method called when the task is started: does the download job. More...
 

Public Attributes

 signals
 HunspellDownloadSignals signals emitted by the download task More...
 
 dicfolder
 str path to the target folder where to store the downloaded DIC file More...
 
 url
 str URL of the DIC file to download (generally, https://raw.githubusercontent.com/wooorm/dictionaries/main/dictionaries/<LANG>/index.dic) More...
 
 lang
 str short name of the language, e.g. More...
 
 overwrite
 bool whether to overwrite the existing file (if any) More...
 
 id
 int unique ID of this task (in the thread pool) More...
 
 on_stopcheck
 callback callback function called periodically to check for interrupt condition More...
 
 timeout_
 int timeout for HTTP(S) requests (in milliseconds) More...
 
 proxies_
 dict HTTP(S) proxy server settings More...
 

Private Member Functions

def _delete_file (self, filepath)
 Deletes a locally stored file (without raising errors on failure). More...
 

Detailed Description

A single download task to download one Hunspell dictionary from the remote repo and store it as a DIC file.

Derived from QtCore.QRunnable so the task can be run in a thread pool concurrently with other downloads.

Constructor & Destructor Documentation

◆ __init__()

def pycross.dbapi.HunspellDownloadTask.__init__ (   self,
  settings,
  dicfolder,
  url,
  lang,
  overwrite = True,
  on_stopcheck = None,
  id = 0 
)
Parameters
settingsdict pointer to the app global settings (utils::guisettings::CWSettings::settings)
dicfolderstr path to the target folder where to store the downloaded DIC file
urlstr URL of the DIC file to download (generally, https://raw.githubusercontent.com/wooorm/dictionaries/main/dictionaries/<LANG>/index.dic)
langstr short name of the language, e.g. 'en'
overwritebool whether to overwrite the existing file (if any)
on_stopcheckcallback callback function called periodically to check for interrupt condition; takes 4 parameters:
  • id int unique ID of this task (in the thread pool)
  • url str URL of the DIC file to download
  • lang str short name of the language, e.g. 'en'
  • filepath str full path to the downloaded (target) file Must return a Boolean value: True to stop the download task, False to continue
idint unique ID of this task (in the thread pool)

Member Function Documentation

◆ _delete_file()

def pycross.dbapi.HunspellDownloadTask._delete_file (   self,
  filepath 
)
private

Deletes a locally stored file (without raising errors on failure).

Parameters
filepathstr full path of the file to delete

◆ get_filesize_url()

def pycross.dbapi.HunspellDownloadTask.get_filesize_url (   self,
  url 
)

Gets the file size (in bytes) of a given web resource by URL.

Parameters
urlstr URL of the web resource (file)
Returns
int file size in bytes (-1 on error)

◆ run()

def pycross.dbapi.HunspellDownloadTask.run (   self)

Overridden worker method called when the task is started: does the download job.

Member Data Documentation

◆ dicfolder

pycross.dbapi.HunspellDownloadTask.dicfolder

str path to the target folder where to store the downloaded DIC file

◆ id

pycross.dbapi.HunspellDownloadTask.id

int unique ID of this task (in the thread pool)

◆ lang

pycross.dbapi.HunspellDownloadTask.lang

str short name of the language, e.g.

'en'

◆ on_stopcheck

pycross.dbapi.HunspellDownloadTask.on_stopcheck

callback callback function called periodically to check for interrupt condition

◆ overwrite

pycross.dbapi.HunspellDownloadTask.overwrite

bool whether to overwrite the existing file (if any)

◆ proxies_

pycross.dbapi.HunspellDownloadTask.proxies_

dict HTTP(S) proxy server settings

◆ signals

pycross.dbapi.HunspellDownloadTask.signals

HunspellDownloadSignals signals emitted by the download task

◆ timeout_

pycross.dbapi.HunspellDownloadTask.timeout_

int timeout for HTTP(S) requests (in milliseconds)

◆ url

pycross.dbapi.HunspellDownloadTask.url

str URL of the DIC file to download (generally, https://raw.githubusercontent.com/wooorm/dictionaries/main/dictionaries/<LANG>/index.dic)


The documentation for this class was generated from the following file: