Skip to content

Commit

Permalink
[ADD] manifestoo: select_addons_categories: allow to filter addons on…
Browse files Browse the repository at this point in the history
… given categories
  • Loading branch information
ThomasBinsfeld committed Nov 16, 2023
1 parent ee8e871 commit 60ecd0c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
]
readme = "README.md"
dependencies = [
"manifestoo_core >= 0.8",
"manifestoo_core >= 1.3",
"textual >= 0.6",
"typer[all] >= 0.3.2",
"importlib_metadata ; python_version<'3.8'",
Expand Down
8 changes: 8 additions & 0 deletions src/manifestoo/addons_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ def remove_addon_names(self, addon_names: str) -> None:
self.remove(addon_name)
except KeyError:
pass

def filter_categories(self, addons_categories: str, addons_set: AddonsSet) -> None:
categories_list = [category for category in comma_split(addons_categories)]
addons_list = list(self)
for addon_name in addons_list:
addon = addons_set.get(addon_name)
if addon and addon.manifest.category not in categories_list:
self.remove(addon_name)
13 changes: 13 additions & 0 deletions src/manifestoo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ def callback(
help="Exclude the Odoo core addons (CE and EE) for the given series.",
show_default=False,
),
filter_categories: Optional[str] = typer.Option(
None,
metavar="addon1,addon2,...",
help=(
"Comma separated list of addons categories to use as addons filter. "
"Filter out addons from the selected addons that don't belong to one "
"of these categories."
),
),
addons_path: Optional[str] = typer.Option(
None,
help="Expand addons path with this comma separated list of directories.",
Expand Down Expand Up @@ -210,6 +219,10 @@ def callback(
main_options.addons_selection.update(core_addons)
else:
main_options.addons_selection.difference_update(core_addons)
if filter_categories:
main_options.addons_selection.filter_categories(
filter_categories, main_options.addons_set
)
if main_options.addons_selection:
echo.info(str(main_options.addons_selection), bold_intro="Addons selection: ")
else:
Expand Down

0 comments on commit 60ecd0c

Please sign in to comment.