diff --git a/nw/constants/__init__.py b/nw/constants/__init__.py new file mode 100644 index 00000000..27c14997 --- /dev/null +++ b/nw/constants/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from nw.constants.iso import isoLanguage, isoCountry +from nw.constants.constants import ( + nwConst, nwFiles, nwKeyWords, nwLabels, nwDependencies, nwQuotes, nwUnicode +) +from nw.constants.enum import ( + nwAlert, nwDocAction, nwItemClass, nwItemLayout, nwItemType +) + +__all__ = [ + "isoLanguage", + "isoCountry", + "nwConst", + "nwFiles", + "nwKeyWords", + "nwLabels", + "nwDependencies", + "nwQuotes", + "nwUnicode", + "nwAlert", + "nwDocAction", + "nwItemClass", + "nwItemLayout", + "nwItemType", +] \ No newline at end of file diff --git a/nw/constants.py b/nw/constants/constants.py similarity index 98% rename from nw/constants.py rename to nw/constants/constants.py index 7919ba8c..a0325482 100644 --- a/nw/constants.py +++ b/nw/constants/constants.py @@ -10,7 +10,7 @@ """ -from nw.enum import nwItemClass, nwItemLayout +from nw.constants.enum import nwItemClass, nwItemLayout class nwConst(): @@ -128,10 +128,6 @@ class nwDependencies(): "site" : "", "docs" : "", }, - "pycountry" : { - "site" : "", - "docs" : "", - }, "latexcodec" : { "site" : "https://pypi.org/project/latexcodec/", "docs" : "https://latexcodec.readthedocs.io/en/latest/", diff --git a/nw/enum.py b/nw/constants/enum.py similarity index 100% rename from nw/enum.py rename to nw/constants/enum.py diff --git a/nw/constants/iso.py b/nw/constants/iso.py new file mode 100644 index 00000000..1d4ee769 --- /dev/null +++ b/nw/constants/iso.py @@ -0,0 +1,462 @@ +# -*- coding: utf-8 -*- +"""novelWriter Language Codes + + novelWriter – Language Codes +============================== + Handles translating language codes to language names + + File History: + Created: 2019-11-05 [0.4.0] + +""" + +import logging + +logger = logging.getLogger(__name__) + +class isoLanguage(): + + ISO_639_1 = { + "aa" : "Afar", + "ab" : "Abkhazian", + "ae" : "Avestan", + "af" : "Afrikaans", + "ak" : "Akan", + "am" : "Amharic", + "an" : "Aragonese", + "ar" : "Arabic", + "as" : "Assamese", + "av" : "Avaric", + "ay" : "Aymara", + "az" : "Azerbaijani", + "ba" : "Bashkir", + "be" : "Belarusian", + "bg" : "Bulgarian", + "bh" : "Bihari languages", + "bi" : "Bislama", + "bm" : "Bambara", + "bn" : "Bengali", + "bo" : "Tibetan", + "br" : "Breton", + "bs" : "Bosnian", + "ca" : "Catalan", + "ce" : "Chechen", + "ch" : "Chamorro", + "co" : "Corsican", + "cr" : "Cree", + "cs" : "Czech", + "cu" : "Church Slavic", + "cv" : "Chuvash", + "cy" : "Welsh", + "da" : "Danish", + "de" : "German", + "dv" : "Divehi", + "dz" : "Dzongkha", + "ee" : "Ewe", + "el" : "Modern Greek", + "en" : "English", + "eo" : "Esperanto", + "es" : "Spanish", + "et" : "Estonian", + "eu" : "Basque", + "fa" : "Persian", + "ff" : "Fulah", + "fi" : "Finnish", + "fj" : "Fijian", + "fo" : "Faroese", + "fr" : "French", + "fy" : "Western Frisian", + "ga" : "Irish", + "gd" : "Gaelic", + "gl" : "Galician", + "gn" : "Guarani", + "gu" : "Gujarati", + "gv" : "Manx", + "ha" : "Hausa", + "he" : "Hebrew", + "hi" : "Hindi", + "ho" : "Hiri Motu", + "hr" : "Croatian", + "ht" : "Haitian", + "hu" : "Hungarian", + "hy" : "Armenian", + "hz" : "Herero", + "ia" : "Interlingua", + "id" : "Indonesian", + "ie" : "Interlingue", + "ig" : "Igbo", + "ii" : "Sichuan Yi", + "ik" : "Inupiaq", + "io" : "Ido", + "is" : "Icelandic", + "it" : "Italian", + "iu" : "Inuktitut", + "ja" : "Japanese", + "jv" : "Javanese", + "ka" : "Georgian", + "kg" : "Kongo", + "ki" : "Kikuyu", + "kj" : "Kuanyama", + "kk" : "Kazakh", + "kl" : "Kalaallisut", + "km" : "Central Khmer", + "kn" : "Kannada", + "ko" : "Korean", + "kr" : "Kanuri", + "ks" : "Kashmiri", + "ku" : "Kurdish", + "kv" : "Komi", + "kw" : "Cornish", + "ky" : "Kirghiz", + "la" : "Latin", + "lb" : "Luxembourgish", + "lg" : "Ganda", + "li" : "Limburgan", + "ln" : "Lingala", + "lo" : "Lao", + "lt" : "Lithuanian", + "lu" : "Luba-Katanga", + "lv" : "Latvian", + "mg" : "Malagasy", + "mh" : "Marshallese", + "mi" : "Maori", + "mk" : "Macedonian", + "ml" : "Malayalam", + "mn" : "Mongolian", + "mr" : "Marathi", + "ms" : "Malay", + "mt" : "Maltese", + "my" : "Burmese", + "na" : "Nauru", + "nb" : "Norwegian Bokmål", + "nd" : "North Ndebele", + "ne" : "Nepali", + "ng" : "Ndonga", + "nl" : "Dutch", + "nn" : "Norwegian Nynorsk", + "no" : "Norwegian", + "nr" : "South Ndebele", + "nv" : "Navajo", + "ny" : "Chichewa", + "oc" : "Occitan", + "oj" : "Ojibwa", + "om" : "Oromo", + "or" : "Oriya", + "os" : "Ossetian", + "pa" : "Panjabi", + "pi" : "Pali", + "pl" : "Polish", + "ps" : "Pushto", + "pt" : "Portuguese", + "qu" : "Quechua", + "rm" : "Romansh", + "rn" : "Rundi", + "ro" : "Romanian", + "ru" : "Russian", + "rw" : "Kinyarwanda", + "sa" : "Sanskrit", + "sc" : "Sardinian", + "sd" : "Sindhi", + "se" : "Northern Sami", + "sg" : "Sango", + "si" : "Sinhala", + "sk" : "Slovak", + "sl" : "Slovenian", + "sm" : "Samoan", + "sn" : "Shona", + "so" : "Somali", + "sq" : "Albanian", + "sr" : "Serbian", + "ss" : "Swati", + "st" : "Southern Sotho", + "su" : "Sundanese", + "sv" : "Swedish", + "sw" : "Swahili", + "ta" : "Tamil", + "te" : "Telugu", + "tg" : "Tajik", + "th" : "Thai", + "ti" : "Tigrinya", + "tk" : "Turkmen", + "tl" : "Tagalog", + "tn" : "Tswana", + "to" : "Tonga", + "tr" : "Turkish", + "ts" : "Tsonga", + "tt" : "Tatar", + "tw" : "Twi", + "ty" : "Tahitian", + "ug" : "Uighur", + "uk" : "Ukrainian", + "ur" : "Urdu", + "uz" : "Uzbek", + "ve" : "Venda", + "vi" : "Vietnamese", + "vo" : "Volapük", + "wa" : "Walloon", + "wo" : "Wolof", + "xh" : "Xhosa", + "yi" : "Yiddish", + "yo" : "Yoruba", + "za" : "Zhuang", + "zh" : "Chinese", + "zu" : "Zulu", + } + +# END Class isoLanguage + +class isoCountry(): + + ISO_3166_1_alpha_2 = { + "AD" : "Andorra", + "AE" : "United Arab Emirates", + "AF" : "Afghanistan", + "AG" : "Antigua and Barbuda", + "AI" : "Anguilla", + "AL" : "Albania", + "AM" : "Armenia", + "AO" : "Angola", + "AQ" : "Antarctica", + "AR" : "Argentina", + "AS" : "American Samoa", + "AT" : "Austria", + "AU" : "Australia", + "AW" : "Aruba", + "AX" : "Åland Islands", + "AZ" : "Azerbaijan", + "BA" : "Bosnia and Herzegovina", + "BB" : "Barbados", + "BD" : "Bangladesh", + "BE" : "Belgium", + "BF" : "Burkina Faso", + "BG" : "Bulgaria", + "BH" : "Bahrain", + "BI" : "Burundi", + "BJ" : "Benin", + "BL" : "Saint Barthélemy", + "BM" : "Bermuda", + "BN" : "Brunei Darussalam", + "BO" : "Plurinational State of Bolivia", + "BQ" : "Sint Eustatius and Saba Bonaire", + "BR" : "Brazil", + "BS" : "Bahamas", + "BT" : "Bhutan", + "BV" : "Bouvet Island", + "BW" : "Botswana", + "BY" : "Belarus", + "BZ" : "Belize", + "CA" : "Canada", + "CC" : "Cocos (Keeling) Islands", + "CD" : "The Democratic Republic of the Congo", + "CF" : "Central African Republic", + "CG" : "Congo", + "CH" : "Switzerland", + "CI" : "Côte d'Ivoire", + "CK" : "Cook Islands", + "CL" : "Chile", + "CM" : "Cameroon", + "CN" : "China", + "CO" : "Colombia", + "CR" : "Costa Rica", + "CU" : "Cuba", + "CV" : "Cape Verde", + "CW" : "Curaçao", + "CX" : "Christmas Island", + "CY" : "Cyprus", + "CZ" : "Czech Republic", + "DE" : "Germany", + "DJ" : "Djibouti", + "DK" : "Denmark", + "DM" : "Dominica", + "DO" : "Dominican Republic", + "DZ" : "Algeria", + "EC" : "Ecuador", + "EE" : "Estonia", + "EG" : "Egypt", + "EH" : "Western Sahara", + "ER" : "Eritrea", + "ES" : "Spain", + "ET" : "Ethiopia", + "FI" : "Finland", + "FJ" : "Fiji", + "FK" : "Falkland Islands (Malvinas)", + "FM" : "Federated States of Micronesia", + "FO" : "Faroe Islands", + "FR" : "France", + "GA" : "Gabon", + "GB" : "United Kingdom", + "GD" : "Grenada", + "GE" : "Georgia", + "GF" : "French Guiana", + "GG" : "Guernsey", + "GH" : "Ghana", + "GI" : "Gibraltar", + "GL" : "Greenland", + "GM" : "Gambia", + "GN" : "Guinea", + "GP" : "Guadeloupe", + "GQ" : "Equatorial Guinea", + "GR" : "Greece", + "GS" : "South Georgia and the South Sandwich Islands", + "GT" : "Guatemala", + "GU" : "Guam", + "GW" : "Guinea-Bissau", + "GY" : "Guyana", + "HK" : "Hong Kong", + "HM" : "Heard Island and McDonald Islands", + "HN" : "Honduras", + "HR" : "Croatia", + "HT" : "Haiti", + "HU" : "Hungary", + "ID" : "Indonesia", + "IE" : "Ireland", + "IL" : "Israel", + "IM" : "Isle of Man", + "IN" : "India", + "IO" : "British Indian Ocean Territory", + "IQ" : "Iraq", + "IR" : "Islamic Republic of Iran", + "IS" : "Iceland", + "IT" : "Italy", + "JE" : "Jersey", + "JM" : "Jamaica", + "JO" : "Jordan", + "JP" : "Japan", + "KE" : "Kenya", + "KG" : "Kyrgyzstan", + "KH" : "Cambodia", + "KI" : "Kiribati", + "KM" : "Comoros", + "KN" : "Saint Kitts and Nevis", + "KP" : "Democratic People's Republic of Korea", + "KR" : "Republic of Korea", + "KW" : "Kuwait", + "KY" : "Cayman Islands", + "KZ" : "Kazakhstan", + "LA" : "Lao People's Democratic Republic", + "LB" : "Lebanon", + "LC" : "Saint Lucia", + "LI" : "Liechtenstein", + "LK" : "Sri Lanka", + "LR" : "Liberia", + "LS" : "Lesotho", + "LT" : "Lithuania", + "LU" : "Luxembourg", + "LV" : "Latvia", + "LY" : "Libya", + "MA" : "Morocco", + "MC" : "Monaco", + "MD" : "Republic of Moldova", + "ME" : "Montenegro", + "MF" : "Saint Martin (French part)", + "MG" : "Madagascar", + "MH" : "Marshall Islands", + "MK" : "The Former Yugoslav Republic of Macedonia", + "ML" : "Mali", + "MM" : "Myanmar", + "MN" : "Mongolia", + "MO" : "Macao", + "MP" : "Northern Mariana Islands", + "MQ" : "Martinique", + "MR" : "Mauritania", + "MS" : "Montserrat", + "MT" : "Malta", + "MU" : "Mauritius", + "MV" : "Maldives", + "MW" : "Malawi", + "MX" : "Mexico", + "MY" : "Malaysia", + "MZ" : "Mozambique", + "NA" : "Namibia", + "NC" : "New Caledonia", + "NE" : "Niger", + "NF" : "Norfolk Island", + "NG" : "Nigeria", + "NI" : "Nicaragua", + "NL" : "Netherlands", + "NO" : "Norway", + "NP" : "Nepal", + "NR" : "Nauru", + "NU" : "Niue", + "NZ" : "New Zealand", + "OM" : "Oman", + "PA" : "Panama", + "PE" : "Peru", + "PF" : "French Polynesia", + "PG" : "Papua New Guinea", + "PH" : "Philippines", + "PK" : "Pakistan", + "PL" : "Poland", + "PM" : "Saint Pierre and Miquelon", + "PN" : "Pitcairn", + "PR" : "Puerto Rico", + "PS" : "State of Palestine", + "PT" : "Portugal", + "PW" : "Palau", + "PY" : "Paraguay", + "QA" : "Qatar", + "RE" : "Réunion", + "RO" : "Romania", + "RS" : "Serbia", + "RU" : "Russian Federation", + "RW" : "Rwanda", + "SA" : "Saudi Arabia", + "SB" : "Solomon Islands", + "SC" : "Seychelles", + "SD" : "Sudan", + "SE" : "Sweden", + "SG" : "Singapore", + "SH" : "Saint Helena, Ascension and Tristan da Cunha", + "SI" : "Slovenia", + "SJ" : "Svalbard and Jan Mayen", + "SK" : "Slovakia", + "SL" : "Sierra Leone", + "SM" : "San Marino", + "SN" : "Senegal", + "SO" : "Somalia", + "SR" : "Suriname", + "SS" : "South Sudan", + "ST" : "Sao Tome and Principe", + "SV" : "El Salvador", + "SX" : "Sint Maarten", + "SY" : "Syrian Arab Republic", + "SZ" : "Swaziland", + "TC" : "Turks and Caicos Islands", + "TD" : "Chad", + "TF" : "French Southern Territories", + "TG" : "Togo", + "TH" : "Thailand", + "TJ" : "Tajikistan", + "TK" : "Tokelau", + "TL" : "Timor-Leste", + "TM" : "Turkmenistan", + "TN" : "Tunisia", + "TO" : "Tonga", + "TR" : "Turkey", + "TT" : "Trinidad and Tobago", + "TV" : "Tuvalu", + "TW" : "Taiwan, Province of China", + "TZ" : "United Republic of Tanzania", + "UA" : "Ukraine", + "UG" : "Uganda", + "UM" : "United States Minor Outlying Islands", + "US" : "United States", + "UY" : "Uruguay", + "UZ" : "Uzbekistan", + "VA" : "Holy See (Vatican City State)", + "VC" : "Saint Vincent and the Grenadines", + "VE" : "Bolivarian Republic of Venezuela", + "VG" : "British Virgin Islands", + "VI" : "U.S. Virgin Islands", + "VN" : "Viet Nam", + "VU" : "Vanuatu", + "WF" : "Wallis and Futuna", + "WS" : "Samoa", + "YE" : "Yemen", + "YT" : "Mayotte", + "ZA" : "South Africa", + "ZM" : "Zambia", + "ZW" : "Zimbabwe", + } + +# END Class isoCountry diff --git a/nw/convert/__init__.py b/nw/convert/__init__.py index 43416a65..ea50119a 100644 --- a/nw/convert/__init__.py +++ b/nw/convert/__init__.py @@ -14,14 +14,14 @@ from nw.convert.text.tomarkdown import ToMarkdown from nw.convert.text.totext import ToText __all__ = [ - Tokenizer, - ConcatFile, - HtmlFile, - LaTeXFile, - MarkdownFile, - TextFile, - ToHtml, - ToLaTeX, - ToMarkdown, - ToText, + "Tokenizer", + "ConcatFile", + "HtmlFile", + "LaTeXFile", + "MarkdownFile", + "TextFile", + "ToHtml", + "ToLaTeX", + "ToMarkdown", + "ToText", ] diff --git a/nw/convert/file/__init__.py b/nw/convert/file/__init__.py index ca28cc43..da2afb33 100644 --- a/nw/convert/file/__init__.py +++ b/nw/convert/file/__init__.py @@ -7,9 +7,9 @@ from nw.convert.file.markdown import MarkdownFile from nw.convert.file.text import TextFile __all__ = [ - ConcatFile, - HtmlFile, - LaTeXFile, - MarkdownFile, - TextFile, + "ConcatFile", + "HtmlFile", + "LaTeXFile", + "MarkdownFile", + "TextFile", ] diff --git a/nw/convert/file/concat.py b/nw/convert/file/concat.py index 6aedb857..f16b1f47 100644 --- a/nw/convert/file/concat.py +++ b/nw/convert/file/concat.py @@ -19,7 +19,7 @@ from PyQt5.QtWidgets import QMessageBox from nw.convert.file.text import TextFile from nw.convert.tokenizer import Tokenizer -from nw.enum import nwAlert, nwItemLayout +from nw.constants import nwAlert, nwItemLayout logger = logging.getLogger(__name__) diff --git a/nw/convert/file/html.py b/nw/convert/file/html.py index 084789d6..d7065bef 100644 --- a/nw/convert/file/html.py +++ b/nw/convert/file/html.py @@ -15,7 +15,7 @@ import nw from nw.convert.file.text import TextFile from nw.convert.text.tohtml import ToHtml -from nw.enum import nwAlert +from nw.constants import nwAlert logger = logging.getLogger(__name__) diff --git a/nw/convert/file/latex.py b/nw/convert/file/latex.py index 6a8617fd..70f378ed 100644 --- a/nw/convert/file/latex.py +++ b/nw/convert/file/latex.py @@ -15,7 +15,7 @@ import nw from nw.convert.file.text import TextFile from nw.convert.text.tolatex import ToLaTeX -from nw.enum import nwAlert +from nw.constants import nwAlert logger = logging.getLogger(__name__) diff --git a/nw/convert/file/markdown.py b/nw/convert/file/markdown.py index fc96ac4f..253a46f4 100644 --- a/nw/convert/file/markdown.py +++ b/nw/convert/file/markdown.py @@ -15,7 +15,7 @@ import nw from nw.convert.file.text import TextFile from nw.convert.text.tomarkdown import ToMarkdown -from nw.enum import nwAlert +from nw.constants import nwAlert logger = logging.getLogger(__name__) diff --git a/nw/convert/file/text.py b/nw/convert/file/text.py index cc842422..d9d30fe6 100644 --- a/nw/convert/file/text.py +++ b/nw/convert/file/text.py @@ -18,7 +18,7 @@ from os import path from PyQt5.QtWidgets import QMessageBox from nw.convert.text.totext import ToText -from nw.enum import nwAlert, nwItemType, nwItemLayout, nwItemClass +from nw.constants import nwAlert, nwItemType, nwItemLayout, nwItemClass logger = logging.getLogger(__name__) diff --git a/nw/convert/text/__init__.py b/nw/convert/text/__init__.py index 078ed943..ef849320 100644 --- a/nw/convert/text/__init__.py +++ b/nw/convert/text/__init__.py @@ -6,8 +6,8 @@ from nw.convert.text.tomarkdown import ToMarkdown from nw.convert.text.totext import ToText __all__ = [ - ToHtml, - ToLaTeX, - ToMarkdown, - ToText, + "ToHtml", + "ToLaTeX", + "ToMarkdown", + "ToText", ] diff --git a/nw/convert/tokenizer.py b/nw/convert/tokenizer.py index 44bcc6c7..e5cae82b 100644 --- a/nw/convert/tokenizer.py +++ b/nw/convert/tokenizer.py @@ -20,7 +20,7 @@ from PyQt5.QtCore import QRegularExpression from nw.project.document import NWDoc from nw.tools.translate import numberToWord -from nw.enum import nwItemLayout +from nw.constants import nwItemLayout logger = logging.getLogger(__name__) diff --git a/nw/gui/__init__.py b/nw/gui/__init__.py index b5ab1e3c..a755fc97 100644 --- a/nw/gui/__init__.py +++ b/nw/gui/__init__.py @@ -26,21 +26,21 @@ from nw.gui.tools.dochighlight import GuiDocHighlighter from nw.gui.tools.wordcounter import WordCounter __all__ = [ - GuiMainMenu, - GuiMainStatus, - GuiConfigEditor, - GuiExport, - GuiItemEditor, - GuiProjectEditor, - GuiSessionLogView, - GuiTimeLineView, - GuiDocDetails, - GuiDocEditor, - GuiDocTree, - GuiDocViewer, - GuiNoticeBar, - GuiSearchBar, - GuiDocViewDetails, - GuiDocHighlighter, - WordCounter, + "GuiMainMenu", + "GuiMainStatus", + "GuiConfigEditor", + "GuiExport", + "GuiItemEditor", + "GuiProjectEditor", + "GuiSessionLogView", + "GuiTimeLineView", + "GuiDocDetails", + "GuiDocEditor", + "GuiDocTree", + "GuiDocViewer", + "GuiNoticeBar", + "GuiSearchBar", + "GuiDocViewDetails", + "GuiDocHighlighter", + "WordCounter", ] diff --git a/nw/gui/dialogs/__init__.py b/nw/gui/dialogs/__init__.py index f5ce2a89..fac299ba 100644 --- a/nw/gui/dialogs/__init__.py +++ b/nw/gui/dialogs/__init__.py @@ -8,10 +8,10 @@ from nw.gui.dialogs.sessionlog import GuiSessionLogView from nw.gui.dialogs.timelineview import GuiTimeLineView __all__ = [ - GuiConfigEditor, - GuiExport, - GuiItemEditor, - GuiProjectEditor, - GuiSessionLogView, - GuiTimeLineView, + "GuiConfigEditor", + "GuiExport", + "GuiItemEditor", + "GuiProjectEditor", + "GuiSessionLogView", + "GuiTimeLineView", ] diff --git a/nw/gui/dialogs/configeditor.py b/nw/gui/dialogs/configeditor.py index c7f17771..b38e20ee 100644 --- a/nw/gui/dialogs/configeditor.py +++ b/nw/gui/dialogs/configeditor.py @@ -25,8 +25,7 @@ from PyQt5.QtWidgets import ( QFileDialog ) -from nw.enum import nwAlert -from nw.constants import nwQuotes +from nw.constants import nwAlert, nwQuotes logger = logging.getLogger(__name__) diff --git a/nw/gui/dialogs/export.py b/nw/gui/dialogs/export.py index 56e99369..c3053ff0 100644 --- a/nw/gui/dialogs/export.py +++ b/nw/gui/dialogs/export.py @@ -27,9 +27,8 @@ from PyQt5.QtWidgets import ( from nw.convert import TextFile, HtmlFile, MarkdownFile, LaTeXFile, ConcatFile from nw.project import NWDoc from nw.tools import numberToWord, OptLastState -from nw.constants import nwFiles from nw.common import packageRefURL -from nw.enum import nwItemType, nwAlert +from nw.constants import nwFiles, nwItemType, nwAlert logger = logging.getLogger(__name__) diff --git a/nw/gui/dialogs/itemeditor.py b/nw/gui/dialogs/itemeditor.py index ea278bc9..f099a32d 100644 --- a/nw/gui/dialogs/itemeditor.py +++ b/nw/gui/dialogs/itemeditor.py @@ -22,8 +22,7 @@ from PyQt5.QtWidgets import ( QLineEdit, QPushButton, QComboBox ) -from nw.enum import nwItemLayout, nwItemClass, nwItemType -from nw.constants import nwLabels +from nw.constants import nwLabels, nwItemLayout, nwItemClass, nwItemType logger = logging.getLogger(__name__) diff --git a/nw/gui/dialogs/projecteditor.py b/nw/gui/dialogs/projecteditor.py index d848bc9a..1db212f6 100644 --- a/nw/gui/dialogs/projecteditor.py +++ b/nw/gui/dialogs/projecteditor.py @@ -25,7 +25,7 @@ from PyQt5.QtWidgets import ( QTreeWidgetItem, QCheckBox ) -from nw.enum import nwAlert +from nw.constants import nwAlert logger = logging.getLogger(__name__) diff --git a/nw/gui/dialogs/sessionlog.py b/nw/gui/dialogs/sessionlog.py index c3a53cf5..fcbc54e9 100644 --- a/nw/gui/dialogs/sessionlog.py +++ b/nw/gui/dialogs/sessionlog.py @@ -24,9 +24,8 @@ from PyQt5.QtWidgets import ( QCheckBox ) -from nw.constants import nwConst, nwFiles +from nw.constants import nwConst, nwFiles, nwAlert from nw.tools import OptLastState -from nw.enum import nwAlert logger = logging.getLogger(__name__) diff --git a/nw/gui/dialogs/timelineview.py b/nw/gui/dialogs/timelineview.py index 4d75d01a..0ac3148f 100644 --- a/nw/gui/dialogs/timelineview.py +++ b/nw/gui/dialogs/timelineview.py @@ -23,9 +23,8 @@ from PyQt5.QtWidgets import ( QGroupBox, QCheckBox ) -from nw.constants import nwFiles +from nw.constants import nwFiles, nwItemClass from nw.tools import OptLastState -from nw.enum import nwItemClass logger = logging.getLogger(__name__) diff --git a/nw/gui/elements/__init__.py b/nw/gui/elements/__init__.py index 4e198336..572473ee 100644 --- a/nw/gui/elements/__init__.py +++ b/nw/gui/elements/__init__.py @@ -9,11 +9,11 @@ from nw.gui.elements.searchbar import GuiSearchBar from nw.gui.elements.viewdetails import GuiDocViewDetails __all__ = [ - GuiDocDetails, - GuiDocEditor, - GuiDocTree, - GuiDocViewer, - GuiNoticeBar, - GuiSearchBar, - GuiDocViewDetails, + "GuiDocDetails", + "GuiDocEditor", + "GuiDocTree", + "GuiDocViewer", + "GuiNoticeBar", + "GuiSearchBar", + "GuiDocViewDetails", ] diff --git a/nw/gui/elements/doceditor.py b/nw/gui/elements/doceditor.py index 00da2436..72dea74b 100644 --- a/nw/gui/elements/doceditor.py +++ b/nw/gui/elements/doceditor.py @@ -27,8 +27,7 @@ from PyQt5.QtGui import ( from nw.project import NWDoc from nw.gui.tools import GuiDocHighlighter, WordCounter from nw.tools import NWSpellCheck -from nw.constants import nwFiles, nwUnicode -from nw.enum import nwDocAction, nwAlert +from nw.constants import nwFiles, nwUnicode, nwDocAction, nwAlert logger = logging.getLogger(__name__) diff --git a/nw/gui/elements/doctree.py b/nw/gui/elements/doctree.py index 49673c3f..6eb1441e 100644 --- a/nw/gui/elements/doctree.py +++ b/nw/gui/elements/doctree.py @@ -20,8 +20,9 @@ from PyQt5.QtWidgets import ( ) from nw.project import NWItem -from nw.constants import nwLabels -from nw.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert +from nw.constants import ( + nwLabels, nwItemType, nwItemClass, nwItemLayout, nwAlert +) logger = logging.getLogger(__name__) diff --git a/nw/gui/elements/docviewer.py b/nw/gui/elements/docviewer.py index 2636a112..614adafe 100644 --- a/nw/gui/elements/docviewer.py +++ b/nw/gui/elements/docviewer.py @@ -18,7 +18,7 @@ from PyQt5.QtWidgets import QTextBrowser from PyQt5.QtGui import QTextOption, QFont, QPalette, QColor from nw.convert import Tokenizer, ToHtml -from nw.enum import nwAlert, nwItemType +from nw.constants import nwAlert, nwItemType logger = logging.getLogger(__name__) diff --git a/nw/gui/elements/searchbar.py b/nw/gui/elements/searchbar.py index 32a520ec..02f97755 100644 --- a/nw/gui/elements/searchbar.py +++ b/nw/gui/elements/searchbar.py @@ -19,7 +19,7 @@ from PyQt5.QtWidgets import ( QFrame, QGridLayout, QLabel, QLineEdit, QPushButton, QApplication ) -from nw.enum import nwDocAction +from nw.constants import nwDocAction logger = logging.getLogger(__name__) diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index c1366662..1e935d68 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -17,7 +17,7 @@ from PyQt5.QtCore import QUrl from PyQt5.QtGui import QIcon, QDesktopServices from PyQt5.QtWidgets import QMenuBar, QAction, QMessageBox -from nw.enum import nwItemType, nwItemClass, nwDocAction +from nw.constants import nwItemType, nwItemClass, nwDocAction logger = logging.getLogger(__name__) diff --git a/nw/gui/tools/__init__.py b/nw/gui/tools/__init__.py index 48a90468..4899f398 100644 --- a/nw/gui/tools/__init__.py +++ b/nw/gui/tools/__init__.py @@ -4,6 +4,6 @@ from nw.gui.tools.dochighlight import GuiDocHighlighter from nw.gui.tools.wordcounter import WordCounter __all__ = [ - GuiDocHighlighter, - WordCounter, + "GuiDocHighlighter", + "WordCounter", ] diff --git a/nw/guimain.py b/nw/guimain.py index 6d79eb2f..b42b4070 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -29,11 +29,10 @@ from nw.gui import ( GuiConfigEditor, GuiProjectEditor, GuiExport, GuiItemEditor, GuiTimeLineView, GuiSessionLogView ) -from nw.constants import nwFiles from nw.project import NWProject, NWDoc, NWItem, NWIndex, NWBackup from nw.tools import countWords from nw.theme import Theme -from nw.enum import nwItemType, nwAlert +from nw.constants import nwFiles, nwItemType, nwAlert logger = logging.getLogger(__name__) diff --git a/nw/project/__init__.py b/nw/project/__init__.py index 1bfb4b8c..d7065c78 100644 --- a/nw/project/__init__.py +++ b/nw/project/__init__.py @@ -8,10 +8,10 @@ from nw.project.project import NWProject from nw.project.status import NWStatus __all__ = [ - NWBackup, - NWDoc, - NWIndex, - NWItem, - NWProject, - NWStatus, + "NWBackup", + "NWDoc", + "NWIndex", + "NWItem", + "NWProject", + "NWStatus", ] diff --git a/nw/project/backup.py b/nw/project/backup.py index 2fdb4112..9e6e5a38 100644 --- a/nw/project/backup.py +++ b/nw/project/backup.py @@ -17,7 +17,7 @@ from os import path, mkdir, listdir from shutil import make_archive from datetime import datetime -from nw.enum import nwAlert +from nw.constants import nwAlert logger = logging.getLogger(__name__) diff --git a/nw/project/document.py b/nw/project/document.py index c6a5e49c..0cc0fa66 100644 --- a/nw/project/document.py +++ b/nw/project/document.py @@ -15,7 +15,7 @@ import nw from os import path, mkdir, rename, unlink -from nw.enum import nwAlert +from nw.constants import nwAlert logger = logging.getLogger(__name__) diff --git a/nw/project/index.py b/nw/project/index.py index 55f3f42e..c8c4c4cb 100644 --- a/nw/project/index.py +++ b/nw/project/index.py @@ -17,8 +17,9 @@ import nw from os import path from nw.project.document import NWDoc -from nw.constants import nwFiles, nwKeyWords -from nw.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert +from nw.constants import ( + nwFiles, nwKeyWords, nwItemType, nwItemClass, nwItemLayout, nwAlert +) logger = logging.getLogger(__name__) diff --git a/nw/project/item.py b/nw/project/item.py index a1667032..7c30fc8b 100644 --- a/nw/project/item.py +++ b/nw/project/item.py @@ -18,7 +18,7 @@ from lxml import etree from datetime import datetime from nw.common import checkInt -from nw.enum import nwItemType, nwItemClass, nwItemLayout +from nw.constants import nwItemType, nwItemClass, nwItemLayout logger = logging.getLogger(__name__) diff --git a/nw/project/project.py b/nw/project/project.py index 9d621977..49105ce8 100644 --- a/nw/project/project.py +++ b/nw/project/project.py @@ -22,9 +22,10 @@ from time import time from nw.project.status import NWStatus from nw.project.item import NWItem -from nw.constants import nwFiles, nwConst from nw.common import checkString, checkBool, checkInt -from nw.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert +from nw.constants import ( + nwFiles, nwConst, nwItemType, nwItemClass, nwItemLayout, nwAlert +) logger = logging.getLogger(__name__) diff --git a/nw/project/status.py b/nw/project/status.py index e3f293f4..df6f5815 100644 --- a/nw/project/status.py +++ b/nw/project/status.py @@ -16,7 +16,7 @@ import nw from lxml import etree from nw.common import checkInt -from nw.enum import nwItemClass +from nw.constants import nwItemClass logger = logging.getLogger(__name__) diff --git a/nw/theme.py b/nw/theme.py index 0b687b17..157b26a3 100644 --- a/nw/theme.py +++ b/nw/theme.py @@ -19,7 +19,7 @@ from os import path, listdir from PyQt5.QtWidgets import qApp from PyQt5.QtGui import QPalette, QColor, QIcon -from nw.enum import nwAlert +from nw.constants import nwAlert logger = logging.getLogger(__name__) diff --git a/nw/tools/__init__.py b/nw/tools/__init__.py index d024daad..52bff781 100644 --- a/nw/tools/__init__.py +++ b/nw/tools/__init__.py @@ -8,10 +8,10 @@ from nw.tools.translate import numberToWord from nw.tools.wordcount import countWords __all__ = [ - TextAnalysis, - OptLastState, - NWSpellCheck, - NWSpellEnchant, - numberToWord, - countWords, + "TextAnalysis", + "OptLastState", + "NWSpellCheck", + "NWSpellEnchant", + "numberToWord", + "countWords", ] diff --git a/nw/tools/spellenchant.py b/nw/tools/spellenchant.py index cf4f1574..a37949c1 100644 --- a/nw/tools/spellenchant.py +++ b/nw/tools/spellenchant.py @@ -14,13 +14,8 @@ import logging import enchant import nw -try: - import pycountry - hasPyCountry = True -except: - hasPyCountry = False - from nw.tools.spellcheck import NWSpellCheck +from nw.constants import isoLanguage logger = logging.getLogger(__name__) @@ -61,19 +56,16 @@ class NWSpellEnchant(NWSpellCheck): def listDictionaries(self): retList = [] for spTag, spProvider in enchant.list_dicts(): - if hasPyCountry: - spList = [] - try: - langObj = pycountry.languages.get(alpha_2 = spTag[:2]) - spList.append(langObj.name) - except: - spList.append(spTag[:2]) - if len(spTag) > 3: - spList.append("(%s)" % spTag[3:]) - spList.append("[%s]" % spProvider.name) - spName = " ".join(spList) + spList = [] + if spTag[:2] in isoLanguage.ISO_639_1: + langName = isoLanguage.ISO_639_1[spTag[:2]] else: - spName = "%s [%s]" % (spTag, spProvider.name) + langName = spTag[:2] + spList.append(langName) + if len(spTag) > 3: + spList.append("(%s)" % spTag[3:]) + spList.append("[%s]" % spProvider.name) + spName = " ".join(spList) retList.append((spTag, spName)) return retList diff --git a/requirements.txt b/requirements.txt index b72874df..b1d28992 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,5 @@ pyqt5 appdirs lxml pyenchant -pycountry latexcodec pypandoc diff --git a/setup.py b/setup.py index 2f7b7e6c..7caa09a4 100755 --- a/setup.py +++ b/setup.py @@ -41,7 +41,6 @@ setuptools.setup( "appdirs", "lxml", "pyenchant", - "pycountry", "latexcodec", "pypandoc", ], diff --git a/tests/nwdummy.py b/tests/nwdummy.py index d1e65fb0..2c54a92a 100644 --- a/tests/nwdummy.py +++ b/tests/nwdummy.py @@ -2,7 +2,7 @@ """novelWriter Test Dummy GUI Classes """ -from nw.enum import nwAlert +from nw.constants import nwAlert class DummyMain(): diff --git a/tests/test_gui.py b/tests/test_gui.py index 16723feb..41c15302 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -12,7 +12,7 @@ from nw.gui.dialogs.projecteditor import GuiProjectEditor from nw.gui.dialogs.timelineview import GuiTimeLineView from nw.gui.dialogs.itemeditor import GuiItemEditor -from nw.enum import * +from nw.constants import * keyDelay = 10 stepDelay = 50 diff --git a/tests/test_project.py b/tests/test_project.py index baeaf1a6..907d0e9f 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -12,7 +12,7 @@ from nw.config import Config from nw.project.project import NWProject from nw.project.item import NWItem from nw.project.index import NWIndex -from nw.enum import nwItemClass +from nw.constants import nwItemClass theConf = Config() theMain = DummyMain()