<commit_before>define :apt_repo,
    :key_package => nil,
    :key_id => nil,
    :key_url => nil,
    :keyserver => "keys.gnupg.net",
    :url => nil,
    :distribution => nil,
    :components => "main",
    :source_packages => false,
    :description => nil do

  unless params[:key_package] or params[:key_id]
    raise "Cannot find key_package or key_id"
  end

  unless params[:url]
    raise "Cannot find url"
  end

  components = params[:components]
  components = components.join(' ') if components.kind_of?(Array)
  distribution = params[:distribution] || node[:lsb][:codename]
  description = params[:description] || params[:name].capitalize

  if params[:key_id]
    key_id = params[:key_id]
    key_url = params[:key_url]
    keyserver = params[:keyserver]
    key_installed = "apt-key list | grep #{key_id}"
    if key_url
      execute "apt-key adv --fetch #{key_url}" do
        not_if key_installed
      end
    elsif keyserver
      execute "apt-key adv --keyserver #{keyserver} --recv-keys #{key_id}" do
        not_if key_installed
      end
    end
  end

  execute "apt-get update" do
    action :nothing
  end

  directory "/etc/apt/sources.list.d"

  url = params[:url].gsub(/^ppa:/, '')
  src_entry = "#{url} #{distribution} #{components} ##{description}"
  file_content = "deb     #{src_entry}\n"

  # only add deb-src entry if source_packages parameter was specified
  file_content << "deb-src #{src_entry}\n" if params[:source_packages]

  file "/etc/apt/sources.list.d/#{params[:name]}.list" do
    content file_content
    mode "0644"
    notifies :run, resources(:execute => "apt-get update"), :immediately
  end

  if params[:key_package]
    package params[:key_package] do
      options "--allow-unauthenticated" unless key_installed
    end
  end<commit_msg>Revert "Accept Launchpad-style "ppa:foo/bar" URLs"<commit_after>define :apt_repo,
    :key_package => nil,
    :key_id => nil,
    :key_url => nil,
    :keyserver => "keys.gnupg.net",
    :url => nil,
    :distribution => nil,
    :components => "main",
    :source_packages => false,
    :description => nil do

  unless params[:key_package] or params[:key_id]
    raise "Cannot find key_package or key_id"
  end

  unless params[:url]
    raise "Cannot find url"
  end

  components = params[:components]
  components = components.join(' ') if components.kind_of?(Array)
  distribution = params[:distribution] || node[:lsb][:codename]
  description = params[:description] || params[:name].capitalize

  if params[:key_id]
    key_id = params[:key_id]
    key_url = params[:key_url]
    keyserver = params[:keyserver]
    key_installed = "apt-key list | grep #{key_id}"
    if key_url
      execute "apt-key adv --fetch #{key_url}" do
        not_if key_installed
      end
    elsif keyserver
      execute "apt-key adv --keyserver #{keyserver} --recv-keys #{key_id}" do
        not_if key_installed
      end
    end
  end

  execute "apt-get update" do
    action :nothing
  end

  directory "/etc/apt/sources.list.d"

  # only add deb-src entries if source_packages parameter was specified
  src_entry = "#{params[:url]} #{distribution} #{components} ##{description}"
  file_content = "deb     #{src_entry}\n"
  file_content << "deb-src #{src_entry}\n" if params[:source_packages]

  file "/etc/apt/sources.list.d/#{params[:name]}.list" do
    content file_content
    mode "0644"
    notifies :run, resources(:execute => "apt-get update"), :immediately
  end

  if params[:key_package]
    package params[:key_package] do
      options "--allow-unauthenticated" unless key_installed
    end
  end
{'fraction_non_alphanumeric': 0.13348164627363737, 'fraction_numerical': 0.002224694104560623, 'mean_word_length': 3.36, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '2063092', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1143, 'n_words': 301}