From 02714184258c9be072857ddcc03bc114b2e843d1 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 22 Oct 2019 19:32:45 -0400 Subject: cosmetic --- src/doc_reform/doc_reform.d | 347 +++++++++++++++++++------------------------- 1 file changed, 150 insertions(+), 197 deletions(-) (limited to 'src/doc_reform/doc_reform.d') diff --git a/src/doc_reform/doc_reform.d b/src/doc_reform/doc_reform.d index e6a9b59..708c96a 100755 --- a/src/doc_reform/doc_reform.d +++ b/src/doc_reform/doc_reform.d @@ -269,65 +269,31 @@ void main(string[] args) { return opts["epub"]; } bool harvest() { - bool _is = ( - opts["harvest"] - || opts["harvest-authors"] - || opts["harvest-topics"] - ) - ? true : false; - return _is; + return (opts["harvest"] || opts["harvest-authors"] || opts["harvest-topics"]) ? true : false; } bool harvest_authors() { - bool _is = ( - opts["harvest"] - || opts["harvest-authors"] - ) - ? true : false; - return _is; + return (opts["harvest"] || opts["harvest-authors"]) ? true : false; } bool harvest_topics() { - bool _is = ( - opts["harvest"] - || opts["harvest-topics"] - ) - ? true : false; - return _is; + return (opts["harvest"] || opts["harvest-topics"]) ? true : false; } bool html() { - bool _is; - if ( opts["html"] || opts["html-seg"] || opts["html-scroll"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["html"] || opts["html-seg"] || opts["html-scroll"]) ? true : false; } bool html_seg() { - bool _is; - if ( opts["html"] || opts["html-seg"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["html"] || opts["html-seg"]) ? true : false; } bool html_scroll() { - bool _is; - if ( opts["html"] || opts["html-scroll"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["html"] || opts["html-scroll"]) ? true : false; } bool html_stuff() { - bool _is; - if (opts["html"] || opts["html-scroll"] || opts["html-seg"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["html"] || opts["html-scroll"] || opts["html-seg"]) ? true : false; } bool latex() { - bool _is; - if ( opts["latex"] || opts["pdf"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["latex"] || opts["pdf"]) ? true : false; } bool odt() { - bool _is; - if ( opts["odf"] || opts["odt"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["odf"] || opts["odt"]) ? true : false; } bool manifest() { return opts["manifest"]; @@ -366,44 +332,31 @@ void main(string[] args) { return opts["sqlite-discrete"]; } bool sqlite_db_drop() { - bool _is; - if ( opts["sqlite-db-recreate"] || opts["sqlite-db-drop"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["sqlite-db-recreate"] || opts["sqlite-db-drop"]) ? true : false; } bool sqlite_db_create() { - bool _is; - if ( opts["sqlite-db-recreate"] || opts["sqlite-db-create"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["sqlite-db-recreate"] || opts["sqlite-db-create"]) ? true : false; } bool sqlite_delete() { return opts["sqlite-delete"]; } bool sqlite_update() { - bool _is; - if (opts["sqlite-update"] || opts["sqlite-insert"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["sqlite-update"] || opts["sqlite-insert"]) ? true : false; } bool sqlite_shared_db_action() { - bool _is; - if (opts["sqlite-db-recreate"] + return ( + opts["sqlite-db-recreate"] || opts["sqlite-db-create"] || opts["sqlite-delete"] || opts["sqlite-insert"] || opts["sqlite-update"] - ) { _is = true; } else { _is = false; } - return _is; + ) ? true : false; } bool text() { return opts["text"]; } bool verbose() { - bool _is; - if (opts["verbose"] || opts["very-verbose"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["verbose"] || opts["very-verbose"]) ? true : false; } bool very_verbose() { return opts["very-verbose"]; @@ -458,7 +411,8 @@ void main(string[] args) { } else if (opts["parallel"] == false && opts["serial"] == true) { _is = false; - } else if (opts["abstraction"] + } else if ( + opts["abstraction"] || concordance || harvest || html @@ -505,8 +459,8 @@ void main(string[] args) { return schedule.sort().uniq; } bool abstraction() { - bool _is; - if (opts["abstraction"] + return ( + opts["abstraction"] || concordance || source_or_pod || harvest @@ -518,31 +472,28 @@ void main(string[] args) { || sqlite_discrete || sqlite_delete || sqlite_update - ) { _is = true; } else { _is = false; } - return _is; + ) ? true : false; } bool meta_processing_general() { - bool _is; - if (opts["abstraction"] + return ( + opts["abstraction"] || html || epub || odt || latex || sqlite_discrete || sqlite_update - ) { _is = true; } else { _is = false; } - return _is; + ) ? true :false; } bool meta_processing_xml_dom() { - bool _is; - if (opts["abstraction"] + return ( + opts["abstraction"] || html || epub || odt || sqlite_discrete || sqlite_update - ) { _is = true; } else { _is = false; } - return _is; + ) ? true : false; } } auto _opt_action = OptActions(); @@ -576,77 +527,110 @@ void main(string[] args) { "pwd" : environment["PWD"], "home" : environment["HOME"], ]; - auto _manifest_matter = PathMatters!()(_opt_action, _env, ""); - auto _manifests = [ _manifest_matter ]; + auto _manifested = PathMatters!()(_opt_action, _env, ""); + auto _manifests = [ _manifested ]; ConfCompositePlus _make_and_meta_struct_tst; foreach(arg; args[1..$]) { - _manifest_matter = PathMatters!()(_opt_action, _env, arg); // gather input markup source file names for processing - auto _config_local_site_struct = readConfigSite!()(_manifest_matter, _env); - { /+ local site config +/ - if (_config_local_site_struct.filetype == "yaml") { - import doc_reform.meta.conf_make_meta_yaml; - _make_and_meta_struct_tst = _config_local_site_struct.configParseYAMLreturnDocReformStruct!()(_make_and_meta_struct_tst, _manifest_matter); - } - } auto _manifest_start = PodManifest!()(arg); - if (arg.match(rgx.flag_action)) { + if (arg.match(rgx.flag_action)) { /+ cli instruction, flag do +/ flag_action ~= " " ~ arg; // flags not taken by getopt - } else if ( - !(arg.match(rgx.src_pth_sst_or_ssm)) - && _manifest_start.pod_manifest_file_with_path - && _opt_action.abstraction - ) { - string pod_manifest_root_content_paths_to_markup_location_raw_; - string markup_contents_location_; - string sisudoc_txt_ = _manifest_start.pod_manifest_file_with_path; - enforce( - exists(sisudoc_txt_)!=0, - "file not found: «" ~ - sisudoc_txt_ ~ "»" - ); - if (exists(sisudoc_txt_)) { - try { - if (exists(sisudoc_txt_)) { - import dyaml; - try { - Node pod_manifest_yaml = Loader.fromFile(sisudoc_txt_).load(); - if ("doc" in pod_manifest_yaml) { - if (pod_manifest_yaml["doc"].type.mapping - && pod_manifest_yaml["doc"].tag.match(rgx.yaml_tag_is_map) - ) { - if ("path" in pod_manifest_yaml["doc"]) { - if (pod_manifest_yaml["doc"]["path"].tag.match(rgx.yaml_tag_is_seq)) { - foreach (string _path; pod_manifest_yaml["doc"]["path"]) { - markup_contents_location_ ~= _path ~ "\n"; - pod_manifest_root_content_paths_to_markup_location_raw_ ~= - _path ~ "\n"; + } else { /+ cli, assumed to be path to source files +/ + _manifested = PathMatters!()(_opt_action, _env, arg); // gather input markup source file names for processing + auto _config_local_site_struct = readConfigSite!()(_manifested, _env); + { /+ local site config +/ + if (_config_local_site_struct.filetype == "yaml") { + import doc_reform.meta.conf_make_meta_yaml; + _make_and_meta_struct_tst = _config_local_site_struct.configParseYAMLreturnDocReformStruct!()(_make_and_meta_struct_tst, _manifested); + } + } + if ( /+ pod files +/ + !(arg.match(rgx.src_pth_sst_or_ssm)) + && _manifest_start.pod_manifest_file_with_path + && _opt_action.abstraction + ) { + string pod_manifest_root_content_paths_to_markup_location_raw_; + string markup_contents_location_; + string sisudoc_txt_ = _manifest_start.pod_manifest_file_with_path; + enforce( + exists(sisudoc_txt_)!=0, + "file not found: «" ~ + sisudoc_txt_ ~ "»" + ); + if (exists(sisudoc_txt_)) { + try { + if (exists(sisudoc_txt_)) { + import dyaml; + try { + Node pod_manifest_yaml = Loader.fromFile(sisudoc_txt_).load(); + if ("doc" in pod_manifest_yaml) { + if (pod_manifest_yaml["doc"].type.mapping + && pod_manifest_yaml["doc"].tag.match(rgx.yaml_tag_is_map) + ) { + if ("path" in pod_manifest_yaml["doc"]) { + if (pod_manifest_yaml["doc"]["path"].tag.match(rgx.yaml_tag_is_seq)) { + foreach (string _path; pod_manifest_yaml["doc"]["path"]) { + markup_contents_location_ ~= _path ~ "\n"; + pod_manifest_root_content_paths_to_markup_location_raw_ ~= + _path ~ "\n"; + } + } else if ( + pod_manifest_yaml["doc"]["path"].type.string + && pod_manifest_yaml["doc"]["path"].tag.match(rgx.yaml_tag_is_str) + ) { + markup_contents_location_ = pod_manifest_yaml["doc"]["path"].get!string; + pod_manifest_root_content_paths_to_markup_location_raw_ = + pod_manifest_yaml["doc"]["path"].get!string; } - } else if ( - pod_manifest_yaml["doc"]["path"].type.string - && pod_manifest_yaml["doc"]["path"].tag.match(rgx.yaml_tag_is_str) - ) { - markup_contents_location_ = pod_manifest_yaml["doc"]["path"].get!string; - pod_manifest_root_content_paths_to_markup_location_raw_ = - pod_manifest_yaml["doc"]["path"].get!string; } - } - if ("filename" in pod_manifest_yaml["doc"]) { - if (pod_manifest_yaml["doc"]["filename"].tag.match(rgx.yaml_tag_is_seq)) { - foreach (string _filename; pod_manifest_yaml["doc"]["filename"]) { + if ("filename" in pod_manifest_yaml["doc"]) { + if (pod_manifest_yaml["doc"]["filename"].tag.match(rgx.yaml_tag_is_seq)) { + foreach (string _filename; pod_manifest_yaml["doc"]["filename"]) { + if ("language" in pod_manifest_yaml["doc"]) { + if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_seq)) { + foreach (string _lang; pod_manifest_yaml["doc"]["language"]) { + markup_contents_location_ ~= + "media/text/" + ~ _lang ~ "/" + ~ _filename ~ "\n"; + } + } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_str) + ) { + markup_contents_location_ = + "media/text/" + ~ pod_manifest_yaml["doc"]["language"].get!string + ~ "/" ~ _filename ~ "\n"; + } else { + string _lang_default = "en"; + markup_contents_location_ ~= + "media/text/" + ~ _lang_default ~ "/" + ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; + } + } else { + string _lang_default = "en"; + markup_contents_location_ ~= + "media/text/" + ~ _lang_default ~ "/" + ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; + } + } + } else if ( + pod_manifest_yaml["doc"]["filename"].type.string + && pod_manifest_yaml["doc"]["filename"].tag.match(rgx.yaml_tag_is_str) + ) { if ("language" in pod_manifest_yaml["doc"]) { if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_seq)) { foreach (string _lang; pod_manifest_yaml["doc"]["language"]) { markup_contents_location_ ~= "media/text/" ~ _lang ~ "/" - ~ _filename ~ "\n"; + ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; } - } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_str) - ) { + } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_str)) { markup_contents_location_ = "media/text/" ~ pod_manifest_yaml["doc"]["language"].get!string - ~ "/" ~ _filename ~ "\n"; + ~ "/" ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; } else { string _lang_default = "en"; markup_contents_location_ ~= @@ -662,81 +646,50 @@ void main(string[] args) { ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; } } - } else if ( - pod_manifest_yaml["doc"]["filename"].type.string - && pod_manifest_yaml["doc"]["filename"].tag.match(rgx.yaml_tag_is_str) - ) { - if ("language" in pod_manifest_yaml["doc"]) { - if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_seq)) { - foreach (string _lang; pod_manifest_yaml["doc"]["language"]) { - markup_contents_location_ ~= - "media/text/" - ~ _lang ~ "/" - ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; - } - } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_str)) { - markup_contents_location_ = - "media/text/" - ~ pod_manifest_yaml["doc"]["language"].get!string - ~ "/" ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; - } else { - string _lang_default = "en"; - markup_contents_location_ ~= - "media/text/" - ~ _lang_default ~ "/" - ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; - } - } else { - string _lang_default = "en"; - markup_contents_location_ ~= - "media/text/" - ~ _lang_default ~ "/" - ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; - } } } } - } - } catch (ErrnoException ex) { + } catch (ErrnoException ex) { + } } + } catch (ErrnoException ex) { + } catch (FileException ex) { + // Handle errors } - } catch (ErrnoException ex) { - } catch (FileException ex) { - // Handle errors + } else { + writeln("manifest not found: ", sisudoc_txt_); } - } else { - writeln("manifest not found: ", sisudoc_txt_); - } - auto markup_contents_locations_arr - = (cast(char[]) markup_contents_location_).split; - auto tmp_dir_ = (sisudoc_txt_).dirName.array; - foreach (markup_contents_location; markup_contents_locations_arr) { - assert(markup_contents_location.match(rgx.src_pth_sst_or_ssm), - "not a recognised file: «" ~ - markup_contents_location ~ "»" - ); - auto markup_contents_location_pth_ = (markup_contents_location).to!string; - Regex!(char) lang_rgx_ = regex(r"/(" ~ _opt_action.languages_set.join("|") ~ ")/"); - if (_opt_action.languages_set[0] == "all" - || (markup_contents_location_pth_).match(lang_rgx_) - ) { - auto _fns = (((tmp_dir_).chainPath(markup_contents_location_pth_)).array).to!string; - _manifest_matter = PathMatters!()(_opt_action, _env, arg, _fns, markup_contents_locations_arr); - _manifests ~= _manifest_matter; + auto markup_contents_locations_arr + = (cast(char[]) markup_contents_location_).split; + auto tmp_dir_ = (sisudoc_txt_).dirName.array; + foreach (markup_contents_location; markup_contents_locations_arr) { + assert(markup_contents_location.match(rgx.src_pth_sst_or_ssm), + "not a recognised file: «" ~ + markup_contents_location ~ "»" + ); + auto markup_contents_location_pth_ = (markup_contents_location).to!string; + Regex!(char) lang_rgx_ = regex(r"/(" ~ _opt_action.languages_set.join("|") ~ ")/"); + if (_opt_action.languages_set[0] == "all" + || (markup_contents_location_pth_).match(lang_rgx_) + ) { + auto _fns = (((tmp_dir_).chainPath(markup_contents_location_pth_)).array).to!string; + _manifested = PathMatters!()(_opt_action, _env, arg, _fns, markup_contents_locations_arr); + _manifests ~= _manifested; + } } + } else if (arg.match(rgx.src_pth_sst_or_ssm)) { /+ markup txt files +/ + if (exists(arg)==0) { + writeln("ERROR >> Processing Skipped! File not found: ", arg); + } else { + _manifested = PathMatters!()(_opt_action, _env, arg, arg); + _manifests ~= _manifested; + } + } else if (arg.match(rgx.src_pth_zip)) { + // fns_src ~= arg; // gather input markup source file names for processing + } else { // anything remaining, unused + arg_unrecognized ~= " " ~ arg; } - } else if (arg.match(rgx.src_pth_sst_or_ssm)) { - if (exists(arg)==0) { - writeln("ERROR >> Processing Skipped! File not found: ", arg); - } else { - _manifest_matter = PathMatters!()(_opt_action, _env, arg, arg); - _manifests ~= _manifest_matter; - } - } else if (arg.match(rgx.src_pth_zip)) { - // fns_src ~= arg; // gather input markup source file names for processing - } else { // anything remaining, unused - arg_unrecognized ~= " " ~ arg; } } if (!(_opt_action.skip_output)) { -- cgit v1.2.3