<commit_before># Make python versions available as facts
# In lists default python and system python versions
require 'puppet'
pkg = Puppet::Type.type(:package).new(:name => "python")

Facter.add("system_python_version") do
  setcode do
    if pkg.retrieve[pkg.property(:ensure)] != 'purged'
        /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
    end
  end
end

Facter.add("python_version") do
  has_weight 100
  setcode do
    /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V 2>/dev/null'))[1]
  end
end

Facter.add("python_version") do
  has_weight 50
  setcode do
    if pkg.retrieve[pkg.property(:ensure)] != 'purged'
        /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
    end
  end
end
<commit_msg>Fix Python version detection, stderr to stdout<commit_after># Make python versions available as facts
# In lists default python and system python versions
require 'puppet'
pkg = Puppet::Type.type(:package).new(:name => "python")

Facter.add("system_python_version") do
  setcode do
    if pkg.retrieve[pkg.property(:ensure)] != 'purged'
        /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
    end
  end
end

Facter.add("python_version") do
  has_weight 100
  setcode do
    /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V 2>&1'))[1]
  end
end

Facter.add("python_version") do
  has_weight 50
  setcode do
    if pkg.retrieve[pkg.property(:ensure)] != 'purged'
        /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
    end
  end
end

{'fraction_non_alphanumeric': 0.19923857868020303, 'fraction_numerical': 0.012055837563451776, 'mean_word_length': 3.679525222551929, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1526587', 'n_tokens_mistral': 596, 'n_tokens_neox': 579, 'n_words': 116}