/++
read configuration files
- read config files
meta_config_files.d
+/
module sdp.meta.read_config_files;
static template configInSite() {
import
sdp.meta,
sdp.output.paths_source,
std.file,
std.path;
final string configInSite(M,E)(M manifest, E env) {
auto conf_file_details = ConfigFilePaths!()(manifest, env);
string conf_sdl = conf_file_details.config_filename_site;
auto possible_config_path_locations = conf_file_details.possible_config_path_locations_local_site;
string config_file_str;
foreach(pth; possible_config_path_locations) {
auto conf_file = asNormalizedPath(chainPath(to!string(pth), conf_sdl)).array;
if (config_file_str.length > 0) {
break;
}
try {
if (exists(conf_file)) {
debug(configfile) {
writeln(conf_file);
}
config_file_str = conf_file.readText;
break;
}
}
catch (ErrnoException ex) {
}
catch (FileException ex) {
}
}
return config_file_str;
}
}
static template configInDoc() {
import
sdp.meta,
sdp.output.paths_source,
std.file,
std.path;
final string configInDoc(M,E)(M manifest, E env) {
auto conf_file_details = ConfigFilePaths!()(manifest, env);
string conf_sdl = conf_file_details.config_filename_document;
auto possible_config_path_locations = conf_file_details.possible_config_path_locations_document;
string config_file_str;
foreach(pth; possible_config_path_locations) {
auto conf_file = asNormalizedPath(chainPath(to!string(pth), conf_sdl)).array;
if (config_file_str.length > 0) {
break;
}
try {
if (exists(conf_file)) {
debug(configfile) {
writeln(conf_file);
}
config_file_str = conf_file.readText;
break;
}
}
catch (ErrnoException ex) {
}
catch (FileException ex) {
}
}
return config_file_str;
}
}
/+
+/
static template ConfigSDLang() {
import sdlang;
import
sdp.meta,
sdp.output.paths_source,
std.file,
std.path;
auto ConfigSDLang(string configuration, string conf_sdl_filename) {
Tag sdl_root_conf;
try {
sdl_root_conf = parseSource(configuration);
}
catch(ParseException e) {
stderr.writeln("SDLang problem with content for ", conf_sdl_filename);
stderr.writeln(e.msg);
}
return sdl_root_conf;
}
}
/+
+/
static template configReadSite() {
import
sdp.meta,
sdp.output.paths_source,
std.file,
std.path;
final auto configReadSite(M,E)(M manifest, E env) {
auto configuration = configInSite!()(manifest, env);
auto conf_file_details = ConfigFilePaths!()(manifest, env);
string conf_sdl = conf_file_details.config_filename_site;
auto sdl_root = ConfigSDLang!()(configuration, conf_sdl);
return sdl_root;
}
}
static template configReadDoc() {
import
sdp.meta,
sdp.output.paths_source,
std.file,
std.path;
final auto configReadDoc(M,E)(M manifest, E env) {
auto configuration = configInDoc!()(manifest, env);
auto conf_file_details = ConfigFilePaths!()(manifest, env);
string conf_sdl = conf_file_details.config_filename_document;
auto sdl_root = ConfigSDLang!()(configuration, conf_sdl);
return sdl_root;
}
}