Class: Dependabot::Python::FileUpdater::SetupFileSanitizer
- Inherits:
-
Object
- Object
- Dependabot::Python::FileUpdater::SetupFileSanitizer
- Defined in:
- lib/dependabot/python/file_updater/setup_file_sanitizer.rb
Overview
Take a setup.py, parses it (carefully!) and then create a new, clean setup.py using only the information which will appear in the lockfile.
Instance Method Summary collapse
-
#initialize(setup_file:, setup_cfg:) ⇒ SetupFileSanitizer
constructor
A new instance of SetupFileSanitizer.
- #sanitized_content ⇒ Object
Constructor Details
#initialize(setup_file:, setup_cfg:) ⇒ SetupFileSanitizer
Returns a new instance of SetupFileSanitizer.
12 13 14 15 |
# File 'lib/dependabot/python/file_updater/setup_file_sanitizer.rb', line 12 def initialize(setup_file:, setup_cfg:) @setup_file = setup_file @setup_cfg = setup_cfg end |
Instance Method Details
#sanitized_content ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dependabot/python/file_updater/setup_file_sanitizer.rb', line 17 def sanitized_content # The part of the setup.py that Pipenv cares about appears to be the # install_requires. A name and version are required by don't end up # in the lockfile. content = "from setuptools import setup\n\n"\ "setup(name=\"sanitized-package\",version=\"0.0.1\","\ "install_requires=#{install_requires_array.to_json},"\ "extras_require=#{extras_require_hash.to_json}" content += ',setup_requires=["pbr"],pbr=True' if include_pbr? content + ")" end |