Commit c74bfbe5 authored by Daniel Silverstone's avatar Daniel Silverstone
Browse files

_site.py: Reduce complexity of bwrap version comparison



Instead of an if/else ladder which is quite complex, this patch
uses the fact that Python supports by-component tuple comparison
to simply compare two (major, minor, patch) tuples

Signed-off-by: default avatarDaniel Silverstone <daniel.silverstone@codethink.co.uk>
parent b8421a9c
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -86,14 +86,4 @@ def check_bwrap_version(major, minor, patch):
        _bwrap_major, _bwrap_minor, _bwrap_patch = map(int, version.split("."))

    # Check whether the installed version meets the requirements
    if _bwrap_major > major:
        return True
    elif _bwrap_major < major:
        return False
    else:
        if _bwrap_minor > minor:
            return True
        elif _bwrap_minor < minor:
            return False
        else:
            return _bwrap_patch >= patch
    return (_bwrap_major, _bwrap_minor, _bwrap_patch) >= (major, minor, patch)