pycrossword  0.4
Pure-Python implementation of a crossword puzzle generator and editor
Functions | Variables
pycross.utils.globalvars Namespace Reference

Functions

def make_abspath (filename, root='')
 Returns the absolute path for a relative one, for a given root directory. More...
 
def readSettings (settings_file=None, write_defaults_on_error=True)
 Loads the app settings from a settings file. More...
 
def switch_lang (lang='')
 Changes the app interface language by installing the specified translation. More...
 

Variables

bool DEBUGGING = False
 toggle debug message printing More...
 
string APP_VERSION = '0.4.0.1'
 current app version More...
 
string APP_NAME = 'pycrossword'
 app name More...
 
string GIT_REPO = 'https://github.com/S0mbre/crossword.git'
 git repo hosting this app More...
 
string APP_AUTHOR = 'Iskander Shafikov (S0mbre)'
 app author More...
 
string APP_EMAIL = 's00mbre@gmail.com'
 author's email More...
 
string ENCODING = 'utf-8'
 default encoding (for file I/O mostly) More...
 
def SETTINGS_FILE = make_abspath('settings.pxjson')
 path to the current app settings More...
 
def DEFAULT_SETTINGS_FILE = make_abspath('defsettings.pxjson')
 path to the default app settings More...
 
def UPDATE_FILE = make_abspath('update.json')
 path to the Update file that stores info on the available update and last update date More...
 
def SAVEDCW_FILE = make_abspath('autosaved.xpf')
 path to the auto-saved crossword file (in XPF format) More...
 
def DICFOLDER = make_abspath('assets/dic')
 path to the 'dic' folder containing word sources More...
 
def ICONFOLDER = make_abspath('assets/icons')
 path to the icons folder containing GUI icon resources More...
 
def PLUGINS_FOLDER = make_abspath('plugins')
 path to the plugins folder containing user plugins More...
 
dictionary LANG = {'en': 'English', 'ru': 'Russian', 'fr': 'French', 'es': 'Spanish', 'de': 'German', 'it': 'Italian'}
 app interface languages in brief and full notation More...
 
list POS
 parts of speech in brief and full notation More...
 
string BRACES = "{}"
 braces More...
 
dictionary SQL_TABLES
 default SQLite DB table names for word sources More...
 
int MAX_RESULTS = 500
 default max results for word source searches More...
 
string PLUGIN_EXTENSION = 'pxplugin'
 user plugin file extension More...
 
string PLUGIN_TEMPLATE_GENERAL
 user plugin template (for the 'general' category) More...
 
list APP_LANGUAGES
 app interface languages More...
 
string NEWLINE = '\n'
 newline character More...
 
 ENCODINGS = \
 string encodings More...
 
dictionary FONT_WEIGHTS = {100: 0, 200: 12, 300: 25, 400: 50, 500: 57, 600: 63, 700: 75, 800: 81, 900: 87}
 CSS-to-Qt font weight conversion table. More...
 
string LINUX_APP_PATH = '~/.local/share/applications/{}.desktop'.format(APP_NAME.lower())
 app path in Linux OS More...
 
 LINUX_MIME_APP = \
 Linux MIME info for app (used for file associations) More...
 
 LINUX_MIME_TYPES = \
 Linux MIME type description (used for file associations) More...
 
string LINUX_MIME_XML = f'~/.local/share/applications/{APP_NAME.lower()}-{APP_NAME.lower()}.xml'
 Linux MIME XML file path (used for file associations) More...
 
string MW_DIC_KEY = '71ae1f74-7edb-4683-be03-8e3d7348660d'
 MW Collegiate Dictionary & Audio API key. More...
 
string MW_DIC_HTTP = 'https://www.dictionaryapi.com/api/v3/references/collegiate/json/{}?key={}'
 MW Collegiate Dictionary API URL. More...
 
int MW_DAILY_REQ = 1000
 MW Collegiate Dictionary daily request limit, see https://www.dictionaryapi.com/. More...
 
string MW_WORD_URL = 'https://www.merriam-webster.com/dictionary/{}'
 MW Collegiate Dictionary URL. More...
 
