From 461d34e9fb293347ca0b38aa41a18511c25b857c Mon Sep 17 00:00:00 2001 From: Hearot Date: Sat, 13 Jun 2020 15:14:37 +0200 Subject: [PATCH] refactor!: rename `on_callback_node` to `recursive_add` --- CHANGELOG.md | 3 ++- FEATURES.md | 3 ++- pyrubrum/__init__.py | 2 +- pyrubrum/handlers/__init__.py | 2 +- pyrubrum/handlers/handler.py | 8 ++++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e70735..5edf75b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ ### New features - - Do not pass parameters to content functions if not supported + - Do not pass parameters to content functions if not supported ([dad5907521d635701cbea12ac736b4f0362e41e6](https://github.com/hearot/pyrubrum/commit/dad5907521d635701cbea12ac736b4f0362e41e6)) - Import all the public functions ([c0a7deb30fbe75d6b8c37f71dcaaa49ba8b3ab8f](https://github.com/hearot/pyrubrum/commit/c0a7deb30fbe75d6b8c37f71dcaaa49ba8b3ab8f)) - Import database errors by default ([eb6bb8b5320676e1f474097e3738d54ddddb31e7](https://github.com/hearot/pyrubrum/commit/eb6bb8b5320676e1f474097e3738d54ddddb31e7)) - Support providing multiple preliminary functions ([3938e308c2176bd280454cdab1875abbae470a28](https://github.com/hearot/pyrubrum/commit/3938e308c2176bd280454cdab1875abbae470a28)) @@ -34,6 +34,7 @@ - Create specific directories for module entities ([25593e6d40fa34dbc47528ff3fa6fdc30c0a41b9](https://github.com/hearot/pyrubrum/commit/25593e6d40fa34dbc47528ff3fa6fdc30c0a41b9)) - Preliminary functions are now passed as arguments (resolve #6) ([45687a4a0a2b407b8085ec78d008536bd598897a](https://github.com/hearot/pyrubrum/commit/45687a4a0a2b407b8085ec78d008536bd598897a)) + - Rename `on_callback_node` to `recursive_add` - `BaseDatabase.get` always returns a string (resolve #2) ([b1d0dac010d2d0cd46a4bcc41d2f07c2099d6ac9](https://github.com/hearot/pyrubrum/commit/b1d0dac010d2d0cd46a4bcc41d2f07c2099d6ac9)) ## v0.1a1.dev5 - 2020-06-12 diff --git a/FEATURES.md b/FEATURES.md index ecdfab6..ab1b35a 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -4,7 +4,7 @@ ### New features - - Do not pass parameters to content functions if not supported + - Do not pass parameters to content functions if not supported ([dad5907521d635701cbea12ac736b4f0362e41e6](https://github.com/hearot/pyrubrum/commit/dad5907521d635701cbea12ac736b4f0362e41e6)) - Import all the public functions ([c0a7deb30fbe75d6b8c37f71dcaaa49ba8b3ab8f](https://github.com/hearot/pyrubrum/commit/c0a7deb30fbe75d6b8c37f71dcaaa49ba8b3ab8f)) - Import database errors by default ([eb6bb8b5320676e1f474097e3738d54ddddb31e7](https://github.com/hearot/pyrubrum/commit/eb6bb8b5320676e1f474097e3738d54ddddb31e7)) - Support providing multiple preliminary functions ([3938e308c2176bd280454cdab1875abbae470a28](https://github.com/hearot/pyrubrum/commit/3938e308c2176bd280454cdab1875abbae470a28)) @@ -19,4 +19,5 @@ - Create specific directories for module entities ([25593e6d40fa34dbc47528ff3fa6fdc30c0a41b9](https://github.com/hearot/pyrubrum/commit/25593e6d40fa34dbc47528ff3fa6fdc30c0a41b9)) - Preliminary functions are now passed as arguments (resolve #6) ([45687a4a0a2b407b8085ec78d008536bd598897a](https://github.com/hearot/pyrubrum/commit/45687a4a0a2b407b8085ec78d008536bd598897a)) + - Rename `on_callback_node` to `recursive_add` - `BaseDatabase.get` always returns a string (resolve #2) ([b1d0dac010d2d0cd46a4bcc41d2f07c2099d6ac9](https://github.com/hearot/pyrubrum/commit/b1d0dac010d2d0cd46a4bcc41d2f07c2099d6ac9)) diff --git a/pyrubrum/__init__.py b/pyrubrum/__init__.py index 4261eac..96c0674 100644 --- a/pyrubrum/__init__.py +++ b/pyrubrum/__init__.py @@ -35,7 +35,7 @@ from .database.errors import SetError # noqa from .handlers import BaseHandler # noqa from .handlers import Handler # noqa -from .handlers import on_callback_node # noqa +from .handlers import recursive_add # noqa from .handlers import ParameterizedBaseHandler # noqa from .handlers import ParameterizedHandler # noqa from .handlers import pass_handler # noqa diff --git a/pyrubrum/handlers/__init__.py b/pyrubrum/handlers/__init__.py index b2eb978..2cab17d 100644 --- a/pyrubrum/handlers/__init__.py +++ b/pyrubrum/handlers/__init__.py @@ -19,7 +19,7 @@ from .base_handler import BaseHandler # noqa from .base_handler import pass_handler # noqa from .handler import Handler # noqa -from .handler import on_callback_node # noqa +from .handler import recursive_add # noqa from .handler import transform # noqa from .parameterized_base_handler import ParameterizedBaseHandler # noqa from .parameterized_base_handler import pass_handler_and_clean # noqa diff --git a/pyrubrum/handlers/handler.py b/pyrubrum/handlers/handler.py index b463abf..96b3703 100644 --- a/pyrubrum/handlers/handler.py +++ b/pyrubrum/handlers/handler.py @@ -116,7 +116,7 @@ def setup(self, client: Client): ) -def on_callback_node(menus: MenuIterable, parent: Node): +def recursive_add(menus: MenuIterable, parent: Node): """Link the provided menus to `Node` instances and add these ones to a provided parent. Finally, for each found value which is iterable, this function is called in a recursive way in order to link its elements to its parent @@ -135,13 +135,13 @@ def on_callback_node(menus: MenuIterable, parent: Node): parent.add_child(node) if isinstance(menus, dict) and isinstance(menus[menu], Iterable): - on_callback_node(menus[menu], node) + recursive_add(menus[menu], node) def transform(menus: MenuIterable) -> Node: """Transform an iterable compounded of menus into a `Node` object. If a dictionary is provided as argument, its values will be transformed as - well and added as children using ``on_callback_node``. + well and added as children using ``recursive_add``. Args: menus (Union[Dict[BaseMenu, Any], Iterable[BaseMenu]]): The iterable @@ -155,6 +155,6 @@ def transform(menus: MenuIterable) -> Node: main_value = list(menus.values())[0] if isinstance(menus, dict) else None if main_value: - on_callback_node(main_value, main_node) + recursive_add(main_value, main_node) return main_node