Class: Harbinger::Analyzers::PythonDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/harbinger/analyzers/python_detector.rb

Instance Method Summary collapse

Constructor Details

#initialize(project_path) ⇒ PythonDetector

Returns a new instance of PythonDetector.



6
7
8
# File 'lib/harbinger/analyzers/python_detector.rb', line 6

def initialize(project_path)
  @project_path = project_path
end

Instance Method Details

#detectObject



10
11
12
13
14
15
# File 'lib/harbinger/analyzers/python_detector.rb', line 10

def detect
  detect_from_pyproject_toml ||
    detect_from_python_version ||
    detect_from_pyvenv_cfg ||
    (python_detected? ? detect_from_shell : nil)
end

#python_detected?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
# File 'lib/harbinger/analyzers/python_detector.rb', line 17

def python_detected?
  File.exist?(File.join(project_path, "pyproject.toml")) ||
    File.exist?(File.join(project_path, "requirements.txt")) ||
    File.exist?(File.join(project_path, ".python-version")) ||
    File.exist?(File.join(project_path, "setup.py")) ||
    File.exist?(File.join(project_path, "setup.cfg")) ||
    venv_exists?
end