<commit_before>#include <yafray_config.h>
#include <cstdlib>
#include <cctype>
#include <algorithm>

#ifdef WIN32
	#include <windows.h>
#endif

#include <core_api/scene.h>
#include <core_api/environment.h>
#include <core_api/integrator.h>
#include <core_api/imagefilm.h>
#include <yafraycore/xmlparser.h>
#include <yaf_revision.h>
#include <utilities/console_utils.h>
#include <yafraycore/imageOutput.h>

#include <gui/yafqtapi.h>

using namespace::yafaray;

int main(int argc, char *argv[])
{
	std::string xmlLoaderVersion = "YafaRay XML loader version 0.2";

	cliParser_t parse(argc, argv, 2, 1, "You need to set at least a yafaray's valid XML file.");

	parse.setAppName(xmlLoaderVersion,
	"[OPTIONS]... <input xml file> [output filename]\n<input xml file> : A valid yafaray XML file\n[output filename] : The filename of the rendered image without extension.\n*Note: If output filename is ommited the name \"yafaray\" will be used instead.");

	parse.setOption("pp", "plugin-path", false, "Path to load plugins.");
	parse.setOption("vl", "verbosity-level", false, "Set verbosity level, options are:\n                                       0 - MUTE (Prints nothing)\n                                       1 - ERROR (Prints only errors)\n                                       2 - WARNING (Prints only errors and warnings)\n                                       3 - INFO (Prints all messages)\n");
	parse.parseCommandLine();

#ifdef RELEASE
	std::string version = std::string(VERSION);
#else
	std::string version = std::string(YAF_SVN_REV);
#endif

	renderEnvironment_t *env = new renderEnvironment_t();

	// Plugin load
	std::string ppath = parse.getOptionString("pp");
	int verbLevel = parse.getOptionInteger("vl");

	if (verbLevel >= 0) yafout.setMasterVerbosity(verbLevel);

	if (ppath.empty()) env->getPluginPath(ppath);

	if (!ppath.empty())
	{
		Y_INFO << "The plugin path is: " << ppath << yendl;
		env->loadPlugins(ppath);
	}
	else
	{
		Y_ERROR << "Getting plugin path from render environment failed!" << yendl;
		return 1;
	}

	std::vector<std::string> formats = env->listImageHandlers();

	std::string formatString = "";
	for (size_t i = 0; i < formats.size(); i++)
	{
		formatString.append("                                       " + formats[i]);
		if (i < formats.size() - 1) formatString.append("\n");
	}

	parse.setOption("v", "version", true, "Displays this program's version.");
	parse.setOption("h", "help", true, "Displays this help text.");
	parse.setOption("op", "output-path", false, "Uses the path in <value> as rendered image output path.");
	parse.setOption("o", "output-file", false, "Uses the path in <value> as rendered image output filename.");
	parse.setOption("f", "format", false, "Sets the output image format, available formats are:\n\n" + formatString + "\n                                       Default: tga.\n");
	parse.setOption("t", "threads", false, "Overrides threads setting on the XML file, for auto selection use -1.");
	parse.setOption("a", "with-alpha", true, "Enables saving the image with alpha channel.");
	parse.setOption("dp", "draw-params", true, "Enables saving the image with a settings badge.");
	parse.setOption("ndp", "no-draw-params", true, "Disables saving the image with a settings badge (warning: this overrides --draw-params setting).");
	parse.setOption("cs", "custom-string", false, "Sets the custom string to be used on the settings badge.");
	parse.setOption("z", "z-buffer", true, "Enables the rendering of the depth map (Z-Buffer) (this flag overrides XML setting).");
	parse.setOption("nz", "no-z-buffer", true, "Disables the rendering of the depth map (Z-Buffer) (this flag overrides XML setting).");

	bool parseOk = parse.parseCommandLine();

	if (parse.getFlag("h"))
	{
		parse.printUsage();
		return 0;
	}

	if (parse.getFlag("v"))
	{
		Y_INFO << xmlLoaderVersion << yendl << "Built with YafaRay version " << version << yendl;
		return 0;
	}

	if (!parseOk)
	{
		parse.printError();
		parse.printUsage();
		return 0;
	}

	bool alpha = parse.getFlag("a");
	std::string format = parse.getOptionString("f");
	std::string outputPath = parse.getOptionString("op");
	std::string outputFilename = parse.getOptionString("o");
	int threads = parse.getOptionInteger("t");
	bool drawparams = parse.getFlag("dp");
	bool nodrawparams = parse.getFlag("ndp");
	std::string customString = parse.getOptionString("cs");
	bool zbuf = parse.getFlag("z");
	bool nozbuf = parse.getFlag("nz");

	if (format.empty()) format = "tga";
	bool formatValid = false;

	for (size_t i = 0; i < formats.size(); i++)
	{
		if (formats[i].find(format) != std::string::npos) formatValid = true;
	}

	if (!formatValid)
	{
		Y_ERROR << "Couldn't find any valid image format, image handlers missing?" << yendl;
		return 1;
	}

	const std::vector<std::string> files = parse.getCleanArgs();

	if (files.size() == 0)
	{
		return 0;
	}

	std::string outName;
	if (outputFilename.empty())
	{
		outName = "yafray." + format;
	}
	else
	{
		outName = outputFilename + "." + format;
	}
	
    std::string outName;
    if(outputFilename.empty())
        outName = "yafray." + format;
    else
        outName = outputFilename;
	
	if(files.size() > 1) outName = files[1] + "." + format;
	
	std::string xmlFile = files[0];
	
	//env->Debug = debug; //disabled until proper debugging messages are set throughout the core<commit_msg>Review code from 'rubdos' patch:     - set only the file name, the extension is set with parsing 'f' option<commit_after>#include <yafray_config.h>
#include <cstdlib>
#include <cctype>
#include <algorithm>

#ifdef WIN32
	#include <windows.h>
#endif

#include <core_api/scene.h>
#include <core_api/environment.h>
#include <core_api/integrator.h>
#include <core_api/imagefilm.h>
#include <yafraycore/xmlparser.h>
#include <yaf_revision.h>
#include <utilities/console_utils.h>
#include <yafraycore/imageOutput.h>

#include <gui/yafqtapi.h>

using namespace::yafaray;

int main(int argc, char *argv[])
{
	std::string xmlLoaderVersion = "YafaRay XML loader version 0.2";

	cliParser_t parse(argc, argv, 2, 1, "You need to set at least a yafaray's valid XML file.");

	parse.setAppName(xmlLoaderVersion,
		"[OPTIONS]... <input xml file> [output filename]\n<input xml file> : A valid yafaray XML file\n[output filename] : The filename of the rendered image without extension.\n*Note: If output filename is ommited the name \"yafaray\" will be used instead.");

	parse.setOption("pp", "plugin-path", false, "Path to load plugins.");
	parse.setOption("vl", "verbosity-level", false, "Set verbosity level, options are:\n                                       0 - MUTE (Prints nothing)\n                                       1 - ERROR (Prints only errors)\n                                       2 - WARNING (Prints only errors and warnings)\n                                       3 - INFO (Prints all messages)\n");
	parse.parseCommandLine();

#ifdef RELEASE
	std::string version = std::string(VERSION);
#else
	std::string version = std::string(YAF_SVN_REV);
#endif

	renderEnvironment_t *env = new renderEnvironment_t();

	// Plugin load
	std::string ppath = parse.getOptionString("pp");
	int verbLevel = parse.getOptionInteger("vl");

	if (verbLevel >= 0) yafout.setMasterVerbosity(verbLevel);

	if (ppath.empty()) env->getPluginPath(ppath);

	if (!ppath.empty())
	{
		Y_INFO << "The plugin path is: " << ppath << yendl;
		env->loadPlugins(ppath);
	}
	else
	{
		Y_ERROR << "Getting plugin path from render environment failed!" << yendl;
		return 1;
	}

	std::vector<std::string> formats = env->listImageHandlers();

	std::string formatString = "";
	for (size_t i = 0; i < formats.size(); i++)
	{
		formatString.append("                                       " + formats[i]);
		if (i < formats.size() - 1) formatString.append("\n");
	}

	parse.setOption("v", "version", true, "Displays this program's version.");
	parse.setOption("h", "help", true, "Displays this help text.");
	parse.setOption("op", "output-path", false, "Uses the path in <value> as rendered image output path.");
	parse.setOption("o", "output-file", false, "Uses the path in <value> as rendered image output filename.");
	parse.setOption("f", "format", false, "Sets the output image format, available formats are:\n\n" + formatString + "\n                                       Default: tga.\n");
	parse.setOption("t", "threads", false, "Overrides threads setting on the XML file, for auto selection use -1.");
	parse.setOption("a", "with-alpha", true, "Enables saving the image with alpha channel.");
	parse.setOption("dp", "draw-params", true, "Enables saving the image with a settings badge.");
	parse.setOption("ndp", "no-draw-params", true, "Disables saving the image with a settings badge (warning: this overrides --draw-params setting).");
	parse.setOption("cs", "custom-string", false, "Sets the custom string to be used on the settings badge.");
	parse.setOption("z", "z-buffer", true, "Enables the rendering of the depth map (Z-Buffer) (this flag overrides XML setting).");
	parse.setOption("nz", "no-z-buffer", true, "Disables the rendering of the depth map (Z-Buffer) (this flag overrides XML setting).");

	bool parseOk = parse.parseCommandLine();

	if (parse.getFlag("h"))
	{
		parse.printUsage();
		return 0;
	}

	if (parse.getFlag("v"))
	{
		Y_INFO << xmlLoaderVersion << yendl << "Built with YafaRay version " << version << yendl;
		return 0;
	}

	if (!parseOk)
	{
		parse.printError();
		parse.printUsage();
		return 0;
	}

	bool alpha = parse.getFlag("a");
	std::string format = parse.getOptionString("f");
	std::string outputPath = parse.getOptionString("op");
	std::string outputFilename = parse.getOptionString("o");
	int threads = parse.getOptionInteger("t");
	bool drawparams = parse.getFlag("dp");
	bool nodrawparams = parse.getFlag("ndp");
	std::string customString = parse.getOptionString("cs");
	bool zbuf = parse.getFlag("z");
	bool nozbuf = parse.getFlag("nz");

	if (format.empty()) format = "tga";
	bool formatValid = false;

	for (size_t i = 0; i < formats.size(); i++)
	{
		if (formats[i].find(format) != std::string::npos) formatValid = true;
	}

	if (!formatValid)
	{
		Y_ERROR << "Couldn't find any valid image format, image handlers missing?" << yendl;
		return 1;
	}

	const std::vector<std::string> files = parse.getCleanArgs();

	if (files.size() == 0)
	{
		return 0;
	}

	std::string outName;
	if (outputFilename.empty())
	{
		outName = "yafray." + format;
	}
	else
	{
		outName = outputFilename + "." + format;
	}
	
	std::string outName;
	if (outputFilename.empty())
	{
		outName = "yafray." + format;
	}
	else
	{
		outName = outputFilename + "." + format;
	}
	
	if(files.size() > 1) outName = files[1] + "." + format;
	
	std::string xmlFile = files[0];
	
	//env->Debug = debug; //disabled until proper debugging messages are set throughout the core
{'fraction_non_alphanumeric': 0.15303478904515175, 'fraction_numerical': 0.0046262028127313105, 'mean_word_length': 3.69140625, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3717757', 'n_tokens_mistral': 3641, 'n_tokens_neox': 3454, 'n_words': 1010}