From edd89902036bde18c91031470e19c871a182cf6d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 23 Oct 2013 23:40:45 -0400 Subject: v5: options & downstream, more use of opt.act instead of opt.cmd * opt.act.*.set==:on instead of opt.cmd =~/\S/ --- lib/sisu/v5/db_import.rb | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'lib/sisu/v5/db_import.rb') diff --git a/lib/sisu/v5/db_import.rb b/lib/sisu/v5/db_import.rb index bcb22de8..6edb0f99 100644 --- a/lib/sisu/v5/db_import.rb +++ b/lib/sisu/v5/db_import.rb @@ -74,7 +74,7 @@ module SiSU_DbImport attr_accessor :tp def initialize(opt,conn,file_maint,sql_type='pg') @opt,@conn,@file_maint,@sql_type=opt,conn,file_maint,sql_type - @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX + @cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX @env=SiSU_Env::InfoEnv.new(@opt.fns) @dal="#{@env.processing_path.dal}" @fnb=if @opt.fns.empty? \ @@ -102,7 +102,7 @@ module SiSU_DbImport ? @conn.execute( sql ).join.to_i : @conn.execute( sql ) { |x| x.fetch_all.flatten[0] } rescue - puts "#{__FILE__}:#{__LINE__}" if @opt.cmd =~/M/ + puts "#{__FILE__}:#{__LINE__}" if @opt.act[:maintenance][:set]==:on end @col[:lid]=0 if @col[:lid].nil? or @col[:lid].to_s.empty? sql='SELECT MAX(nid) FROM endnotes' @@ -112,7 +112,7 @@ module SiSU_DbImport : @id_n=@conn.execute( sql ) { |x| x.fetch_all.flatten[0] } @id_n ||=0 rescue - puts "#{__FILE__}:#{__LINE__}" if @opt.cmd =~/M/ + puts "#{__FILE__}:#{__LINE__}" if @opt.act[:maintenance][:set]==:on end @id_n =0 if @col[:lid].nil? or @col[:lid].to_s.empty? @col[:lv1]=@col[:lv2]=@col[:lv3]=@col[:lv4]=@col[:lv5]=@col[:lv6]=0 @@ -123,8 +123,12 @@ module SiSU_DbImport def marshal_load require_relative 'dal' # dal.rb @dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here - SiSU_Screen::Ansi.new(@opt.cmd,"#{@db.psql.db}::#{@opt.fns}").puts_blue if @opt.cmd =~/vVM/ - SiSU_Screen::Ansi.new(@opt.cmd,'Marshal Load',@fnc).puts_grey if @opt.cmd =~/v/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"#{@db.psql.db}::#{@opt.fns}").puts_blue + end + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Marshal Load',@fnc).puts_grey if @opt.act[:verbose][:set]==:on #% select_first_match=%{ SELECT metadata_and_text.tid @@ -141,7 +145,8 @@ module SiSU_DbImport t_d << db_import_documents(@dal_array) t_d << db_import_urls(@dal_array,@fnc) #import OID on/off t_d=t_d.flatten - if @opt.cmd =~/[MV]/ + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) puts @conn.class if defined? @conn.class puts @conn.driver_name if defined? @conn.driver_name puts @conn.driver if defined? @conn.driver @@ -178,7 +183,7 @@ module SiSU_DbImport sql=File.new(sqlfn,'w') t_d.each {|i| sql.puts i} p sqlfn - if @opt.cmd =~/M/ + if @opt.act[:maintenance][:set]==:on puts sql p @conn.methods.sort puts "#{__FILE__}:#{__LINE__}" @@ -191,7 +196,7 @@ module SiSU_DbImport sql=File.new(sqlfn,'w') t_d.each {|i| sql.puts i} p sqlfn - if @opt.cmd =~/M/ + if @opt.act[:maintenance][:set]==:on puts sql p @conn.methods.sort puts "#{__FILE__}:#{__LINE__}" @@ -230,7 +235,11 @@ module SiSU_DbImport book_idx_str end def db_import_metadata #% import documents - populate database - print %{ #{@cX.grey}import documents dbi_unit #{@cX.off} } if @opt.cmd =~/vVM/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + print %{ #{@cX.grey}import documents dbi_unit #{@cX.off} } + end @tp={} @md=SiSU_Param::Parameters.new(@opt).get #% sisutxt & fulltxt @@ -259,10 +268,14 @@ module SiSU_DbImport end @@id_t=id_t if id_t rescue - puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ + puts "#{__FILE__} #{__LINE__}" if @opt.act[:maintenance][:set]==:on end @@id_t+=1 #bug related, needs to be performed once at start of file, but consider moving, as, placed here it means program will fail if document header lacks @title: - puts %{\n#{@cX.grey}Processing file number#{@cX.off}: #{@cX.green}#{@@id_t}#{@@cX.off}} if @opt.cmd =~/vVM/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + puts %{\n#{@cX.grey}Processing file number#{@cX.off}: #{@cX.green}#{@@id_t}#{@@cX.off}} + end end ################ CLEAR ############## SiSU_DbDBI::Test.new(self,@opt).verify #% import title names, filenames (tuple) -- cgit v1.2.3