Sha256: a2d4389451b3025259dbc61a63c57cf2643ae8a3afe795cf9c3b7fae4ec9744a

Contents?: true

Size: 880 Bytes

Versions: 4

Compression:

Stored size: 880 Bytes

Contents

# frozen_string_literal: true

require 'find'

module Xezat
  module Detector
    class Python39
      def detect(variables)
        return true if File.directory?(File.join(variables[:D], 'usr', 'lib', 'python3.9'))

        Find.find(variables[:D]) do |file|
          next unless file.end_with?('.py')

          first_line = File.readlines(file).first
          return true if %r{^#!\s*/usr/bin/env\s*python\s*$}.match?(first_line)
          return true if %r{^#!\s*/usr/bin/env\s*python3\s*$}.match?(first_line)
          return true if %r{^#!\s*/usr/bin/env\s*python3.9\s*$}.match?(first_line)
          return true if %r{^#!\s*/usr/bin/python\s*$}.match?(first_line)
          return true if %r{^#!\s*/usr/bin/python3\s*$}.match?(first_line)
          return true if %r{^#!\s*/usr/bin/python3.9\s*$}.match?(first_line)
        end
        false
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xezat-0.3.1 lib/xezat/detector/python39.rb
xezat-0.3.0 lib/xezat/detector/python39.rb
xezat-0.2.3 lib/xezat/detector/python39.rb
xezat-0.2.2 lib/xezat/detector/python39.rb