Retrieve comparison methods to apply on version components.

        This is a private API.

        Args:
            partial (bool): whether to provide 'partial' or 'strict' matching.

        Returns:
            5-tuple of cmp-like functions.
485194
def _comparison_functions(cls, partial=False):
        

        def prerelease_cmp(a, b):
            """Compare prerelease components.

            Special rule: a version without prerelease component has higher
            precedence than one with a prerelease component.
            """
            if a and b:
                return identifier_list_cmp(a, b)
            elif a:
                # Versions with prerelease field have lower precedence
                return -1
            elif b:
                return 1
            else:
                return 0

        def build_cmp(a, b):
            """Compare build metadata.

            Special rule: there is no ordering on build metadata.
            """
            if a == b:
                return 0
            else:
                return NotImplemented

        def make_optional(orig_cmp_fun):
            """Convert a cmp-like function to consider 'None == *'."""
            @functools.wraps(orig_cmp_fun)
            def alt_cmp_fun(a, b):
                if a is None or b is None:
                    return 0
                return orig_cmp_fun(a, b)

            return alt_cmp_fun

        if partial:
            return [
                base_cmp,  # Major is still mandatory
                make_optional(base_cmp),
                make_optional(base_cmp),
                make_optional(prerelease_cmp),
                make_optional(build_cmp),
            ]
        else:
            return [
                base_cmp,
                base_cmp,
                base_cmp,
                prerelease_cmp,
                build_cmp,
            ]
78548
def _compare(cur_cmp, cur_struct):
    '''
    
    '''
    if isinstance(cur_cmp, dict) and isinstance(cur_struct, dict):
        log.debug('Comparing dict to dict')
        for cmp_key, cmp_value in six.iteritems(cur_cmp):
            if cmp_key == '*':
                # matches any key from the source dictionary
                if isinstance(cmp_value, dict):
                    found = False
                    for _, cur_struct_val in six.iteritems(cur_struct):
                        found |= _compare(cmp_value, cur_struct_val)
                    return found
                else:
                    found = False
                    if isinstance(cur_struct, (list, tuple)):
                        for cur_ele in cur_struct:
                            found |= _compare(cmp_value, cur_ele)
                    elif isinstance(cur_struct, dict):
                        for _, cur_ele in six.iteritems(cur_struct):
                            found |= _compare(cmp_value, cur_ele)
                    return found
            else:
                if isinstance(cmp_value, dict):
                    if cmp_key not in cur_struct:
                        return False
                    return _compare(cmp_value, cur_struct[cmp_key])
                if isinstance(cmp_value, list):
                    found = False
                    for _, cur_struct_val in six.iteritems(cur_struct):
                        found |= _compare(cmp_value, cur_struct_val)
                    return found
                else:
                    return _compare(cmp_value, cur_struct[cmp_key])
    elif isinstance(cur_cmp, (list, tuple)) and isinstance(cur_struct, (list, tuple)):
        log.debug('Comparing list to list')
        found = False
        for cur_cmp_ele in cur_cmp:
            for cur_struct_ele in cur_struct:
                found |= _compare(cur_cmp_ele, cur_struct_ele)
        return found
    elif isinstance(cur_cmp, dict) and isinstance(cur_struct, (list, tuple)):
        log.debug('Comparing dict to list (of dicts?)')
        found = False
        for cur_struct_ele in cur_struct:
            found |= _compare(cur_cmp, cur_struct_ele)
        return found
    elif isinstance(cur_cmp, bool) and isinstance(cur_struct, bool):
        log.debug('Comparing booleans: %s ? %s', cur_cmp, cur_struct)
        return cur_cmp == cur_struct
    elif isinstance(cur_cmp, (six.string_types, six.text_type)) and \
         isinstance(cur_struct, (six.string_types, six.text_type)):
        log.debug('Comparing strings (and regex?): %s ? %s', cur_cmp, cur_struct)
        # Trying literal match
        matched = re.match(cur_cmp, cur_struct, re.I)
        if matched:
            return True
        return False
    elif isinstance(cur_cmp, (six.integer_types, float)) and \
         isinstance(cur_struct, (six.integer_types, float)):
        log.debug('Comparing numeric values: %d ? %d', cur_cmp, cur_struct)
        # numeric compare
        return cur_cmp == cur_struct
    elif isinstance(cur_struct, (six.integer_types, float)) and \
         isinstance(cur_cmp, (six.string_types, six.text_type)):
        # Comapring the numerical value agains a presumably mathematical value
        log.debug('Comparing a numeric value (%d) with a string (%s)', cur_struct, cur_cmp)
        numeric_compare = _numeric_regex.match(cur_cmp)
        # determine if the value to compare agains is a mathematical operand
        if numeric_compare:
            compare_value = numeric_compare.group(2)
            return getattr(float(cur_struct), _numeric_operand[numeric_compare.group(1)])(float(compare_value))
        return False
    return False
480598
def _cmp_version(item1, item2):
    '''
    
    '''
    vers1 = _LooseVersion(item1)
    vers2 = _LooseVersion(item2)

    if vers1 < vers2:
        return -1
    if vers1 > vers2:
        return 1
    return 0
1267773
def get_component(self, component_type):
        '''
        
        '''
        matching_components = list(filter(lambda component:
                                          isinstance(component,
                                                     component_type),
                                          self._components))
        if matching_components:
            return matching_components[0]
        else:
            return None
