From 3d7c42e904f5a7f4dacca77f3a18f8317d924b61 Mon Sep 17 00:00:00 2001 From: Michael Gene Brockus Date: Sun, 16 Jun 2024 09:25:09 -0600 Subject: [PATCH] format source code --- mesonui/containers/doublylist.py | 11 ++-- mesonui/dashboard/appdashboard.py | 19 +++++-- mesonui/dashboard/buildoptions.py | 12 ++-- mesonui/dashboard/projectinfo.py | 12 ++-- mesonui/dashboard/tests.py | 12 ++-- mesonui/mesonuilib/appconfig/core.py | 48 ++++++++-------- mesonui/mesonuilib/backends/kdevelop.py | 66 +++++++++++++--------- mesonui/repository/dataloader.py | 75 +++++++++++++------------ 8 files changed, 141 insertions(+), 114 deletions(-) diff --git a/mesonui/containers/doublylist.py b/mesonui/containers/doublylist.py index 46a512e..2161a4e 100755 --- a/mesonui/containers/doublylist.py +++ b/mesonui/containers/doublylist.py @@ -1,14 +1,15 @@ #!/usr/bin/env python3 + # -# author : Michael Brockus.   -# contact:  -# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 +# author : Michael Brockus. +# contact:  +# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 # # copyright 2020 The Meson-UI development team # class MesonUiNode: - def __init__(self, data_ptr = None, next_ptr = None, prev_ptr = None): + def __init__(self, data_ptr=None, next_ptr=None, prev_ptr=None): self.data = data_ptr self.next = next_ptr self.prev = prev_ptr @@ -38,7 +39,7 @@ def remove_item(self): if self.is_empty(): return else: - if(self.head != self.tail): + if self.head != self.tail: self.head = self.head.next self.head.previous = None else: diff --git a/mesonui/dashboard/appdashboard.py b/mesonui/dashboard/appdashboard.py index 4bb4815..bac90f2 100755 --- a/mesonui/dashboard/appdashboard.py +++ b/mesonui/dashboard/appdashboard.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 # -# author : Michael Brockus.   -# contact:  -# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 +# author : Michael Brockus. +# contact:  +# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 # # copyright 2020 The Meson-UI development team # @@ -11,12 +11,19 @@ from .projectinfo import IntroProjectInfoTab from .tests import IntroTestlogInfoTab + class IntrospectionDashboard: def __init__(self, context, meson_api): super().__init__() - self._buildoptions: IntroBuildOptionsTab = IntroBuildOptionsTab(context=context, meson_api=meson_api) - self._projectinfo: IntroProjectInfoTab = IntroProjectInfoTab(context=context, meson_api=meson_api) - self._testloginfo: IntroTestlogInfoTab = IntroTestlogInfoTab(context=context, meson_api=meson_api) + self._buildoptions: IntroBuildOptionsTab = IntroBuildOptionsTab( + context=context, meson_api=meson_api + ) + self._projectinfo: IntroProjectInfoTab = IntroProjectInfoTab( + context=context, meson_api=meson_api + ) + self._testloginfo: IntroTestlogInfoTab = IntroTestlogInfoTab( + context=context, meson_api=meson_api + ) def update(self, meson_api: None): self._buildoptions.update_introspection(meson_api) diff --git a/mesonui/dashboard/buildoptions.py b/mesonui/dashboard/buildoptions.py index 3559850..6cfaa94 100755 --- a/mesonui/dashboard/buildoptions.py +++ b/mesonui/dashboard/buildoptions.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 # -# author : Michael Brockus.   -# contact:  -# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 +# author : Michael Brockus. +# contact:  +# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 # # copyright 2020 The Meson-UI development team # @@ -18,7 +18,7 @@ def __init__(self, context, meson_api): def setup_introspection(self): head_ref = self._context._model.model_options().get_list().head - while (head_ref is not None): + while head_ref is not None: new_item = QListWidgetItem(head_ref.data) self._context.buildoptions_list.addItem(new_item) head_ref = head_ref.next @@ -30,11 +30,11 @@ def update_introspection(self, meson_api): head_ref = self._context._model.model_options().get_list().head if head_ref is None: - new_item = QListWidgetItem(f'No Project data.') + new_item = QListWidgetItem("No Project data.") self._context.buildoptions_list.addItem(new_item) return - while (head_ref is not None): + while head_ref is not None: new_item = QListWidgetItem(head_ref.data) self._context.buildoptions_list.addItem(new_item) head_ref = head_ref.next diff --git a/mesonui/dashboard/projectinfo.py b/mesonui/dashboard/projectinfo.py index 7d1ad98..011c635 100755 --- a/mesonui/dashboard/projectinfo.py +++ b/mesonui/dashboard/projectinfo.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 # -# author : Michael Brockus.   -# contact:  -# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 +# author : Michael Brockus. +# contact:  +# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 # # copyright 2020 The Meson-UI development team # @@ -18,7 +18,7 @@ def __init__(self, context, meson_api): def setup_introspection(self): head_ref = self._context._model.buildsysteminfo().get_list().head - while (head_ref is not None): + while head_ref is not None: new_item = QListWidgetItem(head_ref.data) self._context.projectinfo_list.addItem(new_item) head_ref = head_ref.next @@ -30,11 +30,11 @@ def update_introspection(self, meson_api): head_ref = self._context._model.buildsysteminfo().get_list().head if head_ref is None: - new_item = QListWidgetItem(f'No Project data.') + new_item = QListWidgetItem("No Project data.") self._context.projectinfo_list.addItem(new_item) return - while (head_ref is not None): + while head_ref is not None: new_item = QListWidgetItem(head_ref.data) self._context.projectinfo_list.addItem(new_item) head_ref = head_ref.next diff --git a/mesonui/dashboard/tests.py b/mesonui/dashboard/tests.py index fea1f21..b621401 100755 --- a/mesonui/dashboard/tests.py +++ b/mesonui/dashboard/tests.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 # -# author : Michael Brockus.   -# contact:  -# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 +# author : Michael Brockus. +# contact:  +# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 # # copyright 2020 The Meson-UI development team # @@ -18,7 +18,7 @@ def __init__(self, context, meson_api): def setup_introspection(self): head_ref = self._context._model.model_testlogsinfo().get_list().head - while (head_ref is not None): + while head_ref is not None: new_item = QListWidgetItem(head_ref.data) self._context.testsinfo_list.addItem(new_item) head_ref = head_ref.next @@ -30,11 +30,11 @@ def update_introspection(self, meson_api): head_ref = self._context._model.model_testlogsinfo().get_list().head if head_ref is None: - new_item = QListWidgetItem(f'No Testlogs data.') + new_item = QListWidgetItem("No Testlogs data.") self._context.testsinfo_list.addItem(new_item) return - while (head_ref is not None): + while head_ref is not None: new_item = QListWidgetItem(head_ref.data) self._context.testsinfo_list.addItem(new_item) head_ref = head_ref.next diff --git a/mesonui/mesonuilib/appconfig/core.py b/mesonui/mesonuilib/appconfig/core.py index 6b5efa3..95bb129 100755 --- a/mesonui/mesonuilib/appconfig/core.py +++ b/mesonui/mesonuilib/appconfig/core.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 # -# author : Michael Brockus.   -# contact:  -# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 +# author : Michael Brockus. +# contact:  +# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 # # copyright 2020 The Meson-UI development team # @@ -14,32 +14,34 @@ class MesonCoreConfig: def __init__(self): self.meson_configure: T.Dict = { - '--auto-features': None, - '--backend': None, - '--buildtype': None, - '--default-library': None, - '--layout': None, - '--unity': None, - '--warnlevel': None, - '--wrap-mode': None, - '--werror': None,# eithor --werror or '' - '--strip': None, # eithor --strip or '' - '--cmake-prefix-path': None, - '--pkg-config-path': None, - '--fatal-meson-warnings': None + "--auto-features": None, + "--backend": None, + "--buildtype": None, + "--default-library": None, + "--layout": None, + "--unity": None, + "--warnlevel": None, + "--wrap-mode": None, + "--werror": None, # eithor --werror or '' + "--strip": None, # eithor --strip or '' + "--cmake-prefix-path": None, + "--pkg-config-path": None, + "--fatal-meson-warnings": None, } def extract(self): for conf in self.meson_configure: if self.meson_configure[conf] is None: - raise MesonUiException('Meson cache failed do to "None" value found while loading value') + raise MesonUiException( + 'Meson cache failed do to "None" value found while loading value' + ) return self.meson_configure - def config(self, option: T.AnyStr, value: T.AnyStr = '') -> None: - if option == '': - raise MesonUiException('Option key passed as empty string object') - if value == '': - raise MesonUiException('Value passed in as empty string object') + def config(self, option: T.AnyStr, value: T.AnyStr = "") -> None: + if option == "": + raise MesonUiException("Option key passed as empty string object") + if value == "": + raise MesonUiException("Value passed in as empty string object") - self.meson_configure[f'--{option}'] = value + self.meson_configure[f"--{option}"] = value diff --git a/mesonui/mesonuilib/backends/kdevelop.py b/mesonui/mesonuilib/backends/kdevelop.py index 768fe8d..01fc056 100755 --- a/mesonui/mesonuilib/backends/kdevelop.py +++ b/mesonui/mesonuilib/backends/kdevelop.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 # -# author : Michael Brockus.   -# contact:  -# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 +# author : Michael Brockus. +# contact:  +# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 # # copyright 2020 The Meson-UI development team # @@ -21,45 +21,61 @@ class KDevelopBackend(BackendImplementionApi): def __init__(self, meson_api: MesonAPI): super(self.__class__, self).__init__(meson_api) - self.backend: str = '\'kdevelop\'' + self.backend: str = "'kdevelop'" self.buildoptions = BuildOption(meson_api=meson_api) self.projectinfo = ProjectInfo(meson_api=meson_api) self.mesoninfo = MesonInfo(meson_api=meson_api) self.meson = Meson() def generator(self): - logging.info(f'Generating {self.backend} project') + logging.info(f"Generating {self.backend} project") self.generate_project() def generate_project(self): # Generate the .kdev4 file. - with open(join_paths(self.mesoninfo.builddir, f'{self.projectinfo.descriptive_name}.kdev4'), 'w') as file: - file.write('[Project]\n') - file.write('CreatedFrom=meson.build\n') - file.write('Manager=KDevMesonManager\n') - file.write(f'Name={self.projectinfo.descriptive_name}\n') + with open( + join_paths( + self.mesoninfo.builddir, f"{self.projectinfo.descriptive_name}.kdev4" + ), + "w", + ) as file: + file.write("[Project]\n") + file.write("CreatedFrom=meson.build\n") + file.write("Manager=KDevMesonManager\n") + file.write(f"Name={self.projectinfo.descriptive_name}\n") # Make .kdev4/ directory. - if not os.path.exists(join_paths(self.mesoninfo.builddir, '.kdev')): - os.mkdir(join_paths(self.mesoninfo.builddir, '.kdev')) + if not os.path.exists(join_paths(self.mesoninfo.builddir, ".kdev")): + os.mkdir(join_paths(self.mesoninfo.builddir, ".kdev")) # Generate the .kdev4/ file. - with open(join_paths(self.mesoninfo.builddir, '.kdev', f'{self.projectinfo.descriptive_name}.kdev4'), 'w') as file: - file.write('[Buildset]\n') - file.write(f'BuildItems=@Variant({self._variant()})\n\n') + with open( + join_paths( + self.mesoninfo.builddir, + ".kdev", + f"{self.projectinfo.descriptive_name}.kdev4", + ), + "w", + ) as file: + file.write("[Buildset]\n") + file.write(f"BuildItems=@Variant({self._variant()})\n\n") - file.write('[MesonManager]\n') - file.write(f'Current Build Directory Index=0\n') - file.write(f'Number of Build Directories=1\n\n') + file.write("[MesonManager]\n") + file.write(f"Current Build Directory Index=0\n") + file.write(f"Number of Build Directories=1\n\n") - file.write('[MesonManager][BuildDir 0]\n') - file.write('Additional meson arguments=\n') - file.write(f'Build Build Path={self.mesoninfo.builddir}\n') - file.write(f'Meson Generator Backend={self.buildoptions.combo("backend").value}\n') - file.write(f'Meson executable={self.meson.exe}\n') + file.write("[MesonManager][BuildDir 0]\n") + file.write("Additional meson arguments=\n") + file.write(f"Build Build Path={self.mesoninfo.builddir}\n") + file.write( + f'Meson Generator Backend={self.buildoptions.combo("backend").value}\n' + ) + file.write(f"Meson executable={self.meson.exe}\n") def _variant(self) -> str: - variant: str = '\\x00\\x00\\x00\\t\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x0b\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x16' + variant: str = ( + "\\x00\\x00\\x00\\t\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x0b\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x16" + ) for i in self.projectinfo.descriptive_name: - variant + f'\\x00{i}' + variant + f"\\x00{i}" return variant diff --git a/mesonui/repository/dataloader.py b/mesonui/repository/dataloader.py index 330d59e..fef0027 100755 --- a/mesonui/repository/dataloader.py +++ b/mesonui/repository/dataloader.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 # -# author : Michael Brockus.   -# contact:  -# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 +# author : Michael Brockus. +# contact:  +# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 # # copyright 2020 The Meson-UI development team # @@ -13,53 +13,54 @@ import json _MESON_INTRO_FILES: tuple = ( - 'intro-benchmarks.json', - 'intro-buildoptions.json', - 'intro-buildsystem_files.json', - 'intro-dependencies.json', - 'intro-installed.json', - 'intro-projectinfo.json', - 'intro-targets.json', - 'intro-tests.json', - 'meson-info.json' + "intro-benchmarks.json", + "intro-buildoptions.json", + "intro-buildsystem_files.json", + "intro-dependencies.json", + "intro-installed.json", + "intro-projectinfo.json", + "intro-targets.json", + "intro-tests.json", + "meson-info.json", ) + class MesonBuilddirLoader: def __init__(self, builddir: Path = None): self._builddir = builddir def _scan(self, group: str) -> any: - if group == 'testlog.json': - subdir = 'meson-logs' + if group == "testlog.json": + subdir = "meson-logs" if not Path(join_paths(self._builddir, subdir, group)).exists(): return None else: - subdir = 'meson-info' + subdir = "meson-info" with open(join_paths(self._builddir, subdir, group)) as loaded_json: info: any = json.loads(loaded_json.read()) return info def extract_from(self, group: str): - logging.info(f'Try getting {group} API object via build directory loader') - if group == 'buildoptions': - return self._scan(group=f'intro-{group}.json') - elif group == 'meson-info': - return self._scan(group=f'{group}.json') - elif group == 'testlog': - return self._scan(group=f'{group}.json') - elif group == 'tests': - return self._scan(group=f'intro-{group}.json') - elif group == 'benchmarks': - return self._scan(group=f'intro-{group}.json') - elif group == 'buildsystem-files': - return self._scan(group=f'intro-buildsystem_files.json') - elif group == 'projectinfo': - return self._scan(group=f'intro-{group}.json') - elif group == 'dependencies': - return self._scan(group=f'intro-{group}.json') - elif group == 'installed': - return self._scan(group=f'intro-{group}.json') - elif group == 'targets': - return self._scan(group=f'intro-{group}.json') + logging.info(f"Try getting {group} API object via build directory loader") + if group == "buildoptions": + return self._scan(group=f"intro-{group}.json") + elif group == "meson-info": + return self._scan(group=f"{group}.json") + elif group == "testlog": + return self._scan(group=f"{group}.json") + elif group == "tests": + return self._scan(group=f"intro-{group}.json") + elif group == "benchmarks": + return self._scan(group=f"intro-{group}.json") + elif group == "buildsystem-files": + return self._scan(group="intro-buildsystem_files.json") + elif group == "projectinfo": + return self._scan(group=f"intro-{group}.json") + elif group == "dependencies": + return self._scan(group=f"intro-{group}.json") + elif group == "installed": + return self._scan(group=f"intro-{group}.json") + elif group == "targets": + return self._scan(group=f"intro-{group}.json") else: - raise Exception(f'Group tag {group} not found in extract via data options!') + raise Exception(f"Group tag {group} not found in extract via data options!")