From b381ee587f7499aaf1caf2a998d5bcbb2ffec562 Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Mon, 28 Nov 2022 22:48:51 -0800 Subject: [PATCH] fix: jans-cli DocString (ref: #2572) --- .../cli_tui/plugins/010_oxauth/main.py | 4 +- jans-cli-tui/cli_tui/plugins/020_fido/main.py | 28 +++---- jans-cli-tui/cli_tui/plugins/030_scim/main.py | 17 +--- .../cli_tui/plugins/040_config_api/main.py | 78 +++++++------------ 4 files changed, 41 insertions(+), 86 deletions(-) diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/main.py b/jans-cli-tui/cli_tui/plugins/010_oxauth/main.py index 3cdbe078521..75d05c4ea6d 100755 --- a/jans-cli-tui/cli_tui/plugins/010_oxauth/main.py +++ b/jans-cli-tui/cli_tui/plugins/010_oxauth/main.py @@ -69,8 +69,8 @@ def init_plugin(self) -> None: self.schema = self.app.cli_object.get_schema_from_reference('', '#/components/schemas/AppConfiguration') async def get_appconfiguration(self) -> None: - """Coroutine for getting application configuration. - """ + 'Coroutine for getting application configuration.' + cli_args = {'operation_id': 'get-properties'} response = await self.app.loop.run_in_executor(self.app.executor, self.app.cli_requests, cli_args) diff --git a/jans-cli-tui/cli_tui/plugins/020_fido/main.py b/jans-cli-tui/cli_tui/plugins/020_fido/main.py index a78504df3a6..496cfa46936 100755 --- a/jans-cli-tui/cli_tui/plugins/020_fido/main.py +++ b/jans-cli-tui/cli_tui/plugins/020_fido/main.py @@ -1,29 +1,18 @@ -import os -import sys import asyncio -import time - from collections import OrderedDict from functools import partial from typing import Any - -from prompt_toolkit.application.current import get_app from prompt_toolkit.layout.containers import HSplit, DynamicContainer, VSplit, Window from prompt_toolkit.layout.dimension import D -from prompt_toolkit.widgets import Button, Label, Frame, Box, Dialog +from prompt_toolkit.widgets import Button, Label, Box, Dialog from prompt_toolkit.application import Application - from wui_components.jans_nav_bar import JansNavBar from wui_components.jans_drop_down import DropDownWidget from wui_components.jans_vetrical_nav import JansVerticalNav from wui_components.jans_cli_dialog import JansGDialog - - from utils.multi_lang import _ from utils.utils import DialogUtils -import cli_style - class Plugin(DialogUtils): """This is a general class for plugins """ @@ -34,7 +23,7 @@ def __init__( """init for Plugin class "fido" Args: - app (_type_): _description_ + app (Generic): The main Application class """ self.app = app self.pid = 'fido' @@ -48,11 +37,14 @@ def process(self) -> None: pass def init_plugin(self) -> None: + """The initialization for this plugin + """ self.app.create_background_task(self.get_fido_configuration()) - def edit_requested_party(self, **kwargs: Any) -> None: + """This method for editing the requested party + """ title = _("Enter Request Party Properties") schema = self.app.cli_object.get_schema_from_reference('Fido2', '#/components/schemas/RequestedParty') cur_data = kwargs.get('passed', ['', '']) @@ -74,8 +66,9 @@ def add_request_party(dialog: Dialog) -> None: dialog = JansGDialog(self.app, title=title, body=body, buttons=buttons, width=self.app.dialog_width-20) self.app.show_jans_dialog(dialog) - def delete_requested_party(self, **kwargs: Any) -> None: + """This method for deleting the requested party + """ self.requested_parties_container.remove_item(kwargs['selected']) def create_widgets(self): @@ -188,7 +181,6 @@ def create_widgets(self): self.nav_selection_changed(list(self.tabs)[0]) - async def get_fido_configuration(self) -> None: 'Coroutine for getting fido2 configuration.' try: @@ -253,8 +245,9 @@ def nav_selection_changed( else: self.main_area = self.app.not_implemented - def save_config(self) -> None: + """This method for saving the configuration + """ fido2_config = self.make_data_from_dialog(tabs={'configuration': self.tabs['configuration']}) fido2_static = self.make_data_from_dialog(tabs={'static': self.tabs['static']}) @@ -276,7 +269,6 @@ async def coroutine(): asyncio.ensure_future(coroutine()) - def set_center_frame(self) -> None: """center frame content """ diff --git a/jans-cli-tui/cli_tui/plugins/030_scim/main.py b/jans-cli-tui/cli_tui/plugins/030_scim/main.py index 85ddc6bd238..0e01fd02636 100755 --- a/jans-cli-tui/cli_tui/plugins/030_scim/main.py +++ b/jans-cli-tui/cli_tui/plugins/030_scim/main.py @@ -1,21 +1,12 @@ -import os -import sys import asyncio - -from typing import Sequence - - from prompt_toolkit.application import Application from prompt_toolkit.layout.containers import HSplit, VSplit, Window from prompt_toolkit.layout.dimension import D -from prompt_toolkit.widgets import Button, Label, Frame -from prompt_toolkit.formatted_text import HTML +from prompt_toolkit.widgets import Button, Frame from wui_components.jans_drop_down import DropDownWidget - from utils.utils import DialogUtils from utils.multi_lang import _ - class Plugin(DialogUtils): """This is a general class for plugins """ @@ -26,7 +17,7 @@ def __init__( """init for Plugin class "scim" Args: - app (_type_): _description_ + app (Generic): The main Application class """ self.app = app self.pid = 'scim' @@ -37,7 +28,6 @@ def __init__( body=HSplit([Button(text=_("Get Scim Configuration"), handler=self.get_app_config)], width=D()), height=D()) - def process(self) -> None: pass @@ -46,7 +36,6 @@ def set_center_frame(self) -> None: """ self.app.center_container = self.container - def create_widgets(self) -> None: """SCIM Application configuration widgets are created in this fonction """ @@ -87,7 +76,6 @@ def create_widgets(self) -> None: self.app.center_container = self.container - def get_app_config(self) -> None: """Gets SCIM application configurations from server. """ @@ -104,7 +92,6 @@ async def coroutine(): asyncio.ensure_future(coroutine()) - def save_app_config(self) -> None: """Save button handler for saving SCIM application configurations. Once configuration data was obtained from form, patch operations are prepared and saved to server. diff --git a/jans-cli-tui/cli_tui/plugins/040_config_api/main.py b/jans-cli-tui/cli_tui/plugins/040_config_api/main.py index 26d971eb0b0..238ae2a4c27 100755 --- a/jans-cli-tui/cli_tui/plugins/040_config_api/main.py +++ b/jans-cli-tui/cli_tui/plugins/040_config_api/main.py @@ -1,34 +1,22 @@ -import os -import sys from prompt_toolkit.application import Application -import prompt_toolkit - from prompt_toolkit.layout.containers import ( HSplit, VSplit, HorizontalAlign, DynamicContainer, - Window, ) from prompt_toolkit.application.current import get_app from prompt_toolkit.buffer import Buffer - from prompt_toolkit.layout.dimension import D -from prompt_toolkit.widgets import Button, Label, Frame from wui_components.jans_nav_bar import JansNavBar -from prompt_toolkit.layout.containers import HSplit, DynamicContainer, VSplit, Window -from prompt_toolkit.widgets import Button, Label, Frame, Box, Dialog +from prompt_toolkit.widgets import Button, Label, Box, Dialog from wui_components.jans_cli_dialog import JansGDialog from collections import OrderedDict from functools import partial -from typing import Any from wui_components.jans_vetrical_nav import JansVerticalNav from utils.multi_lang import _ from typing import Any, Optional -from utils.utils import DialogUtils -from utils.static import DialogResult import asyncio -from prompt_toolkit.widgets.base import RadioList class Plugin(): """This is a general class for plugins @@ -40,7 +28,7 @@ def __init__( """init for Plugin class "config_api" Args: - app (_type_): _description_ + app (Generic): The main Application class """ self.app = app self.pid = 'config_api' @@ -166,10 +154,6 @@ def create_widgets(self): self.nav_selection_changed(list(self.containers)[0]) - #--------------------------------------------------------------------------------# - #----------------------------------- accessroles --------------------------------# - #--------------------------------------------------------------------------------# - def get_adminui_roles(self) -> None: """Method to get the admin ui roles from server """ @@ -190,13 +174,9 @@ async def coroutine(): asyncio.ensure_future(coroutine()) - def adminui_update_roles(self, ) -> None: - """update the current clients data to server - - Args: - pattern (str, optional): endpoint arguments for the client data. Defaults to ''. + """update the current adminui-roles to server """ data =[] @@ -209,10 +189,6 @@ def adminui_update_roles(self, ] ) - # ------------------------------------------------------------------------------- # - # --------------------------------- View Data ----------------------------------- # - # ------------------------------------------------------------------------------- # - if data: clients = JansVerticalNav( myparent=self.app, @@ -238,9 +214,7 @@ def adminui_update_roles(self, self.app.show_message(_("Oops"), _("No matching result"), tobefocused=self.app.center_container) def add_adminui_roles(self) -> None: - """Method to display the dialog of clients - """ - """Method to display the dialog of clients + """Method to display the dialog of adminui-roles """ self.adminui_role = self.app.getTitledText( @@ -283,9 +257,8 @@ def save(dialog: Dialog) -> None: dialog = JansGDialog(self.app, title=_('Add New Role'), body=body, buttons=buttons, width=self.app.dialog_width-20) self.app.show_jans_dialog(dialog) - def edit_adminui_roles(self, **params: Any) -> None: - """Method to display the dialog of clients + """Method to display the dialog of admin-ui roles for editing """ role_data = params.get('data', {}) @@ -328,6 +301,8 @@ async def coroutine(): self.app.show_jans_dialog(dialog) def delete_adminui_roles(self, **kwargs: Any) -> None: + """Method to delete admin-ui roles + """ dialog = self.app.get_confirm_dialog(_("Are you sure want to delete adminui_roles :")+"\n {} ?".format(kwargs['selected'][0])) @@ -351,10 +326,6 @@ async def coroutine(): ## Need to add editable asyncio.ensure_future(coroutine()) - #--------------------------------------------------------------------------------# - #------------------------------------- permissions ------------------------------# - #--------------------------------------------------------------------------------# - def get_adminui_permissions(self, start_index: Optional[int]=0, pattern: Optional[str]= '' @@ -362,6 +333,7 @@ def get_adminui_permissions(self, """Method to get the adminui_permissions data from server Args: + start_index (Optional[int], optional): This is flag for the adminui-roles pages. Defaults to 0. pattern (str, optional): endpoint arguments for the client data. Defaults to ''. """ @@ -375,14 +347,14 @@ async def coroutine(): asyncio.ensure_future(coroutine()) - def adminui_update_permissions(self, start_index: Optional[int]=0, pattern: Optional[str]= '' ) -> None: """update the current adminui_permissions data to server - Args: + Args:. + start_index (Optional[int], optional): This is flag for the adminui-roles pages. Defaults to 0. pattern (str, optional): endpoint arguments for the client data. Defaults to ''. """ @@ -452,7 +424,7 @@ def adminui_update_permissions(self, self.app.show_message(_("Oops"), _("No matching result"), tobefocused=self.app.center_container) def add_adminui_permissions(self) -> None: - """Method to display the dialog of clients + """Method to display the dialog of adminui-roles """ self.adminui_permission = self.app.getTitledText( @@ -499,15 +471,19 @@ async def coroutine(): self.app.show_jans_dialog(dialog) def search_adminui_permissions(self, tbuffer:Buffer) -> None: + """This method handel the search for adminui_permissions + + Args: + tbuffer (Buffer): Buffer returned from the TextArea widget > GetTitleText + """ if not len(tbuffer.text) > 2: self.app.show_message(_("Error!"), _("Search string should be at least three characters"), tobefocused=self.app.center_container) return self.adminui_update_permissions(0, tbuffer.text) - def edit_adminui_permissions(self, **params: Any) -> None: - """Method to display the dialog of clients + """Method to display the dialog of adminui_permissions for editing """ role_data = params.get('passed', []) @@ -551,9 +527,12 @@ def save(dialog: Dialog) -> None: dialog = JansGDialog(self.app, title='admin ui permissions', body=body, buttons=buttons, width=self.app.dialog_width-20) self.app.show_jans_dialog(dialog) - def delete_adminui_permissions(self, **kwargs: Any) -> None: + """This method for the deletion of the adminui_permissions + Returns: + str: The server response + """ dialog = self.app.get_confirm_dialog(_("Are you sure want to delete adminui_permissions :")+"\n {} ?".format(kwargs['selected'][0])) @@ -581,10 +560,6 @@ async def coroutine(): asyncio.ensure_future(coroutine()) - #--------------------------------------------------------------------------------# - #------------------------------------- mapping ----------------------------------# - #--------------------------------------------------------------------------------# - def get_adminui_mapping(self, pattern: Optional[str]= '') -> None: """Method to get the adminui_permissions data from server """ @@ -652,6 +627,11 @@ def adminui_update_mapping(self, pattern: Optional[str]= '') -> None: self.app.show_message(_("Oops"), _("No matching result"), tobefocused=self.app.center_container) def search_adminui_mapping(self, tbuffer:Buffer,) -> None: + """This method handel the search for adminui_mapping + + Args: + tbuffer (Buffer): Buffer returned from the TextArea widget > GetTitleText + """ if not len(tbuffer.text) > 2: self.app.show_message(_("Error!"), _("Search string should be at least three characters"),tobefocused=self.containers['mapping']) return @@ -659,7 +639,7 @@ def search_adminui_mapping(self, tbuffer:Buffer,) -> None: self.adminui_update_mapping(tbuffer.text) def edit_adminui_mapping(self, **params: Any) -> None: - """Method to display the dialog of clients + """Method to display the dialog of adminui_mapping """ role_data = params.get('data', []) permission = role_data.get('role') @@ -713,10 +693,6 @@ def save(dialog: Dialog) -> None: dialog = JansGDialog(self.app, title='admin ui permissions', body=body, buttons=buttons, width=self.app.dialog_width-20) self.app.show_jans_dialog(dialog) - #--------------------------------------------------------------------------------# - #--------------------------------------------------------------------------------# - #--------------------------------------------------------------------------------# - def nav_selection_changed( self, selection: str