#!/usr/bin/env ruby # encoding: UTF-8 require File.expand_path(File.dirname(__FILE__) + '/../config/boot') require 'optparse' def validate(path, flags) ap({:path => path, :flags => flags}) if flags[:debug] File.umask(002) Dir.glob("#{flags[:srcdir]}/**/*.shp") do |shp| puts "Processing #{shp}" if flags[:debug] basefn = File.basename(shp, '.shp') unless GeoHydra::Utils.shapefile?(shp) puts "SyntaxError: Not a shapefile <#{shp}>. Trying to repair..." Dir.glob("#{File.dirname(shp)}/#{basefn.gsub(' ', "\\ ")}.*") do |fn| newfn = File.join(File.dirname(fn), File.basename(fn).gsub(/[^a-zA-Z0-9_]/, '_')) FileUtils.mv fn, newfn end end end end # __MAIN__ begin flags = { :debug => false, :verbose => false, :stagedir => GeoHydra::Config.geohydra.stage || 'stage', :tmpdir => GeoHydra::Config.geohydra.tmpdir || 'tmp' } OptionParser.new do |opts| opts.banner = < e $stderr.puts "ERROR: #{e.message}" exit(-1) end