Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class String
- def starts_with?(str)
- self =~ /#{str}/
- end
- end
- names_to_edid = File.open(File.dirname(__FILE__) + '/edid_names').read.split("\n").
- collect {|line| edid, pruid, edname = line.split("|"); [edname.strip, edid.strip]}.
- inject({}) {|hash,e| hash[e.first] = e.last; hash }
- lines = File.open(ARGV[0]).read.split("\n").inject({}) {|hash,e| pc, rest = e.split(','); hash[pc] = rest; hash}
- lines.reject! {|k,v| v.nil?}
- lines.each do |k,v|
- if v =~ /^[^a-z]*$/
- puts "#{k},#{v}"
- else
- begin
- edid = names_to_edid.detect {|name,edid| name.starts_with?(v)}.last
- puts k + "," + edid
- rescue
- puts "oops on [#{k},#{v}]"
- end
- end
- end
Add Comment
Please, Sign In to add comment