it kind of works now
This commit is contained in:
parent
0eaca7d0c9
commit
a997a356d2
6 changed files with 63 additions and 19 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,5 +1,7 @@
|
||||||
__pycache__/
|
/__pycache__
|
||||||
|
/.cache
|
||||||
*.o
|
*.o
|
||||||
/vxorg
|
/vxorg
|
||||||
/tree_test
|
/tree_test
|
||||||
/testdata
|
/testdata
|
||||||
|
/compile_commands.json
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "indicators"]
|
||||||
|
path = indicators
|
||||||
|
url = https://github.com/p-ranav/indicators
|
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
||||||
CXX = g++ -std=c++23 -O3
|
CXX = g++ -std=c++23 -O3 -I indicators/include
|
||||||
|
|
||||||
all: vxorg tree_test
|
all: vxorg tree_test
|
||||||
|
|
||||||
|
|
1
indicators
Submodule
1
indicators
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 9c855c95e7782541a419597242535562fa9e41d7
|
3
python_refonly/README.md
Normal file
3
python_refonly/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# python
|
||||||
|
|
||||||
|
This was the original vxorg refactor/rewrite. It was abanodoned because the tree algorithms in python were so unbearably slow that even a iffy c++ reimplementation of the same tree is 100x faster
|
69
vxorg.cpp
69
vxorg.cpp
|
@ -1,24 +1,47 @@
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <indicators/progress_bar.hpp>
|
||||||
|
#include <indicators/terminal_size.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "indicators/terminal_size.hpp"
|
||||||
#include "tree.hpp"
|
#include "tree.hpp"
|
||||||
#include "vxheaven_parse.hpp"
|
#include "vxheaven_parse.hpp"
|
||||||
|
|
||||||
|
namespace ind = indicators;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::ifstream ifs("./testdata/samples.sort");
|
std::ifstream ifs("./testdata/samples.sort");
|
||||||
vxorg::VxHeavenTree tree;
|
vxorg::VxHeavenTree tree;
|
||||||
|
|
||||||
vxorg::parse_into_tree(tree, ifs);
|
vxorg::parse_into_tree(tree, ifs);
|
||||||
|
|
||||||
std::filesystem::path root = std::filesystem::current_path() / "testdata";
|
std::filesystem::path root = std::filesystem::current_path() / "testdata";
|
||||||
std::filesystem::path unorg = root / "unorg";
|
std::filesystem::path unorg = root / "unorg";
|
||||||
std::filesystem::path org = root / "org";
|
std::filesystem::path org = root / "org";
|
||||||
|
|
||||||
if(!std::filesystem::exists(org))
|
if(!std::filesystem::exists(org))
|
||||||
std::filesystem::create_directories(org);
|
std::filesystem::create_directories(org);
|
||||||
|
|
||||||
// walk the resulting tree
|
std::size_t sampleCount = 0;
|
||||||
|
|
||||||
|
// Walk the tree to get the amount of sample nodes
|
||||||
|
tree.walk([&](auto* node) {
|
||||||
|
if(node->data().is_sample)
|
||||||
|
sampleCount++;
|
||||||
|
});
|
||||||
|
|
||||||
|
ind::ProgressBar bar { ind::option::BarWidth { indicators::terminal_width() - 64 },
|
||||||
|
ind::option::Start { "[" },
|
||||||
|
ind::option::Fill { "■" },
|
||||||
|
ind::option::Lead { "■" },
|
||||||
|
ind::option::Remainder { "-" },
|
||||||
|
ind::option::End { " ]" },
|
||||||
|
ind::option::ForegroundColor { ind::Color::cyan },
|
||||||
|
ind::option::FontStyles { std::vector<ind::FontStyle> { ind::FontStyle::bold } },
|
||||||
|
ind::option::MaxProgress { sampleCount } };
|
||||||
|
|
||||||
|
// Walk the tree to perform the operation
|
||||||
tree.walk([&](auto* node) {
|
tree.walk([&](auto* node) {
|
||||||
auto tabulation_level = node->parent_count();
|
auto tabulation_level = node->parent_count();
|
||||||
auto& data = node->data();
|
auto& data = node->data();
|
||||||
|
@ -44,22 +67,34 @@ int main() {
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
||||||
if(!node->is_root()) {
|
if(!node->is_root()) {
|
||||||
if(data.is_sample) {
|
if(data.is_sample) {
|
||||||
std::string sample_name = vxorg::get_sample_name(node);
|
std::string sample_name = vxorg::get_sample_name(node);
|
||||||
|
|
||||||
// paths
|
// paths
|
||||||
auto path = org / vxorg::get_sample_path(node);
|
auto path = org / vxorg::get_sample_path(node);
|
||||||
auto source_path = unorg / vxorg::get_sample_name(node);
|
auto source_path = unorg / vxorg::get_sample_name(node);
|
||||||
|
|
||||||
if(!std::filesystem::exists(source_path)) {
|
if(!std::filesystem::exists(source_path)) {
|
||||||
std::printf("WARNING: sample %s/%s in tree (source disk file %s) does not exist\n", path.string().c_str(), sample_name.c_str(), source_path.string().c_str());
|
std::printf("WARNING: sample %s/%s in tree (source disk file %s) does not exist\n", path.string().c_str(), sample_name.c_str(),
|
||||||
}
|
source_path.string().c_str());
|
||||||
|
} else {
|
||||||
|
if(!std::filesystem::exists(path)) {
|
||||||
|
std::filesystem::create_directories(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
bar.set_option(ind::option::PostfixText { std::format("Moving {}", sample_name) });
|
||||||
|
|
||||||
//std::printf("sample %s/%s in tree (source disk file %s)\n", path.string().c_str(), sample_name.c_str(), source_path.string().c_str());
|
// FIXME Make this a move
|
||||||
}
|
std::filesystem::copy_file(source_path, path / vxorg::get_sample_name(node));
|
||||||
}
|
|
||||||
|
bar.tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
// std::printf("sample %s/%s in tree (source disk file %s)\n", path.string().c_str(), sample_name.c_str(),
|
||||||
|
// source_path.string().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue