pkg_supports¶
- odl.util.utility.pkg_supports(feature, pkg_version, pkg_feat_dict)[source]¶
Return bool indicating whether a package supports
feature.- Parameters:
- featurestr
Name of a potential feature of a package.
- pkg_versionstr
Version of the package that should be checked for presence of the feature.
- pkg_feat_dictdict
Specification of features of a package. Each item has the following form:
feature_name: version_specification
Here,
feature_nameis a string that is matched againstfeature, andversion_specificationis a string or a sequence of strings that specifies version sets. These specifications are the same as forsetuptoolsrequirements, just without the package name. ANoneentry signals "no support in any version", i.e., alwaysFalse. If a sequence of requirements are given, they are OR-ed together. SeeExamplesfor details.
- Returns:
- supportsbool
Trueifpkg_versionof the package in question supportsfeature,Falseotherwise.
Examples
>>> feat_dict = { ... 'feat1': '==0.5.1', ... 'feat2': '>0.6, <=0.9', # both required simultaneously ... 'feat3': ['>0.6', '<=0.9'], # only one required, i.e. always True ... 'feat4': ['==0.5.1', '>0.6, <=0.9'], ... 'feat5': None ... } >>> pkg_supports('feat1', '0.5.1', feat_dict) True >>> pkg_supports('feat1', '0.4', feat_dict) False >>> pkg_supports('feat2', '0.5.1', feat_dict) False >>> pkg_supports('feat2', '0.6.1', feat_dict) True >>> pkg_supports('feat2', '0.9', feat_dict) True >>> pkg_supports('feat2', '1.0', feat_dict) False >>> pkg_supports('feat3', '0.4', feat_dict) True >>> pkg_supports('feat3', '1.0', feat_dict) True >>> pkg_supports('feat4', '0.5.1', feat_dict) True >>> pkg_supports('feat4', '0.6', feat_dict) False >>> pkg_supports('feat4', '0.6.1', feat_dict) True >>> pkg_supports('feat4', '1.0', feat_dict) False >>> pkg_supports('feat5', '0.6.1', feat_dict) False >>> pkg_supports('feat5', '1.0', feat_dict) False