From 33417c59a25d9c68698d319d298da1fecaec1673 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 3 Jun 2012 14:28:19 -0400 Subject: v3: warn when files to be copied not found, add --- lib/sisu/v3/conf.rb | 21 +++++++++++++++------ lib/sisu/v3/odf.rb | 10 ++++++++-- lib/sisu/v3/share_src.rb | 11 ++++++++--- lib/sisu/v3/shared_images.rb | 31 +++++++++++++++++-------------- lib/sisu/v3/sisupod_make.rb | 13 ++++++++++--- lib/sisu/v3/sysenv.rb | 17 +++++++++++++---- 6 files changed, 71 insertions(+), 32 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/conf.rb b/lib/sisu/v3/conf.rb index 51aeb005..8a323ac4 100644 --- a/lib/sisu/v3/conf.rb +++ b/lib/sisu/v3/conf.rb @@ -172,8 +172,11 @@ module SiSU_Initialize schema=SiSU_Env::SystemCall.new(rnc_src,rng_file) schema.relaxng(@opt.cmd) #rnc - FileUtils::cp(rnc_src,rnc_file) - FileUtils::chmod(0644,rnc_file) + if FileTest.file?(rnc_src) + FileUtils::cp(rnc_src,rnc_file) + FileUtils::chmod(0644,rnc_file) + else STDERR.puts %{\t*WARN* did not find rnc - "#{rnc_src}" [#{__FILE__}:#{__LINE__}]} + end end def trang_rnc_model_output_dom s=@suffix @@ -191,8 +194,11 @@ module SiSU_Initialize schema=SiSU_Env::SystemCall.new(rnc_src,rng_file) schema.relaxng(@opt.cmd) #rnc - FileUtils::cp(rnc_src,rnc_file) - FileUtils::chmod(0644,rnc_file) + if FileTest.file?(rnc_src) + FileUtils::cp(rnc_src,rnc_file) + FileUtils::chmod(0644,rnc_file) + else STDERR.puts %{\t*WARN* did not find rnc - "#{rnc_src}" [#{__FILE__}:#{__LINE__}]} + end end def trang_rnc_model_output_xhtml s=@suffix @@ -210,8 +216,11 @@ module SiSU_Initialize schema=SiSU_Env::SystemCall.new(rnc_src,rng_file) schema.relaxng(@opt.cmd) #rnc - FileUtils::cp(rnc_src,rnc_file) - FileUtils::chmod(0644,rnc_file) + if FileTest.file?(rnc_src) + FileUtils::cp(rnc_src,rnc_file) + FileUtils::chmod(0644,rnc_file) + else STDERR.puts %{\t*WARN* did not find rnc - "#{rnc_src}" [#{__FILE__}:#{__LINE__}]} + end end def trang_rnc_model_input_sax rnc_file=@env.processing_path.dal + '/sax.rnc' diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index c7b60bb5..57994a28 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -215,7 +215,10 @@ module SiSU_ODF image_source=image_src(i) pwd=Dir.pwd if image_source - FileUtils::cp("#{image_source}/#{i}","#{@env.processing_path.odt}/Pictures/#{i}") + if FileTest.file?("#{image_source}/#{i}") + FileUtils::cp("#{image_source}/#{i}","#{@env.processing_path.odt}/Pictures/#{i}") + else STDERR.puts %{\t*WARN* did not find image - "#{image_source}/#{i}" [#{__FILE__}:#{__LINE__}]} + end end img=if i.to_s =~/jpg|png|gif/ \ and h.to_s =~/\d/ \ @@ -522,7 +525,10 @@ module SiSU_ODF fix=[] bullet=image_src('bullet_09.png') if bullet - FileUtils::cp("#{bullet}/bullet_09.png","#{@env.processing_path.odt}/Pictures/.") + if FileTest.file?("#{bullet}/bullet_09.png") + FileUtils::cp("#{bullet}/bullet_09.png","#{@env.processing_path.odt}/Pictures/.") + else STDERR.puts %{\t*WARN* did not find image - "#{bullet}/bullet_09.png" [#{__FILE__}:#{__LINE__}]} + end end odf_metadata data.each do |dob| diff --git a/lib/sisu/v3/share_src.rb b/lib/sisu/v3/share_src.rb index ac466d33..c4900f5f 100644 --- a/lib/sisu/v3/share_src.rb +++ b/lib/sisu/v3/share_src.rb @@ -76,12 +76,17 @@ module SiSU_Markup end FileUtils::mkdir_p(@file.output_path.src.dir) unless FileTest.directory?(@file.output_path.src.dir) if FileTest.directory?(@file.output_path.src.dir) - unless @opt.fns =~/\.ssm$/; FileUtils::cp(@opt.fns,@file.output_path.src.dir) + unless @opt.fns =~/\.ssm$/ + if FileTest.file?(@opt.fns) + FileUtils::cp(@opt.fns,@file.output_path.src.dir) + else STDERR.puts %{\t*WARN* did not find - "#{@opt.fns}"} + end else req=@opt.fns.gsub(/(.+?\.ssm)$/,'\1.sst') file="#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst" - if FileTest.file?(file); FileUtils::cp(file,"#{@file.output_path.src.dir}/#{req}") - else print "did not find #{file} to copy" + if FileTest.file?(file) + FileUtils::cp(file,"#{@file.output_path.src.dir}/#{req}") + else STDERR.puts "*WARN* did not find #{file} to copy" end end else diff --git a/lib/sisu/v3/shared_images.rb b/lib/sisu/v3/shared_images.rb index 8f971a04..46b568d8 100644 --- a/lib/sisu/v3/shared_images.rb +++ b/lib/sisu/v3/shared_images.rb @@ -77,22 +77,25 @@ module SiSU_Images def images_set @pwd=ENV['PWD'] def copy(src_path,dest_path,images=nil) - if FileTest.directory?(src_path) - FileUtils::cd(src_path) - unless images - images=Dir.glob("*.{png,jpg,gif,ico}") - end - FileUtils::mkdir_p(dest_path) unless FileTest.directory?(dest_path) - FileUtils::chmod(0755,dest_path) - if images.length > 0 - images.each do |i| - FileUtils::cp_r(i,"#{dest_path}/#{i}") - FileUtils::chmod(0644,"#{dest_path}/#{i}") + if FileTest.directory?(src_path) + FileUtils::cd(src_path) + unless images + images=Dir.glob("*.{png,jpg,gif,ico}") + end + FileUtils::mkdir_p(dest_path) unless FileTest.directory?(dest_path) + FileUtils::chmod(0755,dest_path) + if images.length > 0 + images.each do |i| + if FileTest.file?(i) + FileUtils::cp_r(i,"#{dest_path}/#{i}") + FileUtils::chmod(0644,"#{dest_path}/#{i}") + else STDERR.puts %{\t*WARN* did not find image - "#{i}" [#{__FILE__}:#{__LINE__}]} + end + end end + FileUtils::cd(@pwd) + else STDERR.puts %{\t*WARN* did not find - "#{src_path}" [#{__FILE__}:#{__LINE__}]} end - FileUtils::cd(@pwd) - else puts "\tWARN, did not find - #{src_path}" - end end def dest_path(image_type) pth=if image_type==:image_sys diff --git a/lib/sisu/v3/sisupod_make.rb b/lib/sisu/v3/sisupod_make.rb index 33ae8db2..54376271 100644 --- a/lib/sisu/v3/sisupod_make.rb +++ b/lib/sisu/v3/sisupod_make.rb @@ -226,6 +226,7 @@ module SiSU_Doc images << f.scan(@rgx_rb_image).uniq if f =~@rgx_rb_image #does not really discriminate, may duplicate images in sisu file, and may take images from default image pool end + else STDERR.puts %{\t*WARN* did not find - "#{skin_source[:name_path]}" [#{__FILE__}:#{__LINE__}]} end end end @@ -255,15 +256,21 @@ module SiSU_Doc if FileTest.directory?(images_pwd) images=images.uniq images.each do |i| - FileUtils::cp_r("#{images_pwd}/#{i}","#{images_path_pod}/#{i}") if FileTest.file?("#{images_pwd}/#{i}") + if FileTest.file?("#{images_pwd}/#{i}") + FileUtils::cp("#{images_pwd}/#{i}","#{images_path_pod}/#{i}") if FileTest.file?("#{images_pwd}/#{i}") + else STDERR.puts %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]} + end end - else puts "\tWARN, did not find - #{images_pwd} #{images_path_pod}" + else STDERR.puts %{\t*WARN* did not find - #{images_pwd} #{images_path_pod} [#{__FILE__}:#{__LINE__}]} end end if doc_import.length > 0 \ and @opt.fno =~/\.ssm$/ doc_import.each do |f| - FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f}","#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f}") + if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f}") + FileUtils::cp("#{@env.path.pwd}#{doc_import_dir}/#{f}","#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f}") + else STDERR.puts %{\t*WARN* did not find image - "#{@env.path.pwd}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]} + end end end x=@env.document_language_versions_found #check multiple document language versions (param not used) diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 977fd3fe..e03c668d 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -2141,7 +2141,10 @@ WOK src="#{path.share}/image" images=%W[bullet_09.png arrow_next_red.png arrow_prev_red.png arrow_up_red.png] images.each do |i| #move to avoid repeated tests - FileUtils::cp("#{src}/#{i}","#{pth}/#{i}") unless FileTest.file?("#{pth}/#{i}") + if FileTest.file?("#{src}/#{i}") + FileUtils::cp("#{src}/#{i}","#{pth}/#{i}") unless FileTest.file?("#{pth}/#{i}") + else STDERR.puts %{\t*WARN* did not find image - "#{i}" [#{__FILE__}:#{__LINE__}]} + end end pth end @@ -5882,8 +5885,11 @@ WOK FileUtils::mkdir_p(dest_path) unless FileTest.directory?(dest_path) FileUtils::chmod(0755,dest_path) source.each do |i| - FileUtils::cp_r(i,"#{dest_path}/#{i}") - FileUtils::chmod(0644,"#{dest_path}/#{i}") + if FileTest.file?(i) + FileUtils::cp(i,"#{dest_path}/#{i}") + FileUtils::chmod(0644,"#{dest_path}/#{i}") + else STDERR.puts %{\t*WARN* did not find image - "#{i}" [#{__FILE__}:#{__LINE__}]} + end end FileUtils::cd(@pwd) else STDERR.puts %{\t*WARN* did not find - #{src_path} [#{__FILE__}:#{__LINE__}]} @@ -5927,7 +5933,10 @@ WOK FileUtils::cd(x) source=Dir.glob("*.{css}") source.each do |i| - FileUtils::cp(i,"#{@env.path.output}/#{@env.path.style}") + if FileTest.file?(i) + FileUtils::cp(i,"#{@env.path.output}/#{@env.path.style}") + else STDERR.puts %{\t*WARN* did not find css - "#{i}" [#{__FILE__}:#{__LINE__}]} + end end FileUtils::cd(@pwd) end -- cgit v1.2.3