corrected code to dispaly __init__ and __main__ files as well

This commit is contained in:
Falko Victor Habel 2025-01-19 22:32:48 +01:00
parent fb66c6f510
commit 9e3910e0f9
2 changed files with 14 additions and 3 deletions

View File

@ -1,3 +1,5 @@
import tree_structurer
from tree_structurer import create_tree_structurer, get_structure
tree_structurer.get_structure()
create_tree_structurer()
for file in get_structure():
print(file)

View File

@ -10,6 +10,11 @@ bool TreeStructurer::should_ignore_dir(const std::string& dirname) {
".git", ".idea", ".vscode", "__pycache__", "**pycache**"
};
// Check for __main__.py or __init__.py files
if (!dirname.empty() && (dirname == "__main__.py" || dirname == "__init__.py")) {
return false; // Do not ignore these files
}
if (std::find(ignore_list.begin(), ignore_list.end(), dirname) != ignore_list.end()) {
return true;
}
@ -26,13 +31,17 @@ bool TreeStructurer::should_ignore_dir(const std::string& dirname) {
return false;
}
// Add the missing should_ignore_file implementation
bool TreeStructurer::should_ignore_file(const std::string& filename) {
static const std::vector<std::string> ignore_extensions = {
".pyc", ".pyo", ".pyd", ".so", ".dll", ".dylib",
".o", ".obj", ".a", ".lib"
};
// Check for __main__.py or __init__.py files
if (!filename.empty() && (filename == "__main__.py" || filename == "__init__.py")) {
return false; // Do not ignore these files
}
if (!filename.empty() && (filename[0] == '.' || filename[0] == '_')) {
return true;
}