Merge pull request 'fixed issue in display in terminal' (#23) from feat/final_display_fix into develop
Gitea Actions For prodir / Explore-Gitea-Actions (push) Successful in 22s
Details
Gitea Actions For prodir / Explore-Gitea-Actions (push) Successful in 22s
Details
Reviewed-on: #23
This commit is contained in:
commit
7022f16833
20
README.md
20
README.md
|
@ -93,19 +93,19 @@ my_project/
|
||||||
|
|
||||||
```plaintext
|
```plaintext
|
||||||
Analyzing directory: .\my_project\
|
Analyzing directory: .\my_project\
|
||||||
data/
|
├── data/
|
||||||
└── sample_data.csv
|
└── sample_data.csv
|
||||||
docs/
|
├── docs/
|
||||||
└── README.md
|
└── README.md
|
||||||
requirements.txt
|
├── requirements.txt
|
||||||
setup.py
|
├── setup.py
|
||||||
src/
|
├── src/
|
||||||
├── __init__.py
|
│ ├── __init__.py
|
||||||
├── main.py
|
│ ├── main.py
|
||||||
└── utils.py
|
└── utils.py
|
||||||
tests/
|
└── tests/
|
||||||
├── __init__.py
|
│ ├── __init__.py
|
||||||
├── test_main.py
|
│ ├── test_main.py
|
||||||
└── test_utils.py
|
└── test_utils.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "prodir"
|
name = "prodir"
|
||||||
version = "1.0.2"
|
version = "1.1.0"
|
||||||
description = "A module for analyzing and creating directory structures"
|
description = "A module for analyzing and creating directory structures"
|
||||||
scripts = {prodir = "prodir.__main__:main"}
|
scripts = {prodir = "prodir.__main__:main"}
|
||||||
dependencies = []
|
dependencies = []
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -20,7 +20,7 @@ tree_structurer_module = Extension(
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='prodir',
|
name='prodir',
|
||||||
version='1.0.2',
|
version='1.1.0',
|
||||||
description='A module for analyzing directory structures',
|
description='A module for analyzing directory structures',
|
||||||
ext_modules=[tree_structurer_module],
|
ext_modules=[tree_structurer_module],
|
||||||
packages=find_packages(where="src"),
|
packages=find_packages(where="src"),
|
||||||
|
|
|
@ -158,20 +158,68 @@ std::vector<std::string> TreeStructurer::get_directory_structure(const std::stri
|
||||||
is_last_per_level.push_back(false);
|
is_last_per_level.push_back(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if this is the last item at its level
|
|
||||||
bool is_last = (i == paths.size() - 1) ||
|
|
||||||
(i + 1 < paths.size() &&
|
|
||||||
fs::relative(paths[i + 1], start).begin()->string() != components[0]);
|
|
||||||
|
|
||||||
is_last_per_level[level] = is_last;
|
|
||||||
|
|
||||||
// Build the line prefix
|
// Build the line prefix
|
||||||
std::string line;
|
std::string line;
|
||||||
for (size_t j = 0; j < level; ++j) {
|
for (size_t j = 0; j <= level; ++j) {
|
||||||
if (j == level - 1) {
|
if (j == level) {
|
||||||
line += is_last ? "└── " : "├── ";
|
// This is the connector for the current item
|
||||||
|
bool is_last_sibling = true;
|
||||||
|
|
||||||
|
// Look ahead to find next sibling at the same level
|
||||||
|
for (size_t k = i + 1; k < paths.size(); ++k) {
|
||||||
|
fs::path next_relative = fs::relative(paths[k], start);
|
||||||
|
std::vector<std::string> next_components;
|
||||||
|
for (const auto& comp : next_relative) {
|
||||||
|
next_components.push_back(comp.string());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if it's a sibling (same parent, same level)
|
||||||
|
if (next_components.size() == components.size()) {
|
||||||
|
bool same_parent = true;
|
||||||
|
for (size_t l = 0; l < level; ++l) {
|
||||||
|
if (l >= next_components.size() || components[l] != next_components[l]) {
|
||||||
|
same_parent = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (same_parent) {
|
||||||
|
is_last_sibling = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
line += is_last_sibling ? "└── " : "├── ";
|
||||||
} else {
|
} else {
|
||||||
line += is_last_per_level[j] ? " " : "│ ";
|
// This is a vertical line for parent levels
|
||||||
|
bool needs_vertical_line = false;
|
||||||
|
|
||||||
|
// Check if there are future items that share this ancestor
|
||||||
|
for (size_t k = i + 1; k < paths.size(); ++k) {
|
||||||
|
fs::path next_relative = fs::relative(paths[k], start);
|
||||||
|
std::vector<std::string> next_components;
|
||||||
|
for (const auto& comp : next_relative) {
|
||||||
|
next_components.push_back(comp.string());
|
||||||
|
}
|
||||||
|
|
||||||
|
// If next item shares the same path up to level j
|
||||||
|
if (next_components.size() > j) {
|
||||||
|
bool shares_ancestor = true;
|
||||||
|
for (size_t l = 0; l <= j; ++l) {
|
||||||
|
if (l >= next_components.size() || l >= components.size() ||
|
||||||
|
components[l] != next_components[l]) {
|
||||||
|
shares_ancestor = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (shares_ancestor) {
|
||||||
|
needs_vertical_line = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
line += needs_vertical_line ? "│ " : " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,16 +138,16 @@ project/
|
||||||
|
|
||||||
# Define expected structure with proper tree markers
|
# Define expected structure with proper tree markers
|
||||||
expected_structure = [
|
expected_structure = [
|
||||||
"LICENSE",
|
"├── LICENSE",
|
||||||
"README.md",
|
"├── README.md",
|
||||||
"config/",
|
"├── config/",
|
||||||
" └── config.yaml",
|
" └── config.yaml",
|
||||||
"pyproject.toml",
|
"├── pyproject.toml",
|
||||||
"setup.py",
|
"├── setup.py",
|
||||||
"src/",
|
"└── src/",
|
||||||
"├── __init__.py",
|
"│ ├── __init__.py",
|
||||||
"├── main.py",
|
"│ ├── main.py",
|
||||||
"├── module1.py",
|
"│ ├── module1.py",
|
||||||
" └── module2.py"
|
" └── module2.py"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue