From d61236952f19c1a1107a11cf11874104c0fe1a9b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 14 Nov 2019 11:16:09 -0500 Subject: 0.8.3 (if exists) get site config & output path - read once & read early: - once per batch processing - early (needed by metadata --harvest) --- org/source_files_read.org | 57 +++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 24 deletions(-) (limited to 'org/source_files_read.org') diff --git a/org/source_files_read.org b/org/source_files_read.org index 8549cda..e182475 100644 --- a/org/source_files_read.org +++ b/org/source_files_read.org @@ -51,30 +51,42 @@ static template readConfigSite() { doc_reform.meta.rgx; <> mixin DocReformRgxInit; - final auto readConfigSite(M,E)(M _manifested, E _env) { + final auto readConfigSite(M,E)( + M _manifested, + E _env, + string _cli_config_path_set = "" + ) { static auto rgx = Rgx(); string config_file_str; string conf_filename = "NONE"; - auto _conf_file_details = ConfigFilePaths!()(_manifested, _env); + auto _conf_file_details = ConfigFilePaths!()(_manifested, _env, _cli_config_path_set); string[] possible_config_path_locations = _conf_file_details.possible_config_path_locations.config_local_site; foreach(conf_fn; [_conf_file_details.config_filename_site]) { foreach(pth; possible_config_path_locations) { - char[] conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array; + char[] conf_file; conf_filename = conf_fn; - if (config_file_str.length > 0) { - // conf_filename = conf_fn; - break; - } - try { - if (exists(conf_file)) { - debug(io) { - writeln("WARNING (io debug) in config file found: ", conf_file); + if (exists(pth)) { + auto f_attrib = pth.getLinkAttributes; + if ( + possible_config_path_locations.length == 1 + && f_attrib.attrIsFile + ) { + conf_file = pth.to!(char[]); + conf_filename = pth.baseName; + } else if (f_attrib.attrIsDir) { + conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array; + conf_filename = conf_fn; + } + try { + if (exists(conf_file)) { + if (conf_file.getLinkAttributes.attrIsFile) { + config_file_str = conf_file.readText; + break; + } } - config_file_str = conf_file.readText; - break; + } catch (ErrnoException ex) { + } catch (FileException ex) { } - } catch (ErrnoException ex) { - } catch (FileException ex) { } } if (config_file_str.length > 0) { break; } @@ -119,16 +131,14 @@ static template readConfigDoc() { auto conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array; conf_filename = conf_fn; if (config_file_str.length > 0) { - // conf_filename = conf_fn; break; } try { if (exists(conf_file)) { - debug(io) { - writeln("WARNING (io debug) in config file found: ", conf_file); + if (conf_file.getLinkAttributes.attrIsFile) { + config_file_str = conf_file.readText; + break; } - config_file_str = conf_file.readText; - break; } } catch (ErrnoException ex) { } catch (FileException ex) { @@ -182,7 +192,6 @@ static template configYAML() { #+BEGIN_SRC d static template configReadSiteYAML() { <> - import dyaml; final YAMLDocument configReadSiteYAML(M,E)(M _manifested, E _env) { string _configuration = configReadInSiteYAML!()(_manifested, _env); auto _conf_file_details = ConfigFilePaths!()(_manifested, _env); @@ -332,10 +341,10 @@ final private string readInMarkupSource(in char[] fn_src) { string source_txt_str; try { if (exists(fn_src)) { - debug(io) { - writeln("in src, markup source file found: ", fn_src); + if (fn_src.getLinkAttributes.attrIsFile) { + source_txt_str = fn_src.readText; + } else { } - source_txt_str = fn_src.readText; } } catch (ErrnoException ex) { } catch (UTFException ex) { -- cgit v1.2.3