Skip to content

Instantly share code, notes, and snippets.

@cbeer
Created January 27, 2012 22:00
Show Gist options
  • Save cbeer/1691159 to your computer and use it in GitHub Desktop.
Save cbeer/1691159 to your computer and use it in GitHub Desktop.
Fedora (pre-akubra) llstore -> Pairtree
require 'rubygems'
require 'pairtree'
require 'find'
require 'fileutils'
pairtree = Pairtree.at('.', :create => true)
Find.find('data/objects') do |x|
next if File.directory? x
f = x.split("/").last
pid = f.gsub('org.wgbh.mars_', 'org.wgbh.mars:')
obj = pairtree.mk(pid)
print File.join(obj.path, 'object.xml')
print "\n"
FileUtils.copy(x, File.join(obj.path, 'object.xml'))
end
Find.find('data/datastreams') do |x|
next if File.directory? x
f = x.split("/").last
pid_dsid = f.gsub('org.wgbh.mars_', 'org.wgbh.mars:')
pid,dsid,dsid_version = pid_dsid.split("+")
obj = pairtree.mk(pid)
print File.join(obj.path, 'data', dsid_version)
print "\n"
FileUtils.mkdir(File.join(obj.path, 'data'))
FileUtils.copy(x, File.join(obj.path, 'object.xml'))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment