================
@@ -322,8 +342,34 @@ def getDwarfVersion():
return "0"
+def isExpectedVersion(
+ actual_version: str, required_version: str, operator: str
+) -> bool:
+ """Returns True if actual_version matches the required_version given the
operator.
+ Any operator other than the following defaults to an equality test:
+ '>', '>=', "=>", '<', '<=', '=<', '!=', "!" or 'not'
+
+ Example:
+ - actual_version='1.2.0', required_version='1.0.0', operator='>='
returns True
+ """
+ actual_version_ = version.parse(actual_version)
+ required_version_ = version.parse(required_version)
+
+ if operator == ">":
+ return actual_version_ > required_version_
+ if operator == ">=" or operator == "=>":
+ return actual_version_ >= required_version_
+ if operator == "<":
+ return actual_version_ < required_version_
+ if operator == "<=" or operator == "=<":
+ return actual_version_ <= required_version_
+ if operator == "!=" or operator == "!" or operator == "not":
+ return actual_version not in required_version
----------------
da-viper wrote:
We could use the `parsed versions` here as it takes care of extra spaces for
the `!=` and `==` cases.
https://github.com/llvm/llvm-project/pull/172838
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits