<commit_before>def ensure_data_bag(bag)
  begin
    data_bag(bag)
  rescue
    new_bag = Chef::DataBag.new
    new_bag.name(bag)
    new_bag.save
  end
end

def load_license(bag,hostname)
  begin
    licenses = search(bag, "allocated_to:#{hostname}")
    if licenses.count = 1
      Chef::Log.debug("zncrypt acl: successfully loaded license: \n" + licenses.first )
      return licenses.first
    else
      Chef::Log.fatal("zncrypt acl: found multiple licenses for node #{hostname} in the #{bag} data bag, cannot proceed.")
      raise
    end
  rescue
    Chef::Log.fatal("zncrypt acl: failed to locate a license for node #{hostname} in the #{bag} data bag, cannot proceed.")
    raise
  end
end

def load_passphrase(bag)
  load_license(bag)['passphrase']
end
<commit_msg>fixing logic in load_license()<commit_after>def ensure_data_bag(bag)
  begin
    data_bag(bag)
  rescue
    new_bag = Chef::DataBag.new
    new_bag.name(bag)
    new_bag.save
  end
end

def load_license(bag,hostname)
  begin
    licenses = search(bag, "allocated_to:#{hostname}")
    if licenses.count == 1
      Chef::Log.debug("zncrypt acl: successfully loaded license: \n" + licenses.first.raw_data.inspect )
      return licenses.first.raw_data
    else
      Chef::Log.fatal("zncrypt acl: found multiple licenses for node #{hostname} in the #{bag} data bag, cannot proceed.")
      raise
    end
  rescue
    Chef::Log.fatal("zncrypt acl: failed to locate a license for node #{hostname} in the #{bag} data bag, cannot proceed.")
    raise
  end
end

def load_passphrase(bag)
  load_license(bag)['passphrase']
end

{'fraction_non_alphanumeric': 0.10804020100502512, 'fraction_numerical': 0.001256281407035176, 'mean_word_length': 3.617391304347826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5664177', 'n_tokens_mistral': 531, 'n_tokens_neox': 536, 'n_words': 151}