Skip to main content

Library for defining and checking for the status of requirements needed for your Python project

Project description

reequirements

reequirements is a useful library for defining and checking for the status of (not necessarily Python) requirements needed for your Python project.

Usage

Create some Requirement objects. Specify a friendly name for the requirement, a command to be able to check that requirement, and if it should issue a warning or halt the program if it is missing.

from reequirements import Requirement

REQUIREMENTS = [
    Requirement("docker", ["docker", "-v"], warn=False)
    Requirement("fortune", ["fortune", "-v"], warn=True)
]

Now, iterate through these requirements and check them.

for r in REQUIREMENTS:
    r.check()

RequirementMissing will be raised if docker -v exits with exit code 127 (command not found), or the more generic RequirementError will be raised if it exits with any other nonzero exit code.

RequirementMissingWarning will be warned if fortune -v exits with exit code 127 (command not found), or the more generic RequirementErrorWarning will be warned if it exits with any other nonzero exit code.

Tips

  • Make sure your commands to check requirements end with the correct exit code! This often means using flags like -v, -h when it comes to command line tools
  • You do not need to check for requirements right away; you can create Requirement at any time and check it whenever you want

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reequirements-1.2.1.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

reequirements-1.2.1-py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page