Compares to semver versions.

@param {String} fstVer
@param {String} sndVer
@returns {Number} -1 if fstVer if older than sndVer, 1 if newer and 0 if
versions are equal.
772349
function compareVersions(fstVer, sndVer) {
    if (semver.lt(fstVer, sndVer)) {
        return 1;
    }
    if (semver.gt(fstVer, sndVer)) {
        return -1;
    }
    return 0;
}
1360628
def _version_checker(module, minver):
    
    # We could use LooseVersion, but distutils imports imp which is deprecated
    version_regexp = r'[a-z]?((?:\d|\.)+\d+)(?:\.dev[0-9]+)?'
    version_tags = re.match(version_regexp, module.__version__)
    if not version_tags:
        return False
    version_tags = version_tags.group(1).split(".")
    version_tags = tuple(int(x) for x in version_tags)
    return version_tags >= minver
56978
function vver(pt, inc) {
		return (pt ? vv(3) : '') + vv(5, self.versionMajor) + vv(6) + vv(7, self.versionMinor) + vv(8)
				+ vv(9, self.versionPatch, inc && !self.versionPrereleaseChar) + vv(10)
				+ vv(11, self.versionPrerelease, inc && self.versionPrereleaseChar) + vv(12, self.versionMetadata);
	}
1349226
public static int compareVersions(String v1, String v2) {
		String s1 = normalisedVersion(v1);
		String s2 = normalisedVersion(v2);
		return s1 != null ? (s2 != null ? s1.compareTo(s2) : 1)
				: (s2 != null ? -1 : 0);
	}
1133920
def _find_matching_version(versions, version_pattern):
    
    pattern = fnmatch.translate(version_pattern.replace('x', '*'))
    return next((v for v in versions if re.match(pattern, v)), None)
801404
public boolean isEquivalentTo(Semver version) {
        // Get versions without build
        Semver sem1 = this.getBuild() == null ? this : new Semver(this.getValue().replace("+" + this.getBuild(), ""));
        Semver sem2 = version.getBuild() == null ? version : new Semver(version.getValue().replace("+" + version.getBuild(), ""));
        // Compare those new versions
        return sem1.isEqualTo(sem2);
    }
671280
function defaultVersionMatcher(raw) {
  // sanity check
  if (ramda.isNil(raw) || ramda.isEmpty(raw)) return null

  try {
    // look for something that looks like semver
    var rx = /([0-9]+\.[0-9]+\.[0-9]+)/
    var match = ramda.match(rx, raw)
    if (match.length > 0) {
      return match[0]
    } else {
      return null
    }
  } catch (err) {
    // something tragic happened
    return false
  }
}
443179
function checkMinVersion() {
  const majorVersion = Number(process.version.replace(/v/, '').split('.')[0]);
  if (majorVersion < NODE_MIN_VERSION) {
    $$.util.log('Please run Web Activities with node.js version ' +
        `${NODE_MIN_VERSION} or newer.`);
    $$.util.log('Your version is', process.version);
    process.exit(1);
  }
}
1118292
function () {
            if (!this.__serverVersion) {
                var self = this;
                this.__serverVersion = this.get(identifier("version").sqlFunction).chain(function (version) {
                    var m = version.match(/PostgreSQL (\d+)\.(\d+)(?:(?:rc\d+)|\.(\d+))?/);
                    version = (parseInt(m[1], 10) * 10000) + (parseInt(m[2], 10) * 100) + parseInt(m[3], 10);
                    self._serverVersion = version;
                    return version;
                });
            }
            return this.__serverVersion.promise();
        }
