36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
"""Utility functions shared across backend modules."""
|
|
from typing import Dict, Any, Tuple
|
|
|
|
|
|
def should_include_path(rel_parts: Tuple[str, ...], vault_config: Dict[str, Any]) -> bool:
|
|
"""Check if a path should be included based on hidden files configuration.
|
|
|
|
Args:
|
|
rel_parts: Tuple of path parts relative to vault root
|
|
vault_config: Vault configuration dict with includeHidden and hiddenWhitelist
|
|
|
|
Returns:
|
|
True if the path should be included, False otherwise
|
|
"""
|
|
include_hidden = vault_config.get("includeHidden", False)
|
|
hidden_whitelist = vault_config.get("hiddenWhitelist", [])
|
|
|
|
# Check if any part of the path starts with a dot (hidden)
|
|
hidden_parts = [part for part in rel_parts if part.startswith(".")]
|
|
|
|
if not hidden_parts:
|
|
# No hidden parts, always include
|
|
return True
|
|
|
|
if include_hidden:
|
|
# Include all hidden files/folders
|
|
return True
|
|
|
|
# Check if any hidden part is in the whitelist
|
|
for hidden_part in hidden_parts:
|
|
if hidden_part in hidden_whitelist:
|
|
return True
|
|
|
|
# Not in whitelist and includeHidden is False
|
|
return False
|