string YAN_DICT_KEY = 'dict.1.1.20191120T032741Z.d541dffb1a55247b.b090f62ccd320c7e33f8d88eefde8c8e1ea0ba5b'
 Yandex dictionary API key. More...
 
string YAN_DICT_HTTP = 'https://dictionary.yandex.net/api/v1/dicservice.json/lookup?key={}&text={}&lang={}&ui=en'
 Yandex dictionary API URL. More...
 
int YAN_DAILY_REQ = 10000
 Yandex dictionary daily request limit. More...
 
string GOOGLE_KEY = 'AIzaSyAcc_B34Mv7Z4UoVuAMYCEiA9n14_SuEjU'
 Google Search JSON API key. More...
 
string GOOGLE_CSE = '012413034625838642915:je3epsydo2r'
 Google CSE identifier. More...
 
string GOOGLE_HTTP = 'https://www.googleapis.com/customsearch/v1?key={}&cx={}&prettyPrint=true&q={}'
 Google API URL. More...
 
int GOOGLE_DAILY_REQ = 100
 Google daily limit, see https://developers.google.com/custom-search/v1/overview. More...
 
dictionary GOOGLE_LANG_LR
 Google document languages. More...
 
dictionary GOOGLE_LANG_HL
 Google interface languages. More...
 
dictionary GOOGLE_COUNTRIES_CR
 Google document countries. More...
 
dictionary GOOGLE_COUNTRIES_GL
 Google user search countries. More...
 
bool LANGAPPLIED = False
 flag that is set to True when the inerface language has been applied More...
 

Function Documentation

◆ make_abspath()

def pycross.utils.globalvars.make_abspath (   filename,
  root = '' 
)

Returns the absolute path for a relative one, for a given root directory.

Parameters
filenamestr relative path, e.g. '../setup.py'
rootstr root directory full path to calculate the abs path; if empty (default), the 'pycross' directory in the installation dir will be used.
Returns
str absolute path for filename

◆ readSettings()

def pycross.utils.globalvars.readSettings (   settings_file = None,
  write_defaults_on_error = True 
)

Loads the app settings from a settings file.

Checks if 'settings.pxjson' exists in the root directory. If not, creates it with the default settings; otherwise, reads 'settings.pxjson' to the global pycross::guisettings::CWSettings::settings object.

Parameters
settings_filestr path to the settings file ('*.pxjson'). If left None, SETTINGS_FILE is used.
write_defaults_on_errorbool whether to save the default settings into the settings file on load error (default = True)
Returns
dict pointer to global app settings pycross::guisettings::CWSettings::settings

◆ switch_lang()

def pycross.utils.globalvars.switch_lang (   lang = '')

Changes the app interface language by installing the specified translation.

It installs the global _() function used by gettext to get localized strings.

Parameters
langstr short language name – see APP_LANGUAGES

Variable Documentation

◆ APP_AUTHOR

string pycross.utils.globalvars.APP_AUTHOR = 'Iskander Shafikov (S0mbre)'

app author

◆ APP_EMAIL

string pycross.utils.globalvars.APP_EMAIL = 's00mbre@gmail.com'

author's email

◆ APP_LANGUAGES

list pycross.utils.globalvars.APP_LANGUAGES
Initial value:
1 = [('English (US)', '', '', 'united-states-of-america.png', "The application must be restarted to apply new language settings. Restart now?"),
2  ('Russian', 'ru', 'Русский', 'russia.png', "Приложение должно быть перезапущено для применения новых настроек языка. Перезапустить сейчас?"),
3  ('German', 'de', 'Deutsch', 'germany.png', "Die Anwendung muss neu gestartet werden, um neue Spracheinstellungen zu übernehmen. Jetzt neu starten?"),
4  ('French', 'fr', 'Français', 'france.png', "L'application doit être redémarrée pour appliquer de nouveaux paramètres de langue. Redémarrer maintenant?"),
5  ('Italian', 'it', 'Italiano', 'italy.png', "È necessario riavviare l'applicazione per applicare le nuove impostazioni della lingua. Riavvia ora?"),
6  ('Spanish', 'es', 'Español', 'spain.png', "La aplicación debe reiniciarse para aplicar la nueva configuración de idioma. ¿Reiniciar ahora?")]