1210092
def compare_contract_versions(
        proxy: ContractProxy,
        expected_version: str,
        contract_name: str,
        address: Address,
) -> None:
    """"""
    assert isinstance(expected_version, str)
    try:
        deployed_version = proxy.contract.functions.contract_version().call()
    except BadFunctionCallOutput:
        raise AddressWrongContract('')

    deployed_version = deployed_version.replace('_', '0')
    expected_version = expected_version.replace('_', '0')

    deployed = [int(x) for x in deployed_version.split('.')]
    expected = [int(x) for x in expected_version.split('.')]

    if deployed != expected:
        raise ContractVersionMismatch(
            f'Provided {contract_name} contract ({to_normalized_address(address)}) '
            f'version mismatch. Expected: {expected_version} Got: {deployed_version}',
        )
565252
def sortedSemver(versions, sort="asc"):
    """"""
    if versions and isinstance(versions, (list, tuple)):
        if PY2:
            return sorted(versions, cmp=semver.compare, reverse=True if sort.upper() == "DESC" else False)
        else:
            from functools import cmp_to_key
            return sorted(versions, key=cmp_to_key(semver.compare), reverse=True if sort.upper() == "DESC" else False)
    else:
        raise TypeError("Invaild Versions, a list or tuple is right.")
113054
public int compareTo(Version that) {

    if (that == null) {
      return 1;
    }

    if (major != that.major) {
      return major - that.major;
    }

    if (minor != that.minor) {
      return minor - that.minor;
    }

    if (bugfix != that.bugfix) {
      return bugfix - that.bugfix;
    }

    if (build != that.build) {
      return build - that.build;
    }

    return 0;
  }
146834
def version_at_least(version_string, major, minor, micro, patch):
    
    parts = re.match(
        r'^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+).*$',
        version_string,
    )
    for ver, gold in zip(parts.group(1, 2, 3, 4), (major, minor, micro, patch)):
        if int(ver) < int(gold):
            return False
        elif int(ver) > int(gold):
            return True
    return True
212373
int version()
  {
    if (_version > 0) {
      return _version;
    }

    CharSegment protocol = getProtocolBuffer();
    if (protocol.equals("HTTP/1.1")) {
      _version = HTTP_1_1;
      return HTTP_1_1;
    }
    else if (protocol.equals("HTTP/1.0")) {
      _version = HTTP_1_0;
      return _version;
    }
    else if (protocol.equals("HTTP/0.9")) {
      _version = HTTP_0_9;
      return HTTP_0_9;
    }
    else if (protocol.length() < 8) {
      _version = HTTP_0_9;
      return _version;
    }

    int i = protocol.indexOf('/');
    int len = protocol.length();
    int major = 0;
    for (i++; i < len; i++) {
      char ch = protocol.charAt(i);

      if ('0' <= ch && ch <= '9')
        major = 10 * major + ch - '0';
      else if (ch == '.')
        break;
      else {
        _version = HTTP_1_0;
        return _version;
      }
    }

    int minor = 0;
    for (i++; i < len; i++) {
      char ch = protocol.charAt(i);

      if ('0' <= ch && ch <= '9')
        minor = 10 * minor + ch - '0';
      else
        break;
    }

    _version = 256 * major + minor;

    return _version;
  }
356547
def compare_version(v1, v2):
    
    s1 = StrictVersion(v1)
    s2 = StrictVersion(v2)
    if s1 == s2:
        return 0
    elif s1 > s2:
        return -1
    else:
        return 1
94240
def check_js_threshold_version(working_alias):
    # type: (str) -> bool

    
    # parse nodejs version into int Tuple: 'v4.2.6\n' -> [4, 2, 6]
    current_version_str = subprocess.check_output(
        [working_alias, "-v"]).decode('utf-8')

    current_version = [int(v) for v in current_version_str.strip().strip('v').split('.')]
    minimum_node_version = [int(v) for v in minimum_node_version_str.split('.')]

    return current_version >= minimum_node_version
922079
public int compareTo(Error s) {
    if (getStart() < s.getStart()) {
      return -1;
    } else if (getStart() == s.getStart()) {
      if (getEnd() > s.getEnd()) {
        return -1;
      } else if (getEnd() < s.getEnd()) {
        return 1;
      } else {
        return 0;
      }
    } else {
      return 1;
    }
  }