<commit_before>module Vx
  module Builder
    class ScriptBuilderV2

      class Python < Base

        DEFAULT_PYTHON = '2.7'
        PIP_DOWNLOADS  = "~/.pip-downloads"
        PIP_OPTS       = " --download-cache=#{PIP_DOWNLOADS}"

        def call(env)
          if enabled?(env)

            py_version = python_version(env)

            do_cache_key(env) do |i|
              i << "python-#{py_version}"
            end

            do_cached_directories(env) do |i|
              i << PIP_DOWNLOADS
            end

            env.stage("init").tap do |i|
              i.add_env 'TRAVIS_PYTHON_VERSION', py_version
            end

            env.stage("install").tap do |i|
              i.add_task "python", "action" => "install", "python" => py_version
              i.add_task "python", "virtualenv"
              i.add_task "python", "announce"

              do_install(env) do
                pip_args = PIP_OPTS
                if args = env.source.pip_args.first
                  pip_args = args
                end
                i.add_task "python", "action" => "pip:install", "pip_args" => pip_args
              end
            end

            do_before_script(env) do
              env.stage("before_script").tap do |i|
                i.add_task "python", "django:settings"
              end
            end

            do_script(env) do
              env.stage("script").tap do |i|
                i.add_task "python", "script"
              end
            end

          end

          app.call(env)
        end

        private

          def enabled?(env)
            env.source.python.first || env.source.language == 'python'
          end

          def python_version(env)
            v = env.source.python.first
            (v || DEFAULT_PYTHON).to_s
          end

      end
    end
  end
end
<commit_msg>Update python.rb<commit_after>module Vx
  module Builder
    class ScriptBuilderV2

      class Python < Base

        DEFAULT_PYTHON = '2.7'
        PIP_DOWNLOADS  = "~/.pip-downloads"
        PIP_OPTS       = ""#" --download-cache=#{PIP_DOWNLOADS}"

        def call(env)
          if enabled?(env)

            py_version = python_version(env)

            do_cache_key(env) do |i|
              i << "python-#{py_version}"
            end

            do_cached_directories(env) do |i|
              i << PIP_DOWNLOADS
            end

            env.stage("init").tap do |i|
              i.add_env 'TRAVIS_PYTHON_VERSION', py_version
            end

            env.stage("install").tap do |i|
              i.add_task "python", "action" => "install", "python" => py_version
              i.add_task "python", "virtualenv"
              i.add_task "python", "announce"

              do_install(env) do
                pip_args = PIP_OPTS
                if args = env.source.pip_args.first
                  pip_args = args
                end
                i.add_task "python", "action" => "pip:install", "pip_args" => pip_args
              end
            end

            do_before_script(env) do
              env.stage("before_script").tap do |i|
                i.add_task "python", "django:settings"
              end
            end

            do_script(env) do
              env.stage("script").tap do |i|
                i.add_task "python", "script"
              end
            end

          end

          app.call(env)
        end

        private

          def enabled?(env)
            env.source.python.first || env.source.language == 'python'
          end

          def python_version(env)
            v = env.source.python.first
            (v || DEFAULT_PYTHON).to_s
          end

      end
    end
  end
end

{'fraction_non_alphanumeric': 0.10021668472372698, 'fraction_numerical': 0.0016251354279523294, 'mean_word_length': 1.2782233189389265, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3213889', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1061, 'n_words': 229}