diff options
| author | Ralph Amissah <ralph@amissah.com> | 2013-04-07 22:18:03 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2013-04-07 22:18:03 -0400 | 
| commit | d2a0dcbc681948219391aa507742347756475905 (patch) | |
| tree | cf7bd4dbc5c4a5d0358b0b75c45b284a8a2d2251 | |
| parent | v4: options, exclude manifest links if no manifest (--no-manifest) selected (diff) | |
v4: zap, delete output files, based on given (existing) source file name
| -rw-r--r-- | data/doc/sisu/CHANGELOG_v4 | 2 | ||||
| -rw-r--r-- | lib/sisu/v4/hub.rb | 26 | ||||
| -rw-r--r-- | lib/sisu/v4/options.rb | 8 | ||||
| -rw-r--r-- | lib/sisu/v4/param.rb | 20 | ||||
| -rw-r--r-- | lib/sisu/v4/particulars.rb | 10 | ||||
| -rw-r--r-- | lib/sisu/v4/sysenv.rb | 94 | ||||
| -rw-r--r-- | lib/sisu/v4/zap.rb | 23 | 
7 files changed, 98 insertions, 85 deletions
| diff --git a/data/doc/sisu/CHANGELOG_v4 b/data/doc/sisu/CHANGELOG_v4 index e9813f01..4ac680cb 100644 --- a/data/doc/sisu/CHANGELOG_v4 +++ b/data/doc/sisu/CHANGELOG_v4 @@ -32,6 +32,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_4.0.19.orig.tar.xz  * v4: options, exclude manifest links if no manifest (--no-manifest) selected +* v4: zap, delete output files, based on given (existing) source file name +  %% 4.0.18.orig.tar.xz (2013-03-29:12/5)  http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_4.0.18  http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_4.0.18-1 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 | 
