<commit_before>#
# Copyright 2015-2016, <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef/resource'
require 'poise_languages'

require 'poise_python/error'
require 'poise_python/python_providers/base'


module PoisePython
  module PythonProviders
    class System < Base
      include PoiseLanguages::System::Mixin
      provides(:system)
      packages('python', {
        debian: {
          '~> 8.0' => %w{python3.4 python2.7},
          '~> 7.0' => %w{python3.2 python2.7 python2.6},
          '~> 6.0' => %w{python3.1 python2.6 python2.5},
        },
        ubuntu: {
          '14.04' => %w{python3.4 python2.7},
          '12.04' => %w{python3.2 python2.7},
          '10.04' => %w{python3.1 python2.6},
        },
        rhel: {default: %w{python}},
        centos: {default: %w{python}},
        fedora: {default: %w{python3 python}},
        amazon: {default: %w{python27 python26 python}},
      })

      # Output value for the Python binary we are installing. Seems to match
      # package name on all platforms I've checked.
      def python_binary
        ::File.join('', 'usr', 'bin', system_package_name)
      end

      private

      def install_python
        install_system_packages
      end

      def uninstall_python
        uninstall_system_packages
      end

      def system_package_candidates(version)
        [].tap do |names|
          # For two (or more) digit versions.
          if match = version.match(/^(\d+\.\d+)/)
            # Debian style pythonx.y
            names << "python#{match[1]}"
            # Amazon style pythonxy
            names << "python#{match[1].gsub(/\./, '')}"
          end
          # Aliases for 2 and 3.
          if version == '3' || version == ''
            names.concat(%w{python3.5 python35 python3.4 python34 python3.3 python33 python3.2 python32 python3.1 python31 python3.0 python30 python3})<commit_msg>fix: python_runtime '3' installs python26<commit_after>#
# Copyright 2015-2016, <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef/resource'
require 'poise_languages'

require 'poise_python/error'
require 'poise_python/python_providers/base'


module PoisePython
  module PythonProviders
    class System < Base
      include PoiseLanguages::System::Mixin
      provides(:system)
      packages('python', {
        debian: {
          '~> 8.0' => %w{python3.4 python2.7},
          '~> 7.0' => %w{python3.2 python2.7 python2.6},
          '~> 6.0' => %w{python3.1 python2.6 python2.5},
        },
        ubuntu: {
          '14.04' => %w{python3.4 python2.7},
          '12.04' => %w{python3.2 python2.7},
          '10.04' => %w{python3.1 python2.6},
        },
        rhel: {default: %w{python}},
        centos: {default: %w{python}},
        fedora: {default: %w{python3 python}},
        amazon: {default: %w{python34 python27 python26 python}},
      })

      # Output value for the Python binary we are installing. Seems to match
      # package name on all platforms I've checked.
      def python_binary
        ::File.join('', 'usr', 'bin', system_package_name)
      end

      private

      def install_python
        install_system_packages
      end

      def uninstall_python
        uninstall_system_packages
      end

      def system_package_candidates(version)
        [].tap do |names|
          # For two (or more) digit versions.
          if match = version.match(/^(\d+\.\d+)/)
            # Debian style pythonx.y
            names << "python#{match[1]}"
            # Amazon style pythonxy
            names << "python#{match[1].gsub(/\./, '')}"
          end
          # Aliases for 2 and 3.
          if version == '3' || version == ''
            names.concat(%w{python3.5 python35 python3.4 python34 python3.3 python33 python3.2 python32 python3.1 python31 python3.0 python30 python3})
{'fraction_non_alphanumeric': 0.11933815925542916, 'fraction_numerical': 0.03950361944157187, 'mean_word_length': 2.484149855907781, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7048469', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1443, 'n_words': 444}