<commit_before>require 'digest'
require 'set'

TRANSPORTER_PATH = '/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/itms/bin/iTMSTransporter'

class ITMSUtils
  def self.download_metadata(username, password, app_id, destination, log_name)
    cmd = "#{TRANSPORTER_PATH} -m lookupMetadata -u #{username} -p #{password} -apple_id #{app_id} -destination #{destination} &> #{log_name}"

    unless system(cmd)
      return false
    end

    return true
  end

  def self.copy_images(image_filenames, destination)
    full_destination_path = File.expand_path(destination)
    image_filenames.each do |image_filename|
      full_image_filepath = File.expand_path(image_filename)
      `cp #{full_image_filepath} #{full_destination_path}`
    end
  end

  def self.image_data_string(image_dir, image_name)
    full_path = "#{image_dir}/#{image_name}"

    output = "<size>#{File.size(full_path)}</size>"
    output += "<file_name>#{image_name}</file_name>"
    output += "<checksum type=\"md5\">#{Digest::MD5.file(full_path).hexdigest}</checksum>"
  end

  def self.locale_row_data_by_id(input_locales)
    locale_row_data_by_id = Hash.new<commit_msg>Better error messages when missing images<commit_after>require 'digest'
require 'set'

TRANSPORTER_PATH = '/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/itms/bin/iTMSTransporter'

class ITMSUtils
  def self.download_metadata(username, password, app_id, destination, log_name)
    cmd = "#{TRANSPORTER_PATH} -m lookupMetadata -u #{username} -p #{password} -apple_id #{app_id} -destination #{destination} &> #{log_name}"

    unless system(cmd)
      return false
    end

    return true
  end

  def self.copy_images(image_filenames, destination)
    full_destination_path = File.expand_path(destination)
    image_filenames.each do |image_filename|
      full_image_filepath = File.expand_path(image_filename)
      `cp #{full_image_filepath} #{full_destination_path}`
    end
  end

  def self.image_data_string(image_dir, image_name)
    if !image_name || image_name.length == 0
      raise Exception.new("Image name cannot be blank")
      return
    end

    full_path = "#{image_dir}/#{image_name}"

    if !File.exists?(full_path)
      raise Exception.new("Image cannot be found: #{full_path}")
      return
    end

    output = "<size>#{File.size(full_path)}</size>"
    output += "<file_name>#{image_name}</file_name>"
    output += "<checksum type=\"md5\">#{Digest::MD5.file(full_path).hexdigest}</checksum>"
  end

  def self.locale_row_data_by_id(input_locales)
    locale_row_data_by_id = Hash.new
{'fraction_non_alphanumeric': 0.12404580152671756, 'fraction_numerical': 0.0019083969465648854, 'mean_word_length': 4.529535864978903, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7505581', 'n_tokens_mistral': 881, 'n_tokens_neox': 868, 'n_words': 164}