131446
def sort_permutations(permutations, user_deps)
      # Cache for versions converted to Gem::Version instances
      versions = {}

      map = lambda do |m, p|
        if p =~ Lyp::PACKAGE_RE
          m[$1] = versions[p] ||= (Lyp.version($2 || '0.0') rescue nil)
        end
        m
      end

      compare = lambda do |x, y|
        x_versions = x.inject({}, &map)
        y_versions = y.inject({}, &map)

        # If the dependency is direct (not transitive), just compare its versions.
        # Otherwise, add the result of comparison to score.
        x_versions.inject(0) do |score, kv|
          package = kv[0]
          cmp = kv[1] <=> y_versions[package]
          if user_deps.include?(package) && cmp != 0
            return cmp
          else
            score += cmp unless cmp.nil?
          end
          score
        end
      end

      permutations.sort(&compare)
    end
1045378
def _define_compat_pickle_load():
    
    if pd.__version__.startswith("0.14"):
        return pickle.load
    return functools.partial(pickle_compat.load, compat=True)
404901
def s(cls: Type[C], *args, **kwargs) -> Partial[C]:
        
        return Partial(cls, *args, **kwargs)
1161079
def compare_version(value):
    

    # extract parts from value
    import re
    res = re.match(r'(<|<=|==|>|>=)(\d{1,2}\.\d{1,2}(\.\d{1,2})?)$',
                   str(value).strip())
    if not res:
        return False
    operator, value, _ = res.groups()

    # break into pieces
    value = tuple(int(x) for x in str(value).split('.'))
    if len(value) < 3:
        value += (0,)

    version = __version_info__

    if operator in ('<', '<='):
        if version < value:
            return True

        if operator != '<=':
            return False

    elif operator in ('>=', '>'):
        if version > value:
            return True

        if operator != '>=':
            return False

    return value == version
1208080
def _paramlist_PartialLikelihoods(self):
        """"""
        if self._distributionmodel:
            return [param for param in self.model.freeparams +
                    [self.model.distributedparam] if param not in
                    self.model.distributionparams]
        else:
            return self.model.freeparams
635122
def overrideable_partial(func, *args, **default_kwargs):
    
    import functools
    @functools.wraps(func)
    def partial_wrapper(*given_args, **given_kwargs):
        kwargs = default_kwargs.copy()
        kwargs.update(given_kwargs)
        return func(*(args + given_args), **kwargs)
    return partial_wrapper
762658
def alwaysCalledWithMatch(self, *args, **kwargs): #pylint: disable=invalid-name
        
        self.__remove_args_first_item()
        alist, klist, gfunc = self.args, self.kwargs, self.__get_func
        if args and kwargs:
            return (uch.tuple_partial_cmp_always(args, alist, gfunc) and
                    uch.dict_partial_cmp_always(kwargs, klist, gfunc))
        elif args:
            return uch.tuple_partial_cmp_always(args, alist, gfunc)
        elif kwargs:
            return uch.dict_partial_cmp_always(kwargs, klist, gfunc)
        else:
            ErrorHandler.called_with_empty_error()
        self.__get_func = SinonSpy.__get_by_matcher
70246
def _get_available_versions(self):
        '''
        
        '''
        solvables = self.zypper.nolock.xml.call('se', '-xv', self.name).getElementsByTagName('solvable')
        if not solvables:
            raise CommandExecutionError('No packages found matching \'{0}\''.format(self.name))

        return sorted(set([slv.getAttribute(self._attr_solvable_version)
                           for slv in solvables if slv.getAttribute(self._attr_solvable_version)]))
1253934
def partial_regardless(self, fn, *a, **kw):
        """"""
        if self.has_annotations(fn):
            return self.partial(fn, *a, **kw)
        else:
            return functools.partial(fn, *a, **kw)
1010547
def get_functions(self, include_meta=False):
        
        instances = self._get_instances(ast.FunctionDef)
        instances = [
            PyFunction(instance, self.full_package)  # fix package name
            for instance in instances
        ]

        if not include_meta:
            instances = [
                instance  # fix package name
                for instance in instances
                if not instance.get_name().startswith("__")
            ]

        return instances
283796
def match(tgt, functions=None, opts=None):
    '''
    
    '''
    if not opts:
        opts = __opts__
    if functions is None:
        utils = salt.loader.utils(opts)
        functions = salt.loader.minion_mods(opts, utils=utils)
    comps = tgt.split(':')
    if len(comps) < 2:
        return False
    val = functions['data.getval'](comps[0])
    if val is None:
        # The value is not defined
        return False
    if isinstance(val, list):
        # We are matching a single component to a single list member
        for member in val:
            if fnmatch.fnmatch(six.text_type(member).lower(), comps[1].lower()):
                return True
        return False
    if isinstance(val, dict):
        if comps[1] in val:
            return True
        return False
    return bool(fnmatch.fnmatch(
        val,
        comps[1],
    ))
307599
private static void getLocalAndInheritedMethods(
      PackageElement pkg, TypeElement type, SetMultimap<String, ExecutableElement> methods) {
    for (TypeMirror superInterface : type.getInterfaces()) {
      getLocalAndInheritedMethods(pkg, MoreTypes.asTypeElement(superInterface), methods);
    }
    if (type.getSuperclass().getKind() != TypeKind.NONE) {
      // Visit the superclass after superinterfaces so we will always see the implementation of a
      // method after any interfaces that declared it.
      getLocalAndInheritedMethods(pkg, MoreTypes.asTypeElement(type.getSuperclass()), methods);
    }
    for (ExecutableElement method : ElementFilter.methodsIn(type.getEnclosedElements())) {
      if (!method.getModifiers().contains(Modifier.STATIC)
          && methodVisibleFromPackage(method, pkg)) {
        methods.put(method.getSimpleName().toString(), method);
      }
    }
  }
1166063
public synchronized Map<String, String> getComponentsVersions() {
        SortedMap<String, String> keys = new TreeMap<>(componentVersions);
        return keys;
    }