app interface languages

◆ APP_NAME

string pycross.utils.globalvars.APP_NAME = 'pycrossword'

app name

Warning
This constant is used by setup.py to generate version-specific Python distributions; so it must be checked and modified regularly!

◆ APP_VERSION

string pycross.utils.globalvars.APP_VERSION = '0.4.0.1'

current app version

Warning
This constant is used by setup.py to generate version-specific Python distributions; so it must be checked and modified regularly!

◆ BRACES

string pycross.utils.globalvars.BRACES = "{}"

braces

◆ DEBUGGING

bool pycross.utils.globalvars.DEBUGGING = False

toggle debug message printing

◆ DEFAULT_SETTINGS_FILE

def pycross.utils.globalvars.DEFAULT_SETTINGS_FILE = make_abspath('defsettings.pxjson')

path to the default app settings

◆ DICFOLDER

def pycross.utils.globalvars.DICFOLDER = make_abspath('assets/dic')

path to the 'dic' folder containing word sources

◆ ENCODING

string pycross.utils.globalvars.ENCODING = 'utf-8'

default encoding (for file I/O mostly)

◆ ENCODINGS

pycross.utils.globalvars.ENCODINGS = \

string encodings

◆ FONT_WEIGHTS

dictionary pycross.utils.globalvars.FONT_WEIGHTS = {100: 0, 200: 12, 300: 25, 400: 50, 500: 57, 600: 63, 700: 75, 800: 81, 900: 87}

CSS-to-Qt font weight conversion table.

◆ GIT_REPO

string pycross.utils.globalvars.GIT_REPO = 'https://github.com/S0mbre/crossword.git'

git repo hosting this app

◆ GOOGLE_COUNTRIES_CR

dictionary pycross.utils.globalvars.GOOGLE_COUNTRIES_CR

Google document countries.

◆ GOOGLE_COUNTRIES_GL

dictionary pycross.utils.globalvars.GOOGLE_COUNTRIES_GL

Google user search countries.

◆ GOOGLE_CSE

string pycross.utils.globalvars.GOOGLE_CSE = '012413034625838642915:je3epsydo2r'

Google CSE identifier.

◆ GOOGLE_DAILY_REQ

int pycross.utils.globalvars.GOOGLE_DAILY_REQ = 100

◆ GOOGLE_HTTP

string pycross.utils.globalvars.GOOGLE_HTTP = 'https://www.googleapis.com/customsearch/v1?key={}&cx={}&prettyPrint=true&q={}'

Google API URL.

◆ GOOGLE_KEY

string pycross.utils.globalvars.GOOGLE_KEY = 'AIzaSyAcc_B34Mv7Z4UoVuAMYCEiA9n14_SuEjU'

Google Search JSON API key.

◆ GOOGLE_LANG_HL

