@classmethod<EOL><INDENT>def from_version(cls, version, op=None):<DEDENT>
lower = None<EOL>upper = None<EOL>if op is None:<EOL><INDENT>lower = _LowerBound(version, True)<EOL>upper = _UpperBound(next(version), False)<EOL><DEDENT>elif op in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>lower = _LowerBound(version, True)<EOL>upper = _UpperBound(version, True)<EOL><DEDENT>elif op in ("<STR_LIT>", "<STR_LIT:>>"):<EOL><INDENT>lower = _LowerBound(version, False)<EOL><DEDENT>elif op in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>lower = _LowerBound(version, True)<EOL><DEDENT>elif op in ("<STR_LIT>", "<STR_LIT:<>"):<EOL><INDENT>upper = _UpperBound(version, False)<EOL><DEDENT>elif op in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>upper = _UpperBound(version, True)<EOL><DEDENT>else:<EOL><INDENT>raise VersionError("<STR_LIT>" % op)<EOL><DEDENT>bound = _Bound(lower, upper)<EOL>range = cls(None)<EOL>range.bounds = [bound]<EOL>return range<EOL>
Create a range from a version.

        Args:
            version: Version object. This is used as the upper/lower bound of
                the range.
            op: Operation as a string. One of 'gt'/'>', 'gte'/'>=', lt'/'<',
                'lte'/'<=', 'eq'/'=='. If None, a bounded range will be created
                that contains the version superset.

        Returns:
            `VersionRange` object.