diff options
| -rw-r--r-- | lib/sisu/v1/db_import.rb | 4 | ||||
| -rw-r--r-- | lib/sisu/v2/db_import.rb | 75 | 
2 files changed, 32 insertions, 47 deletions
| diff --git a/lib/sisu/v1/db_import.rb b/lib/sisu/v1/db_import.rb index 7e96d7d5..036f446e 100644 --- a/lib/sisu/v1/db_import.rb +++ b/lib/sisu/v1/db_import.rb @@ -912,8 +912,8 @@ module SiSU_DB_import          or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@opt.fns}.tgz")==true)            f[:sisupod],u[:sisupod]='sisupod,', "'#{base}/#@fnb/#{@opt.fns}.tgz',"          end -      t=SiSU_DB_tuple::Load_urls.new(@conn,f,u,@@id_t,@opt,@file) -      tuple=t.tuple +        t=SiSU_DB_tuple::Load_urls.new(@conn,f,u,@@id_t,@opt,@file) +        tuple=t.tuple        rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error        ensure        end diff --git a/lib/sisu/v2/db_import.rb b/lib/sisu/v2/db_import.rb index c2ce648c..e5c05040 100644 --- a/lib/sisu/v2/db_import.rb +++ b/lib/sisu/v2/db_import.rb @@ -126,7 +126,7 @@ module SiSU_DB_import        end        if (@sql_type!~/sqlite/ and not file_exist) \        or @sql_type=~/sqlite/ -        t_d=[] # transaction_data +        t_d=[]                                                              # transaction_data          t_d << db_import_metadata          t_d << db_import_documents(@dal_array)          t_d << db_import_urls(@dal_array,@fnc)                              #import OID on/off @@ -199,6 +199,7 @@ module SiSU_DB_import        str.gsub!(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg))(?:\s+\d+x\d+)?(.+?)#{Mx[:lnk_c]}\S+/,'[image: \1] \2')        str.gsub!(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}(?:file|ftp):\/\/\S+?([.,!?]?(?:\s|$))/,'\1\2')        str.gsub!(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,'\1') +      str      end      def strip_markup(str) #define rules, make same as in dal clean        str.gsub!(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]') @@ -211,6 +212,7 @@ module SiSU_DB_import        str.gsub!(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [image]') # else image names found in search        str.gsub!(/\s\s+/,' ')        str.strip! +      str      end      def pf_db_import_transaction_open      end @@ -460,10 +462,8 @@ module SiSU_DB_import      def db_import_documents(dal_array)                                     #% import documents - populate main database table, import into substantive database tables (tuple)        begin          @col[:tid]=@@id_t -        @en,@en_ast,@en_pls=[],[],[] -        @col[:en_a]=nil -        @col[:en_z]=nil -        @tuple_array=[] +        @en,@en_ast,@en_pls,@tuple_array=[],[],[],[] +        @col[:en_a],@col[:en_z]=nil,nil          dal_array.each do |data|            data.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1')            data.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1') @@ -633,8 +633,8 @@ module SiSU_DB_import                @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0]                @col[:body]=if data.is=='table'                  SiSU_Format_Shared::CSS_Format.new(@md,data).html_table -             elsif defined? data.indent and data.indent =~/[1-9]/ -               SiSU_Format_Shared::CSS_Format.new(@md,data).indent(data.indent) +              elsif defined? data.indent and data.indent =~/[1-9]/ +                SiSU_Format_Shared::CSS_Format.new(@md,data).indent(data.indent)                else                  SiSU_Format_Shared::CSS_Format.new(@md,data).norm                end @@ -655,9 +655,10 @@ module SiSU_DB_import                      nr,txt,digest_clean=$1,$2.strip,0                    end                    @id_n+=1 -                  body=SiSU_Format_Shared::CSS_Format.new(@md,data).endnote(nr,txt) -                  special_character_escape(body)                    special_character_escape(txt) +                  body=SiSU_Format_Shared::CSS_Format.new(@md,data).endnote(nr,txt) +                  #special_character_escape(body) +                  #special_character_escape(txt)                    strip_markup(txt)                    if txt.size > (endnote_clean - 1)                      puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" @@ -694,8 +695,8 @@ module SiSU_DB_import                      nr,txt,digest_clean=$1,$2.strip,0                    end                    @id_n+=1 -                  body=SiSU_Format_Shared::CSS_Format.new(@md,data).endnote(nr,txt)                    special_character_escape(txt) +                  body=SiSU_Format_Shared::CSS_Format.new(@md,data).endnote(nr,txt)                    strip_markup(txt)                    if txt.size > (endnote_clean - 1)                      puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" @@ -732,8 +733,8 @@ module SiSU_DB_import                      nr,txt,digest_clean=$1,$2.strip,0                    end                    @id_n+=1 -                  body=SiSU_Format_Shared::CSS_Format.new(@md,data).endnote(nr,txt)                    special_character_escape(txt) +                  body=SiSU_Format_Shared::CSS_Format.new(@md,data).endnote(nr,txt)                    strip_markup(txt)                    if txt.size > (endnote_clean - 1)                      puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" @@ -825,72 +826,56 @@ module SiSU_DB_import          or @fnb.nil?            p 'file output path error' #remove          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:plain]}")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:plain]}")==true            f[:txt],u[:txt]='plaintext,', "'#{base}/#{@fnb}/#{@md.fn[:plain]}',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:toc]}")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:toc]}")==true            f[:html_toc],u[:html_toc]='html_toc,', "'#{base}/#{@fnb}/#{@md.fn[:toc]}',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:doc]}")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:doc]}")==true            f[:html_doc],u[:html_doc]='html_doc,', "'#{base}/#{@fnb}/#{@md.fn[:doc]}',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:xhtml]}")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:xhtml]}")==true            f[:xhtml],u[:xhtml]='xhtml,', "'#{base}/#{@fnb}/#{@md.fn[:xhtml]}',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:sax]}")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:sax]}")==true            f[:xml_sax],u[:xml_sax]='xml_sax,', "'#{base}/#{@fnb}/#{@md.fn[:sax]}',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:dom]}")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:dom]}")==true            f[:xml_dom],u[:xml_dom]='xml_dom,', "'#{base}/#{@fnb}/#{@md.fn[:dom]}',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:odf]}")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:odf]}")==true            f[:odf],u[:odf]='odf,', "'#{base}/#{@fnb}/#{@md.fn[:odf]}',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:pdf_p]}")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:pdf_p]}")==true            f[:pdf_p],u[:pdf_p]='pdf_p,', "'#{base}/#{@fnb}/#{@md.fn[:pdf_p]}',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:pdf_l]}")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:pdf_l]}")==true            f[:pdf_l],u[:pdf_l]='pdf_l,', "'#{base}/#{@fnb}/#{@md.fn[:pdf_l]}',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:concordance]}")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:concordance]}")==true            f[:concordance],u[:concordance]='concordance,', "'#{base}/#{@fnb}/#{@md.fn[:concordance]}',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.tex")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.tex")==true            f[:latex_p],u[:latex_p]='latex_p,', "'#{base}/#{@fnb}/#{@opt.fns}.tex',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.landscape.tex")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.landscape.tex")==true            f[:latex_l],u[:latex_l]='latex_l,', "'#{base}/#{@fnb}/#{@opt}.fns}.landscape.tex',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:digest]}")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:digest]}")==true            f[:digest],u[:digest]='digest,', "'#{base}/#{@fnb}/#{@md.fn[:digest]}',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:manifest]}")==true) #revisit, was to be text, this is html +        if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:manifest]}")==true #revisit, was to be text, this is html            f[:manifest],u[:manifest]='manifest,', "'#{base}/#{@fnb}/#{@md.fn[:manifest]}',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.meta")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.meta")==true            f[:markup],u[:markup]='markup,', "'#{base}/#{@fnb}/#{@opt.fns}.meta',"          end -        if @opt.cmd !~/e/ \ -        or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.tgz")==true) +        if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.tgz")==true            f[:sisupod],u[:sisupod]='sisupod,', "'#{base}/#{@fnb}/#{@opt.fns}.tgz',"          end -      t=SiSU_DB_tuple::Load_urls.new(@conn,f,u,@@id_t,@opt,@file) -      tuple=t.tuple +        t=SiSU_DB_tuple::Load_urls.new(@conn,f,u,@@id_t,@opt,@file) +        tuple=t.tuple        rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error        ensure        end | 
