From 3e1f9d223bcc592b8cc7043812a02d272a27912b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Mon, 25 Apr 2016 11:13:01 +0200 Subject: [PATCH] [doc] Add documentation to contains methods of Specifier/SpecifierSet --- src/yunohost/utils/packages.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/yunohost/utils/packages.py b/src/yunohost/utils/packages.py index 82ebed243..43d2f2927 100644 --- a/src/yunohost/utils/packages.py +++ b/src/yunohost/utils/packages.py @@ -219,6 +219,15 @@ class Specifier(object): return SpecifierSet(result if result is not None else '') def contains(self, item): + """Check if the specifier contains an other + + Return whether the item is contained in the version specifier. + + Example: + >>> '2.2.1' in Specifier('<< 2.3') + >>> '2.4' not in Specifier('<< 2.3') + + """ return self._get_relation(self.relation)(item, self.version) @@ -303,6 +312,15 @@ class SpecifierSet(object): return specifiers def contains(self, item): + """Check if the set contains a version specifier + + Return whether the item is contained in all version specifiers. + + Example: + >>> '2.2.1' in SpecifierSet('>= 2.2, << 2.3') + >>> '2.4' not in SpecifierSet('>= 2.2, << 2.3') + + """ return all( s.contains(item) for s in self._specs