IF there is an exact match then use it
     OTHERWISE try to find a minor version match
485084
def exact_or_minor_exe_version_match(executable_name,
                                     exe_version_tuples,
                                     version):
    
    exe = exact_exe_version_match(executable_name,
                                  exe_version_tuples,
                                  version)

    if not exe:
        exe = minor_exe_version_match(executable_name,
                                      exe_version_tuples,
                                      version)
    return exe
1014658
def get_version(string):
    
    flags = re.S
    pattern = r".*__version__ = '(.*?)'"
    match = re.match(pattern=pattern, string=string, flags=flags)

    if match:
        return match.group(1)

    raise RuntimeError('No version string could be matched')
1229365
def nsUriMatch(self, value, wanted, strict=0, tt=type(())):
        """"""
        if value == wanted or (type(wanted) is tt) and value in wanted:
            return 1
        if not strict and value is not None:
            wanted = type(wanted) is tt and wanted or (wanted,)
            value = value[-1:] != '/' and value or value[:-1]
            for item in wanted:
                if item == value or item[:-1] == value:
                    return 1
        return 0
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
  }
}
1055421
function compareVersion(version1, version2) {
  version1 = cleanupVersion(version1).split('.');
  version2 = cleanupVersion(version2).split('.');
  for (let i = 0; i < 3; i++) {
    let compared = compare(+version1[i], +version2[i]);
    if (compared !== 0) {
      return compared;
    }
  }
  return 0;
}
1229179
def unmatched(match):
    """"""
    start, end = match.span(0)
    return match.string[:start]+match.string[end:]
227315
def match(self, version):
        
        if isinstance(version, string_types):
            version = self.version_class(version)
        for operator, constraint, prefix in self._parts:
            f = self._operators.get(operator)
            if isinstance(f, string_types):
                f = getattr(self, f)
            if not f:
                msg = ('%r not implemented '
                       'for %s' % (operator, self.__class__.__name__))
                raise NotImplementedError(msg)
            if not f(version, constraint, prefix):
                return False
        return True
748342
def check_version(version, range_=None):
    
    if range_ and version not in range_:
        raise RezBindError("found version %s is not within range %s"
                           % (str(version), str(range_)))
926808
def check_version(ctx, param, value):
    """"""
    if ctx.resilient_parsing:
        return

    if not value and ctx.invoked_subcommand != 'run':
        ctx.call_on_close(_check_version)
1000843
function findMatchingSpecial() {
            // used to loop through the specials
            var i;

            for (i = specialsCounter; i < specials.length; i++) {
                // short circuit this search when we know there are no matches following
                if (specials[i] >= deadBranches[queryCounter]) {
                    break;
                }

                // First, ensure that we're not comparing specials that
                // come earlier in the string than our current search position.
                // This can happen when the string position changes elsewhere.
                if (specials[i] < strCounter) {
                    specialsCounter = i;
                } else if (query[queryCounter] === str[specials[i]]) {
                    // we have a match! do the required tracking
                    strCounter = specials[i];

                    // Upper case match check:
                    // If the query and original string matched, but the original string
                    // and the lower case version did not, that means that the original
                    // was upper case.
                    var upper = originalQuery[queryCounter] === originalStr[strCounter] && originalStr[strCounter] !== str[strCounter];
                    result.push(new SpecialMatch(strCounter, upper));
                    specialsCounter = i;
                    queryCounter++;
                    strCounter++;
                    return true;
                }
            }

            return false;
        }
1009061
def _version_find_existing():
    
    _tool_run('git fetch origin -t')
    git_tags = [x for x in (y.strip() for y in (_tool_run('git tag -l')
                                                .stdout.split('\n'))) if x]
    return {tuple(int(n) if n else 0 for n in m.groups())
            for m in (_version_re.match(t) for t in git_tags) if m}
995778
def find_all(name, version = nil)
      matched = []
      find(name, version) {|p| matched << p }
      matched
    end
1316245
protected int findMatchingVersionIndex(String dbVersion) {
        int index = 0;
        int matchingVersionIndex = -1;
        while (matchingVersionIndex < 0 && index < ACTIVITI_VERSIONS.size()) {
            if (ACTIVITI_VERSIONS.get(index).matches(dbVersion)) {
                matchingVersionIndex = index;
            } else {
                index++;
            }
        }
        return matchingVersionIndex;
    }
976341
function match (filename, patterns, ignorePatterns) {
  function isMatch (ps) {
    return ps.some(p => {
      return mm.isMatch(filename, p, mmOptions)
    })
  }

  let isIgnore = false

  if (Array.isArray(ignorePatterns) && ignorePatterns.length) {
    isIgnore = isMatch(ignorePatterns)
  }

  if (isIgnore) {
    return false
  }

  return isMatch(patterns)
}
1340948
def match_path(entry, opts):
    """"""
    if entry.name in ALWAYS_OMIT:
        return False
    # TODO: currently we use fnmatch syntax and match against names.
    # We also might allow glob syntax and match against the whole relative path instead
    # path = entry.get_rel_path()
    path = entry.name
    ok = True
    match = opts.get("match")
    exclude = opts.get("exclude")
    if entry.is_file() and match:
        assert type(match) is list
        ok = False
        for pat in match:
            if fnmatch.fnmatch(path, pat):
                ok = True
                break
    if ok and exclude:
        assert type(exclude) is list
        for pat in exclude:
            if fnmatch.fnmatch(path, pat):
                ok = False
                break
    # write("match", ok, entry)
    return ok
719715
function compareVersions(v1, v2) {
    if (semver.gt(v1.tag, v2.tag)) {
        return -1;
    }
    if (semver.lt(v1.tag, v2.tag)) {
        return 1;
    }
    return 0;
}
495467
def _compare_versions(v1, v2):
    
    def normalize(v):
        # strip trailing .0 or .00 or .0.0 or ...
        v = re.sub(r'(\.0+)*$', '', v)
        result = []
        for part in v.split('.'):
            # just digits
            m = re.match(r'^(\d+)$', part)
            if m:
                result.append(int(m.group(1)))
                continue
            # digits letters
            m = re.match(r'^(\d+)([a-zA-Z]+)$', part)
            if m:
                result.append(int(m.group(1)))
                result.append(m.group(2))
                continue
            # digits letters digits
            m = re.match(r'^(\d+)([a-zA-Z]+)(\d+)$', part)
            if m:
                result.append(int(m.group(1)))
                result.append(m.group(2))
                result.append(int(m.group(3)))
                continue
        return tuple(result)

    n1 = normalize(v1)
    n2 = normalize(v2)

    return (n1 > n2) - (n1 < n2)