Wed, 21 Sep 2022 16:27:00 +0200
Reformatted source code with 'Black'.
.hgignore | file | annotate | diff | comparison | revisions | |
PluginKivy.epj | file | annotate | diff | comparison | revisions | |
PluginProjectKivy.py | file | annotate | diff | comparison | revisions | |
ProjectKivy/KivyLexer.py | file | annotate | diff | comparison | revisions |
--- a/.hgignore Thu Dec 30 12:15:18 2021 +0100 +++ b/.hgignore Wed Sep 21 16:27:00 2022 +0200 @@ -1,6 +1,7 @@ glob:.eric6project glob:.eric7project glob:.ropeproject +glob:.jedi glob:.directory glob:**.pyc glob:**.pyo
--- a/PluginKivy.epj Thu Dec 30 12:15:18 2021 +0100 +++ b/PluginKivy.epj Wed Sep 21 16:27:00 2022 +0200 @@ -1,19 +1,21 @@ { "header": { "comment": "eric project file for project PluginKivy", - "copyright": "Copyright (C) 2021 Detlev Offenbach, detlev@die-offenbachs.de" + "copyright": "Copyright (C) 2022 Detlev Offenbach, detlev@die-offenbachs.de" }, "project": { "AUTHOR": "Detlev Offenbach", "CHECKERSPARMS": { "Pep8Checker": { "AnnotationsChecker": { + "AllowStarArgAny": false, "AllowUntypedDefs": false, "AllowUntypedNested": false, "DispatchDecorators": [ "singledispatch", "singledispatchmethod" ], + "ForceFutureAnnotations": false, "MaximumComplexity": 3, "MaximumLength": 7, "MinimumCoverage": 75, @@ -59,20 +61,25 @@ }, "CopyrightAuthor": "", "CopyrightMinFileSize": 0, - "DocstringType": "eric", + "DocstringType": "eric_black", "EnabledCheckerCategories": "C, D, E, M, N, S, Y, W", "ExcludeFiles": "*/Ui_*.py, */*_rc.py,", - "ExcludeMessages": "C101,E265,E266,E305,E402,M201,M301,M302,M303,M304,M305,M306,M307,M308,M311,M312,M313,M314,M315,M321,M701,M702,M811,M834,N802,N803,N807,N808,N821,W293,W504,Y401,Y402", + "ExcludeMessages": "C101,E265,E266,E305,E402,M201,M301,M302,M303,M304,M305,M306,M307,M308,M311,M312,M313,M314,M315,M321,M701,M702,M811,M834,N802,N803,N807,N808,N821,W293,W503,Y401,Y402", "FixCodes": "", "FixIssues": false, "FutureChecker": "", "HangClosing": false, + "ImportsChecker": { + "ApplicationPackageNames": [], + "BanRelativeImports": "", + "BannedModules": [] + }, "IncludeMessages": "", "LineComplexity": 25, "LineComplexityScore": 10, "MaxCodeComplexity": 10, - "MaxDocLineLength": 79, - "MaxLineLength": 79, + "MaxDocLineLength": 88, + "MaxLineLength": 88, "NoFixCodes": "E501", "RepeatMessages": true, "SecurityChecker": { @@ -128,6 +135,7 @@ } }, "EMAIL": "detlev@die-offenbachs.de", + "EMBEDDED_VENV": false, "EOL": 1, "FILETYPES": { "*.epj": "OTHERS", @@ -159,6 +167,7 @@ }, "INTERFACES": [], "LEXERASSOCS": {}, + "LICENSE": "GNU General Public License v3 or later (GPLv3+)", "MAINSCRIPT": "PluginProjectKivy.py", "MAKEPARAMS": { "MakeEnabled": false, @@ -173,14 +182,31 @@ ".hgignore", "ChangeLog", "PKGLIST", + "PluginKivy.epj", "PluginProjectKivy.zip", "ProjectKivy/APIs/kivy.api", "ProjectKivy/APIs/kivy.bas", "ProjectKivy/Documentation/LICENSE.GPL", - "ProjectKivy/Documentation/source", - "PluginKivy.epj" + "ProjectKivy/Documentation/source" ], - "OTHERTOOLSPARMS": {}, + "OTHERTOOLSPARMS": { + "Black": { + "exclude": "/(\\.direnv|\\.eggs|\\.git|\\.hg|\\.mypy_cache|\\.nox|\\.tox|\\.venv|venv|\\.svn|_build|buck-out|build|dist|__pypackages__)/", + "extend-exclude": "", + "force-exclude": "", + "line-length": 88, + "skip-magic-trailing-comma": false, + "skip-string-normalization": false, + "source": "project", + "target-version": [ + "py311", + "py310", + "py39", + "py38", + "py37" + ] + } + }, "PACKAGERSPARMS": {}, "PROGLANGUAGE": "Python3", "PROJECTTYPE": "E7Plugin", @@ -202,6 +228,7 @@ "SPELLEXCLUDES": "", "SPELLLANGUAGE": "en_US", "SPELLWORDS": "", + "TESTING_FRAMEWORK": "", "TRANSLATIONEXCEPTIONS": [], "TRANSLATIONPATTERN": "ProjectKivy/i18n/kivy_%language%.ts", "TRANSLATIONS": [
--- a/PluginProjectKivy.py Thu Dec 30 12:15:18 2021 +0100 +++ b/PluginProjectKivy.py Wed Sep 21 16:27:00 2022 +0200 @@ -28,9 +28,7 @@ className = "ProjectKivyPlugin" packageName = "ProjectKivy" shortDescription = "Project support for Kivy projects." -longDescription = ( - """This plugin implements project support for Kivy projects.""" -) +longDescription = """This plugin implements project support for Kivy projects.""" needsRestart = False pyqtApi = 2 # End-of-Header @@ -41,16 +39,15 @@ def apiFiles(language): """ Module function to return the API files made available by this plugin. - + @param language language to get API file for @type str @return list of API filenames @rtype list of str """ if language in ["Python3"]: - apisDir = os.path.join(os.path.dirname(__file__), - "ProjectKivy", "APIs") - return glob.glob(os.path.join(apisDir, '*.api')) + apisDir = os.path.join(os.path.dirname(__file__), "ProjectKivy", "APIs") + return glob.glob(os.path.join(apisDir, "*.api")) else: return [] @@ -59,91 +56,100 @@ """ Class implementing the Kivy project plugin. """ + lexerAssociations = { "*.kv": "Pygments|Kivy", "*.kivy": "Pygments|Kivy", } - - KivyLexerKey = 'KivyLexer' + + KivyLexerKey = "KivyLexer" KivyLexerEntry = ( - 'ProjectKivy.KivyLexer', - 'Kivy', - ('kivy', 'kv'), - ('*.kv', '*.kivy'), - ('application/x-kivy',) + "ProjectKivy.KivyLexer", + "Kivy", + ("kivy", "kv"), + ("*.kv", "*.kivy"), + ("application/x-kivy",), ) - + def __init__(self, ui): """ Constructor - + @param ui reference to the user interface object @type UserInterface """ QObject.__init__(self, ui) self.__ui = ui self.__initialize() - + self.__translator = None self.__loadTranslator() - + def __initialize(self): """ Private slot to (re)initialize the plugin. """ self.__ericProject = ericApp().getObject("Project") - + def activate(self): """ Public method to activate this plugin. - + @return tuple of None and activation status @rtype bool """ self.__ericProject.registerProjectType( - "Kivy", self.tr("Kivy"), self.fileTypesCallback, + "Kivy", + self.tr("Kivy"), + self.fileTypesCallback, lexerAssociationCallback=self.lexerAssociationCallback, - progLanguages=["Python3"]) - + progLanguages=["Python3"], + ) + from Project.ProjectBrowser import ( - SourcesBrowserFlag, FormsBrowserFlag, TranslationsBrowserFlag, - OthersBrowserFlag + SourcesBrowserFlag, + FormsBrowserFlag, + TranslationsBrowserFlag, + OthersBrowserFlag, ) + Preferences.setProjectBrowserFlagsDefault( "Kivy", - SourcesBrowserFlag | - FormsBrowserFlag | - TranslationsBrowserFlag | - OthersBrowserFlag, + SourcesBrowserFlag + | FormsBrowserFlag + | TranslationsBrowserFlag + | OthersBrowserFlag, ) - + LEXERS[self.KivyLexerKey] = self.KivyLexerEntry import QScintilla.Lexers + QScintilla.Lexers.registerLexer( "Pygments|Kivy", self.tr("Kivy"), "dummy.kv", self.getLexer, - [self.tr('Kivy Files (*.kv *.kivy)')], - [self.tr('Kivy Files (*.kv)')], - ['*.kv', '*.kivy'] + [self.tr("Kivy Files (*.kv *.kivy)")], + [self.tr("Kivy Files (*.kv)")], + ["*.kv", "*.kivy"], ) - + return None, True - + def deactivate(self): """ Public method to deactivate this plugin. """ self.__ericProject.unregisterProjectType("Kivy") - + import QScintilla.Lexers + QScintilla.Lexers.unregisterLexer("Kivy") if self.KivyLexerKey in LEXERS: del LEXERS[self.KivyLexerKey] - + self.__initialize() - + def __loadTranslator(self): """ Private method to load the translation file. @@ -152,7 +158,8 @@ loc = self.__ui.getLocale() if loc and loc != "C": locale_dir = os.path.join( - os.path.dirname(__file__), "ProjectKivy", "i18n") + os.path.dirname(__file__), "ProjectKivy", "i18n" + ) translation = "kivy_{0}".format(loc) translator = QTranslator(None) loaded = translator.load(translation, locale_dir) @@ -160,14 +167,16 @@ self.__translator = translator ericApp().installTranslator(self.__translator) else: - print("Warning: translation file '{0}' could not be" - " loaded.".format(translation)) + print( + "Warning: translation file '{0}' could not be" + " loaded.".format(translation) + ) print("Using default.") - + def fileTypesCallback(self): """ Public method get the filetype associations of the Kivy project type. - + @return dictionary with file type associations @rtype dict """ @@ -179,12 +188,12 @@ } else: return {} - + def lexerAssociationCallback(self, filename): """ Public method to get the lexer association of the Kivy project type for a file. - + @param filename name of the file @type str @return name of the lexer (Pygments lexers are prefixed with @@ -194,24 +203,26 @@ for pattern, language in self.lexerAssociations.items(): if fnmatch.fnmatch(filename, pattern): return language - + return "" - + def getLexer(self, parent=None): """ Public method to instantiate a Pygments Kivy lexer object. - + @param parent reference to the parent object @type QObject @return reference to the instanciated lexer object @rtype QsciLexer """ from QScintilla.Lexers.LexerPygments import LexerPygments + lexer = LexerPygments(parent, name="Kivy") if lexer.canStyle(): return lexer else: return None + # # eflag: noqa = M801, M811
--- a/ProjectKivy/KivyLexer.py Thu Dec 30 12:15:18 2021 +0100 +++ b/ProjectKivy/KivyLexer.py Wed Sep 21 16:27:00 2022 +0200 @@ -16,44 +16,46 @@ from pygments.lexers.agile import PythonLexer from pygments.token import Comment, Text, Name, Punctuation, Operator -__all__ = ['KivyLexer'] +__all__ = ["KivyLexer"] class KivyLexer(RegexLexer): """ Class implementing a Pygments lexer for the Kivy language. """ - name = 'Kivy' - aliases = ['kivy', 'kv'] - filenames = ['*.kv', '*.kivy'] - mimetypes = ['application/x-kivy'] + + name = "Kivy" + aliases = ["kivy", "kv"] + filenames = ["*.kv", "*.kivy"] + mimetypes = ["application/x-kivy"] tokens = { - 'root': [ - (r'#:.*?$', Comment.Preproc), - (r'#.*?$', using(PythonLexer)), - (r'\s+', Text), - (r'<.+>', Name.Namespace), - (r'(\[)(\s*)(.*?)(\s*)(@)', + "root": [ + (r"#:.*?$", Comment.Preproc), + (r"#.*?$", using(PythonLexer)), + (r"\s+", Text), + (r"<.+>", Name.Namespace), + ( + r"(\[)(\s*)(.*?)(\s*)(@)", bygroups(Punctuation, Text, Name.Class, Text, Operator), - 'classList'), - (r'[A-Za-z][A-Za-z0-9]*$', Name.Attribute), - (r'(.*?)(\s*)(:)(\s*)$', - bygroups(Name.Class, Text, Punctuation, Text)), - (r'(.*?)(\s*)(:)(\s*)(.*?)$', - bygroups(Name.Attribute, Text, Punctuation, Text, - using(PythonLexer))), - (r'[^:]+?$', using(PythonLexer)) + "classList", + ), + (r"[A-Za-z][A-Za-z0-9]*$", Name.Attribute), + (r"(.*?)(\s*)(:)(\s*)$", bygroups(Name.Class, Text, Punctuation, Text)), + ( + r"(.*?)(\s*)(:)(\s*)(.*?)$", + bygroups(Name.Attribute, Text, Punctuation, Text, using(PythonLexer)), + ), + (r"[^:]+?$", using(PythonLexer)), ], - 'classList': [ - (r'(,)(\s*)([A-Z][A-Za-z0-9]*)', - bygroups(Punctuation, Text, Name.Class)), - (r'(\+)(\s*)([A-Z][A-Za-z0-9]*)', - bygroups(Operator, Text, Name.Class)), - (r'\s+', Text), - (r'[A-Z][A-Za-z0-9]*', Name.Class), - (r'\]', Punctuation, '#pop') + "classList": [ + (r"(,)(\s*)([A-Z][A-Za-z0-9]*)", bygroups(Punctuation, Text, Name.Class)), + (r"(\+)(\s*)([A-Z][A-Za-z0-9]*)", bygroups(Operator, Text, Name.Class)), + (r"\s+", Text), + (r"[A-Z][A-Za-z0-9]*", Name.Class), + (r"\]", Punctuation, "#pop"), ], } + # # eflag: noqa = M702