it kind of works now

This commit is contained in:
Lily Tsuru 2024-10-21 21:21:37 -04:00
parent 0eaca7d0c9
commit a997a356d2
6 changed files with 63 additions and 19 deletions

4
.gitignore vendored
View file

@ -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
View file

@ -0,0 +1,3 @@
[submodule "indicators"]
path = indicators
url = https://github.com/p-ranav/indicators

View file

@ -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

@ -0,0 +1 @@
Subproject commit 9c855c95e7782541a419597242535562fa9e41d7

3
python_refonly/README.md Normal file
View 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

View file

@ -1,10 +1,15 @@
#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;
@ -18,7 +23,25 @@ int main() {
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();
@ -53,11 +76,23 @@ int main() {
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