dictionary pycross.utils.globalvars.GOOGLE_LANG_HL
Initial value:
1 = {'af': 'Afrikaans', 'sq': 'Albanian', 'sm': 'Amharic', 'ar': 'Arabic', 'az': 'Azerbaijani', 'eu': 'Basque',
2  'be': 'Belarusian', 'bn': 'Bengali', 'bh': 'Bihari', 'bs': 'Bosnian', 'bg': 'Bulgarian',
3  'ca': 'Catalan', 'zh-CN': 'Chinese (Simplified)', 'zh-TW': 'Chinese (Traditional)',
4  'hr': 'Croatian', 'cs': 'Czech', 'da': 'Danish', 'nl': 'Dutch', 'en': 'English', 'eo': 'Esperanto',
5  'et': 'Estonian', 'fo': 'Faroese', 'fi': 'Finnish', 'fr': 'French', 'fy': 'Frisian', 'gl': 'Galician',
6  'ka': 'Georgian', 'de': 'German', 'el': 'Greek', 'gu': 'Gujarati', 'iw': 'Hebrew', 'hi': 'Hindi',
7  'hu': 'Hungarian', 'is': 'Icelandic', 'id': 'Indonesian', 'ia': 'Interlingua', 'ga': 'Irish', 'it': 'Italian',
8  'ja': 'Japanese', 'jw': 'Javanese', 'kn': 'Kannada', 'ko': 'Korean', 'la': 'Latin', 'lv': 'Latvian',
9  'lt': 'Lithuanian', 'mk': 'Macedonian', 'ms': 'Malay', 'ml': 'Malayam', 'mt': 'Maltese', 'mr': 'Marathi',
10  'ne': 'Nepali', 'no': 'Norwegian', 'nn': 'Norwegian (Nynorsk)', 'oc': 'Occitan', 'fa': 'Persian',
11  'pl': 'Polish', 'pt-BR': 'Portuguese (Brazil)', 'pt-PT': 'Portuguese (Portugal)', 'pa': 'Punjabi',
12  'ro': 'Romanian', 'ru': 'Russian', 'gd': 'Scots Gaelic', 'sr': 'Serbian', 'si': 'Sinhalese',
13  'sk': 'Slovak', 'sl': 'Slovenian', 'es': 'Spanish', 'su': 'Sudanese', 'sw': 'Swahili', 'sv': 'Swedish',
14  'tl': 'Tagalog', 'ta': 'Tamil', 'te': 'Telugu', 'th': 'Thai', 'ti': 'Tigrinya', 'tr': 'Turkish',
15  'uk': 'Ukrainian', 'ur': 'Urdu', 'uz': 'Uzbek', 'vi': 'Vietnamese', 'cy': 'Welsh', 'xh': 'Xhosa', 'zu': 'Zulu'}

Google interface languages.

◆ GOOGLE_LANG_LR

dictionary pycross.utils.globalvars.GOOGLE_LANG_LR
Initial value:
1 = {'lang_ar': 'Arabic', 'lang_bg': 'Bulgarian', 'lang_ca': 'Catalan', 'lang_cs': 'Czech',
2  'lang_da': 'Danish', 'lang_de': 'German', 'lang_el': 'Greek', 'lang_en': 'English',
3  'lang_es': 'Spanish', 'lang_et': 'Estonian', 'lang_fi': 'Finnish', 'lang_fr': 'French',
4  'lang_hr': 'Croatian', 'lang_hu': 'Hungarian', 'lang_id': 'Indonesian', 'lang_is': 'Icelandic',
5  'lang_it': 'Italian', 'lang_iw': 'Hebrew', 'lang_ja': 'Japanese', 'lang_ko': 'Korean',
6  'lang_lt': 'Lithuanian', 'lang_lv': 'Latvian', 'lang_nl': 'Dutch', 'lang_no': 'Norwegian',
7  'lang_pl': 'Polish', 'lang_pt': 'Portuguese', 'lang_ro': 'Romanian', 'lang_ru': 'Russian',
8  'lang_sk': 'Slovak', 'lang_sl': 'Slovenian', 'lang_sr': 'Serbian', 'lang_sv': 'Swedish',
9  'lang_tr': 'Turkish', 'lang_zh-CN': 'Chinese (Simplified)', 'lang_zh-TW': 'Chinese (Traditional)'}

Google document languages.

◆ ICONFOLDER

def pycross.utils.globalvars.ICONFOLDER = make_abspath('assets/icons')

path to the icons folder containing GUI icon resources

◆ LANG

dictionary pycross.utils.globalvars.LANG = {'en': 'English', 'ru': 'Russian', 'fr': 'French', 'es': 'Spanish', 'de': 'German', 'it': 'Italian'}

app interface languages in brief and full notation

◆ LANGAPPLIED

bool pycross.utils.globalvars.LANGAPPLIED = False

flag that is set to True when the inerface language has been applied

◆ LINUX_APP_PATH

string pycross.utils.globalvars.LINUX_APP_PATH = '~/.local/share/applications/{}.desktop'.format(APP_NAME.lower())

app path in Linux OS

◆ LINUX_MIME_APP

pycross.utils.globalvars.LINUX_MIME_APP = \

Linux MIME info for app (used for file associations)

◆ LINUX_MIME_TYPES

pycross.utils.globalvars.LINUX_MIME_TYPES = \

Linux MIME type description (used for file associations)

◆ LINUX_MIME_XML

string pycross.utils.globalvars.LINUX_MIME_XML = f'~/.local/share/applications/{APP_NAME.lower()}-{APP_NAME.lower()}.xml'

Linux MIME XML file path (used for file associations)

◆ MAX_RESULTS

int pycross.utils.globalvars.MAX_RESULTS = 500

default max results for word source searches

◆ MW_DAILY_REQ

int pycross.utils.globalvars.MW_DAILY_REQ = 1000

MW Collegiate Dictionary daily request limit, see https://www.dictionaryapi.com/.

◆ MW_DIC_HTTP

string pycross.utils.globalvars.MW_DIC_HTTP = 'https://www.dictionaryapi.com/api/v3/references/collegiate/json/{}?key={}'

MW Collegiate Dictionary API URL.

◆ MW_DIC_KEY

string pycross.utils.globalvars.MW_DIC_KEY = '71ae1f74-7edb-4683-be03-8e3d7348660d'

MW Collegiate Dictionary & Audio API key.

◆ MW_WORD_URL

string pycross.utils.globalvars.MW_WORD_URL = 'https://www.merriam-webster.com/dictionary/{}'

MW Collegiate Dictionary URL.

◆ NEWLINE

string pycross.utils.globalvars.NEWLINE = '\n'

newline character

◆ PLUGIN_EXTENSION

string pycross.utils.globalvars.PLUGIN_EXTENSION = 'pxplugin'

user plugin file extension

◆ PLUGIN_TEMPLATE_GENERAL

string pycross.utils.globalvars.PLUGIN_TEMPLATE_GENERAL
Initial value:
1 = """\
2 from utils.pluginbase import *
3 
4 class Px{}(PxPluginGeneral):
5 
6  # >>> add code here <<<
7  pass
8 """

user plugin template (for the 'general' category)

◆ PLUGINS_FOLDER

def pycross.utils.globalvars.PLUGINS_FOLDER = make_abspath('plugins')

path to the plugins folder containing user plugins

◆ POS

list pycross.utils.globalvars.POS
Initial value:
1 = [('N', 'noun'), ('V', 'verb'), ('ADV', 'adverb'), ('ADJ', 'adjective'), ('P', 'participle'),
2  ('PRON', 'pronoun'), ('I', 'interjection'), ('C', 'conjuction'), ('PREP', 'preposition'),
3  ('PROP', 'proposition'), ('MISC', 'miscellaneous / other'), ('NONE', 'no POS')]

parts of speech in brief and full notation

◆ SAVEDCW_FILE

def pycross.utils.globalvars.SAVEDCW_FILE = make_abspath('autosaved.xpf')

path to the auto-saved crossword file (in XPF format)

◆ SETTINGS_FILE

def pycross.utils.globalvars.SETTINGS_FILE = make_abspath('settings.pxjson')

path to the current app settings

◆ SQL_TABLES

dictionary pycross.utils.globalvars.SQL_TABLES
Initial value:
1 = {'words': {'table': 'twords', 'fid': 'id', 'fwords': 'word', 'fpos': 'idpos'},
2  'pos': {'table': 'tpos', 'fid': 'id', 'fpos': 'pos', 'fposdesc': 'posdesc'} }

default SQLite DB table names for word sources

◆ UPDATE_FILE

def pycross.utils.globalvars.UPDATE_FILE = make_abspath('update.json')

path to the Update file that stores info on the available update and last update date

◆ YAN_DAILY_REQ

int pycross.utils.globalvars.YAN_DAILY_REQ = 10000

Yandex dictionary daily request limit.

◆ YAN_DICT_HTTP

string pycross.utils.globalvars.YAN_DICT_HTTP = 'https://dictionary.yandex.net/api/v1/dicservice.json/lookup?key={}&text={}&lang={}&ui=en'

Yandex dictionary API URL.

◆ YAN_DICT_KEY

string pycross.utils.globalvars.YAN_DICT_KEY = 'dict.1.1.20191120T032741Z.d541dffb1a55247b.b090f62ccd320c7e33f8d88eefde8c8e1ea0ba5b'

Yandex dictionary API key.