Skip to content

Commit

Permalink
refactor!: rename on_callback_node to recursive_add
Browse files Browse the repository at this point in the history
  • Loading branch information
hearot committed Jun 13, 2020
1 parent dad5907 commit 461d34e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -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))
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion FEATURES.md
Expand Up @@ -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))
Expand All @@ -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))
2 changes: 1 addition & 1 deletion pyrubrum/__init__.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyrubrum/handlers/__init__.py
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pyrubrum/handlers/handler.py
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit 461d34e

Please sign in to comment.