Skip to main content

Query a program for supported features

Project description

feature-check - query a program for supported features

The feature_check library obtains the list of supported features from a program via various methods and allows programs to check for the presence and, possibly, versions of specific features.

The feature_check library is fully typed.

Obtaining the features supported by a program

The obtain_features() function in the feature_check module runs a program with the appropriate option to obtain its list of features; the default is to pass the --features option, but this may be overridden. The obtain_features() function then examines the output to find a line that matches the specified prefix (or the default Features: prefix) and expects the rest of the line to be a whitespace-separated list of either feature names or name=version pairs. It returns a dictionary of the features obtained with their versions (or 1.0 if only a feature name was found in the program's output).

import feature_check

data = feature_check.obtain_features("timelimit")
print(data.get("subsecond", "not supported"))

For programs that need a different command-line option to list features:

import feature_check

print("SSL" in feature_check.obtain_features("curl", option="--version"))

Testing for feature versions

The feature_check library also provides a simple expression evaluation mechanism for examining feature versions - the expr module defines several Expr and Result classes and also provides the parse_simple() function (also exported by feature_check() itself) for creating simple version comparisons:

import feature_check

data = feature_check.obtain_features("timelimit")
expr = feature_check.parse_simple("subsecond >= 1")
print(expr.evaluate(data).value)

Contact the author

For more information, please see the feature_check library's homepage or contact the author, Peter Pentchev.

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

feature_check-2.3.1.tar.gz (39.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

feature_check-2.3.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file feature_check-2.3.1.tar.gz.

File metadata

  • Download URL: feature_check-2.3.1.tar.gz
  • Upload date:
  • Size: 39.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for feature_check-2.3.1.tar.gz
Algorithm Hash digest
SHA256 d1108c4fb2e20474a2dd3dc9203aff446eb806a1a75e36e7ba7128c433c108bf
MD5 409f21283acd6313360eb3bcc02c21aa
BLAKE2b-256 ab1c719ca263e0674fc3b246637b011cfe71bc9dc96a7c322b3d8e95132d065f

See more details on using hashes here.

File details

Details for the file feature_check-2.3.1-py3-none-any.whl.

File metadata

  • Download URL: feature_check-2.3.1-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for feature_check-2.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8bb958e8b4153b18dd2f3450d2bf4368d1503e49ff64f4ec4c76f1f25847c378
MD5 60d2c5cf83895e73ad09393cd4f428b4
BLAKE2b-256 2e02db9be90d5bfdde3dc78671757b20d4a91ed8ba630965f629758133b0b775

See more details on using hashes here.

Supported by

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