1+ from functools import partial
12from pathlib import Path
23from typing import Set
34
4- from polylith import check , deps , info
5+ from polylith import check , configuration , deps , info
6+
7+
8+ def _is_empty (brick : str , bricks_path : Path ) -> bool :
9+ path = bricks_path / brick
10+
11+ return not any (path .iterdir ())
12+
13+
14+ def _without_empty (
15+ root : Path , namespace : str , bricks : Set [str ], brick_type : str
16+ ) -> Set [str ]:
17+ theme = configuration .get_theme_from_config (root )
18+
19+ if theme == "loose" :
20+ bricks_path = root / f"{ brick_type } /{ namespace } "
21+ else :
22+ bricks_path = root / f"{ brick_type } "
23+
24+ return {brick for brick in bricks if not _is_empty (brick , bricks_path )}
525
626
727def _calculate (root : Path , namespace : str , project_data : dict , bases : Set [str ]) -> dict :
@@ -20,14 +40,16 @@ def _calculate(root: Path, namespace: str, project_data: dict, bases: Set[str])
2040 brick_diff = check .collect .diff (all_bricks , bases , components )
2141
2242 bases_diff = {b for b in brick_diff if b in all_bases }
23- components_diff = {b for b in brick_diff if b in all_components }
43+ comp_diff = {b for b in brick_diff if b in all_components }
44+
45+ fn = partial (_without_empty , root , namespace )
2446
2547 return {
2648 "name" : project_data ["name" ],
2749 "path" : project_data ["path" ],
2850 "is_project" : is_project ,
29- "bases" : bases_diff ,
30- "components" : components_diff ,
51+ "bases" : bases_diff if is_project else fn ( bases_diff , "bases" ) ,
52+ "components" : comp_diff if is_project else fn ( comp_diff , "components" ) ,
3153 "brick_imports" : brick_imports ,
3254 }
3355
0 commit comments