corrected code to dispaly __init__ and __main__ files as well
This commit is contained in:
parent
fb66c6f510
commit
9e3910e0f9
|
@ -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)
|
|
@ -10,6 +10,11 @@ bool TreeStructurer::should_ignore_dir(const std::string& dirname) {
|
||||||
".git", ".idea", ".vscode", "__pycache__", "**pycache**"
|
".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()) {
|
if (std::find(ignore_list.begin(), ignore_list.end(), dirname) != ignore_list.end()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -26,13 +31,17 @@ bool TreeStructurer::should_ignore_dir(const std::string& dirname) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the missing should_ignore_file implementation
|
|
||||||
bool TreeStructurer::should_ignore_file(const std::string& filename) {
|
bool TreeStructurer::should_ignore_file(const std::string& filename) {
|
||||||
static const std::vector<std::string> ignore_extensions = {
|
static const std::vector<std::string> ignore_extensions = {
|
||||||
".pyc", ".pyo", ".pyd", ".so", ".dll", ".dylib",
|
".pyc", ".pyo", ".pyd", ".so", ".dll", ".dylib",
|
||||||
".o", ".obj", ".a", ".lib"
|
".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] == '_')) {
|
if (!filename.empty() && (filename[0] == '.' || filename[0] == '_')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue