Revision 50d91bdfc94cb9d3aa01634ac0b003d76e799bf1 authored by Tobias Ellinghaus on 04 May 2017, 21:56:48 UTC, committed by Tobias Ellinghaus on 04 May 2017, 21:56:48 UTC
1 parent c2e0a27
sync_wb_presets_with_ufraw
#!/usr/bin/env ruby
require './rawspeed_common.rb'
require 'net/http'
DTPRESETS=File.expand_path("../src/external/wb_presets.c", File.dirname(__FILE__))
UFRAWPRESETS=URI('http://ufraw.cvs.sourceforge.net/viewvc/ufraw/ufraw/wb_presets.c?content-type=text%2Fplain')
puts "Fetching ufraw presets from their CVS, may take a moment..."
ufraw_presets = {}
Net::HTTP.get(UFRAWPRESETS).each_line do |line|
if line[0..2] == " {"
lineparts = line.split('"')
cameraname = [lineparts[1].upcase, lineparts[3].upcase]
if cameraname.join.strip != ""
ufraw_presets[cameraname] ||= []
ufraw_presets[cameraname] << line
end
end
end
dt_presets = {}
File.open(DTPRESETS) do |f|
f.each do |line|
if line[0..2] == " {"
lineparts = line.split('"')
cameraname = [lineparts[1], lineparts[3]]
dt_presets[cameraname] ||= []
dt_presets[cameraname] << line
end
end
end
forward_hash, backward_hash = RawSpeedCommon.generate_hashes()
grab_from_ufraw = []
forward_hash.each do |exif_name, clean_name|
if(ufraw_presets[exif_name] && !dt_presets[clean_name])
grab_from_ufraw << [exif_name, clean_name]
end
end
submit_to_ufraw = []
backward_hash.each do |clean_name, exif_names|
if dt_presets[clean_name]
exif_names.keys.each do |exif_name|
if !ufraw_presets[exif_name]
submit_to_ufraw << [clean_name, exif_name]
end
end
end
end
def change_makermodel(line, make, model)
lineparts = line.split('"')
lineparts[1] = make
lineparts[3] = model
lineparts.join('"')
end
puts "Found #{grab_from_ufraw.size} cameras to copy ufraw->darktable"
grab_from_ufraw.each do |exif_name, clean_name|
ufraw_presets[exif_name].each do |line|
puts change_makermodel(line, *clean_name)
end
puts ""
end
puts "Found #{submit_to_ufraw.size} cameras to submit darktable->ufraw"
submit_to_ufraw.each do |clean_name, exif_name|
dt_presets[clean_name].each do |line|
puts change_makermodel(line, *exif_name)
end
puts ""
end
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...