From 48ef624d3117bf5c1a175c65ce0499e1925b9114 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 31 Mar 2013 09:40:15 -0400 Subject: v4: sysenv, yamlrc cosmetic --- lib/sisu/v4/sysenv.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v4/sysenv.rb b/lib/sisu/v4/sysenv.rb index d77672a6..d9f2a080 100644 --- a/lib/sisu/v4/sysenv.rb +++ b/lib/sisu/v4/sysenv.rb @@ -336,18 +336,20 @@ module SiSU_Env break else f=S_CONF[:rc_yml] - if FileTest.exist?("#{v}/#{f}") + p_f="#{v}/#{f}" + if FileTest.exist?(p_f) require 'yaml' @@sisurc_path=v - @@rc=YAML::load(File::open("#{@@sisurc_path}/#{f}")) + @@rc=YAML::load(File::open(p_f)) break end unless @@rc f='sisurc.yaml' - if FileTest.exist?("#{v}/#{f}") + p_f="#{v}/#{f}" + if FileTest.exist?(p_f) require 'yaml' @@sisurc_path=v - @@rc=YAML::load(File::open("#{@@sisurc_path}/#{f}")) + @@rc=YAML::load(File::open(p_f)) break end end -- cgit v1.2.3 From 4b1d0dd6880e9dcf1056657119acce87e28a233d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 31 Mar 2013 10:07:26 -0400 Subject: v4: options, exclude manifest links if no manifest (--no-manifest) selected --- lib/sisu/v4/options.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/sisu/v4/options.rb b/lib/sisu/v4/options.rb index 0608df4e..896cfe0a 100644 --- a/lib/sisu/v4/options.rb +++ b/lib/sisu/v4/options.rb @@ -718,6 +718,9 @@ module SiSU_Commandline end act[:links_to_manifest]=if mod.inspect =~/"--inc-links-to-manifest"|"--inc-manifest-links"/ { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ + || act[:switch][:off].inspect =~/"manifest"/ #place lower + { bool: false, set: :off } elsif mod.inspect =~/"--(?:exc|no)-links-to-manifest"|"--(?:exc|no)-manifest-links"/ \ || act[:switch][:off].inspect =~/"links_to_manifest"|"manifest_links"|"--(?:exc|no)-manifest"/ \ || mod.inspect =~/"--(?:redirect|dump)/ -- cgit v1.2.3 From d2a0dcbc681948219391aa507742347756475905 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 7 Apr 2013 22:18:03 -0400 Subject: v4: zap, delete output files, based on given (existing) source file name --- lib/sisu/v4/hub.rb | 26 +++++-------- lib/sisu/v4/options.rb | 8 +--- lib/sisu/v4/param.rb | 20 ++-------- lib/sisu/v4/particulars.rb | 10 ++++- lib/sisu/v4/sysenv.rb | 94 +++++++++++++++++++++++++++++----------------- lib/sisu/v4/zap.rb | 23 +++++++----- 6 files changed, 96 insertions(+), 85 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v4/hub.rb b/lib/sisu/v4/hub.rb index 70a9fc9a..0691ff37 100644 --- a/lib/sisu/v4/hub.rb +++ b/lib/sisu/v4/hub.rb @@ -259,6 +259,9 @@ module SiSU @tell=lambda { SiSU_Screen::Ansi.new(@opt.cmd,@msg,"#{@msgs.inspect if @msgs}") } end def do_loops + if @opt.act[:zap][:set]==:on #% --zap, -Z + do_loop_files_on_given_option_pre + end do_each_file_loop_options do_loop_files_on_given_option_post end @@ -367,16 +370,15 @@ module SiSU end end end - def loop_files_on_given_option_pre_do - if @opt.act[:sisupod][:set]==:on #% --sisupod, -S make sisupod - require_relative 'sisupod_make' # -S sisupod_make.rb - begin + def do_loop_files_on_given_option_pre + begin + if @opt.act[:zap][:set]==:on #% --zap, -Z OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Doc::Source.new(@opt).read + require_relative 'zap' + SiSU_Zap::Source.new(@opt).read # -Z zap.rb end - ensure - SiSU_Doc::Source.new(@opt).sisupod_tar_xz end + ensure end end def do_loop_files_on_given_option_post @@ -479,12 +481,6 @@ module SiSU SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb end end - if @opt.act[:zap][:set]==:on #% --zap, -Z - # OptionLoopFiles.new(@opt).loop_files_on_given_option do - # require_relative 'zap' - # SiSU_Zap::Source.new(@opt).read # -Z zap.rb - # end - end if @opt.act[:manifest][:set]==:on #% --manifest, -y require_relative 'manifest' OptionLoopFiles.new(@opt).manifest_on_files_translated do @@ -580,10 +576,6 @@ module SiSU if @opt.act[:webrick][:set]==:on #% --webrick, -W webrick SiSU::Operations.new(@opt).webrick end - if @opt.act[:zap][:set]==:on #% --zap -Z wipe previous output clean DUPLICATE - #require_relative 'zap' - #SiSU_Zap::Source.new(@opt).read # -Z zap.rb - end if @opt.act[:dal][:set]==:on @retry_count= -1 begin diff --git a/lib/sisu/v4/options.rb b/lib/sisu/v4/options.rb index 896cfe0a..20499964 100644 --- a/lib/sisu/v4/options.rb +++ b/lib/sisu/v4/options.rb @@ -945,10 +945,6 @@ module SiSU_Commandline || mod.inspect =~/"--git"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } - act[:zap]=(cmd =~/Z/ \ - || mod.inspect =~/"--zap"|"--delete"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } act[:hash_digests]=(cmd =~/N/ \ || mod.inspect =~/"--hash-digests"/) \ ? { bool: true, set: :on } @@ -977,8 +973,8 @@ module SiSU_Commandline || mod.inspect =~/"--rsync"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } - act[:delete_output]=(cmd =~/z/ \ - || mod.inspect =~/"--delete"|"--zap"/) \ + act[:zap]=(cmd =~/Z/ \ + || mod.inspect =~/"--zap"|"--delete"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } act[:urls_all]=(cmd =~/U/ \ diff --git a/lib/sisu/v4/param.rb b/lib/sisu/v4/param.rb index 035697c9..b8e582eb 100644 --- a/lib/sisu/v4/param.rb +++ b/lib/sisu/v4/param.rb @@ -1320,7 +1320,8 @@ module SiSU_Param : papersize_array_rc fn=@opt.fno #decide what to do a filesize on .ssm tells very little about actual document size @filesize=(File.size(fn)).to_s - if @sys.openssl !=false + if @sys.openssl !=false \ + and FileTest.file?(@env.source_file_with_path) @dgst=[] if @env.digest.type =~/sha256/ dgst=@sys.sha256(@env.source_file_with_path) @@ -1331,6 +1332,8 @@ module SiSU_Param @dgst=dgst[1].length==32 ? dgst : nil puts 'check document (md5) digest' if not @dgst end + elsif not FileTest.file?(@env.source_file_with_path) + #puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:fuchsia) end @publisher ||= "#{@@publisher} (this copy)" fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language @@ -1345,23 +1348,8 @@ module SiSU_Param @language[:name]=fn_set_lang[:n] end @fnl=@env.i18n.lang_filename(fn_set_lang[:c]) -#fix -# @flv.each do |l| -# lang=SiSU_Env::StandardiseLanguage.new.file_to_language(l) -# c={ a: '', b: '', c: '' } -# if @fnl[:pre] =~/\S/ then c[:a]="#{lang[:c]}." -# elsif @fnl[:mid] =~/\S/ then c[:b]=".#{lang[:c]}" -# elsif @fnl[:post] =~/\S/ then c[:c]=".#{lang[:c]}" -# end -# @lang << [lang[:n],"#{c[:a]}sisu_manifest#{c[:b]}.html#{c[:c]}"] -# end if @flv @lang=@lang.uniq @fn=SiSU_Env::EnvCall.new(@fns).lang(fn_set_lang[:c]) - #if @identifier.is_a?(Array) - # @identifier[:sisupod]=sisupod_hash_value - #else @identifier={ sisupod: sisupod_hash_value } - #end - #"#{@env.url.root}/#{@fnb}/#{@fn[:toc]}" #DC note constructed dc identifier if @en[:note] > 0 \ and @en[:sum] > 0 if @en[:sum] > 0 diff --git a/lib/sisu/v4/particulars.rb b/lib/sisu/v4/particulars.rb index c893be0c..b7ea2f3a 100644 --- a/lib/sisu/v4/particulars.rb +++ b/lib/sisu/v4/particulars.rb @@ -207,8 +207,14 @@ module SiSU_Particulars @nametags_map=SiSU_DAL::Source.new(opt).get_map_nametags self rescue - SiSU_Errors::InfoError.new($!,$@,opt.cmd,opt.fnl).error do - __LINE__.to_s + ':' + __FILE__ + if @md + SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.opt.fnl).error do + __LINE__.to_s + ':' + __FILE__ + end + else + SiSU_Errors::InfoError.new($!,$@,opt.cmd,opt.fnl).error do + __LINE__.to_s + ':' + __FILE__ + end end end end diff --git a/lib/sisu/v4/sysenv.rb b/lib/sisu/v4/sysenv.rb index d9f2a080..400d53b0 100644 --- a/lib/sisu/v4/sysenv.rb +++ b/lib/sisu/v4/sysenv.rb @@ -3038,45 +3038,71 @@ WOK include FileUtils::Verbose def initialize(opt) @opt=opt - z=SiSU_Env::FileMap.new(@opt) - @zap=z.local_sisu_source - if @opt.cmd =~ /[hH]/ - @zap=Dir.glob(@zap).join(' ') - @zap=if @opt.cmd !~ /w/ - @zap.gsub(/#{@source_path}\/concordance.html/,'') - else @zap + z=SiSU_Env::FileMap.new(opt) + zap=z.local_sisu_source + if opt.cmd =~ /h/i + zap=Dir.glob(zap).join(' ') + @zap=if opt.cmd !~ /w/ + zap.gsub(/#{@source_path}\/concordance.html/,'') + else zap end end @env=SiSU_Env::InfoEnv.new end def zap - def main_output - (@zap !~/\/\//) \ - ? (FileUtils::rm_rf(@zap) if FileTest.directory?(@zap)) - : (puts 'suspect zap request, ignored') - end - def site_map - if @opt.fnb \ - and not @opt.fnb.empty? - sm="#{@env.path.output}/sitemaps/sitemap_#{@opt.fnb}.xml" - FileUtils::rm(sm) if FileTest.file?(sm) - end - end - def epub - if @opt.fnb \ - and not @opt.fnb.empty? - sm="#{@env.path.output}/epub/#{@opt.fnb}.epub" - FileUtils::rm(sm) if FileTest.file?(sm) - end - end - def src # consider - if @opt.fnb \ - and not @opt.fnb.empty? - sm="#{@env.path.output}/src/pod/#{@opt.fns}.txz" - FileUtils::rm(sm) if FileTest.file?(sm) - sm="#{@env.path.output}/src/#{@opt.fns}" - FileUtils::rm(sm) if FileTest.file?(sm) - end + def deletion(fn) + if FileTest.file?(fn)==true + File.delete(fn) + tell=SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns, 'remove: ' + fn) + tell.warn unless @opt.cmd =~/q/ + end + end + def remove_output + if @opt.act[:maintenance][:set] == :on + m=InfoFile.new(@opt.fnc) + tell=SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns, 'remove maintenance files from: ' + @env.processing_path.dal) + tell.warn unless @opt.cmd =~/q/ + deletion(m.marshal.dal_content) + deletion(m.marshal.dal_idx_sst_rel_html_seg) + deletion(m.dal_idx_sst_rel) + deletion(m.dal_idx_html) + deletion(m.dal_idx_xhtml) + deletion(m.dal_metadata) + deletion(m.dal_map_nametags) + deletion(m.dal_map_ocn_htmlseg) + deletion(m.html_tune) + end + md=SiSU_Param::Parameters.new(@opt).get + f=SiSU_Env::FileOp.new(md) + deletion(f.place_file.html_segtoc.dir) + deletion(f.place_file.html_scroll.dir) + deletion(f.place_file.html_book_index.dir) + deletion(f.place_file.html_concordance.dir) + deletion(f.place_file.epub.dir) + deletion("#{f.output_path.pdf.dir}/#{f.base_filename.pdf_p_letter}") + deletion("#{f.output_path.pdf.dir}/#{f.base_filename.pdf_l_letter}") + deletion("#{f.output_path.pdf.dir}/#{f.base_filename.pdf_p_a4}") + deletion("#{f.output_path.pdf.dir}/#{f.base_filename.pdf_l_a4}") + deletion("#{f.output_path.pdf.dir}/#{f.base_filename.pdf_p_a5}") + deletion("#{f.output_path.pdf.dir}/#{f.base_filename.pdf_l_a5}") + deletion("#{f.output_path.pdf.dir}/#{f.base_filename.pdf_p_b5}") + deletion("#{f.output_path.pdf.dir}/#{f.base_filename.pdf_l_b5}") + deletion("#{f.output_path.pdf.dir}/#{f.base_filename.pdf_p_legal}") + deletion("#{f.output_path.pdf.dir}/#{f.base_filename.pdf_p_legal}") + deletion(f.place_file.odt.dir) + deletion(f.place_file.xhtml.dir) + deletion(f.place_file.xml_sax.dir) + deletion(f.place_file.xml_dom.dir) + deletion(f.place_file.info.dir) + deletion(f.place_file.manpage.dir) + deletion(f.place_file.sqlite_discrete.dir) + deletion(f.place_file.txt.dir) + deletion(f.place_file.hash_digest.dir) + deletion(f.place_file.manifest.dir) + deletion(f.place_file.qrcode_md.dir) + deletion(f.place_file.qrcode_title.dir) + deletion(f.place_file.src.dir) + deletion(f.place_file.sisupod.dir) end self end diff --git a/lib/sisu/v4/zap.rb b/lib/sisu/v4/zap.rb index fbda244f..42f41fb7 100644 --- a/lib/sisu/v4/zap.rb +++ b/lib/sisu/v4/zap.rb @@ -66,20 +66,23 @@ module SiSU_Zap class Source def initialize(opt) @opt=opt - @env=SiSU_Env::InfoEnv.new(@opt.fns) - @zap_path="#{@env.path.output}/#{@env.fnb}" - @zap=SiSU_Env::CleanOutput.new(@opt) + @env=SiSU_Env::InfoEnv.new(opt.fns) end def read + zap_path="#{@env.path.output}/#{@env.fnb}" + z=SiSU_Env::CleanOutput.new(@opt) if SiSU_Env::InfoSettings.new.permission?('zap') - tell=SiSU_Screen::Ansi.new(@opt.cmd,"Clean files related to processing #{@opt.cmd} ->","#{@opt.fns} -> #{@zap_path}") - @zap.zap.main_output - @zap.zap.site_map - @zap.zap.epub - @zap.zap.src - else tell=SiSU_Screen::Ansi.new(@opt.cmd,'use of -Z (zap) has not enabled in sisurc.yml') + unless @opt.cmd =~/q/ + tell=SiSU_Screen::Ansi.new(@opt.cmd,"Clean files related to processing #{@opt.cmd} ->","#{@opt.fns} -> #{zap_path}") + tell.warn + end + z.zap.remove_output + else + unless @opt.cmd =~/q/ + tell=SiSU_Screen::Ansi.new(@opt.cmd,'use of -Z (zap) has not enabled in sisurc.yml') + tell.warn + end end - tell.warn unless @opt.cmd =~/q/ end end end -- cgit v1.2.3