This is a generalization of Converter.are_worth_chaining(), to support ConversionChains.

        :param first_converter:
        :param second_converter:
        :return:
172516
def are_worth_chaining(first_converter: Converter, second_converter: Converter) -> bool:
        
        if isinstance(first_converter, ConversionChain):
            if isinstance(second_converter, ConversionChain):
                # BOTH are chains
                for sec_conv in second_converter._converters_list:
                    for fir_conv in first_converter._converters_list:
                        if not Converter.are_worth_chaining(fir_conv, sec_conv):
                            return False
            else:
                for fir_conv in first_converter._converters_list:
                    if not Converter.are_worth_chaining(fir_conv, second_converter):
                        return False
        else:
            if isinstance(second_converter, ConversionChain):
                for sec_conv in second_converter._converters_list:
                    if not Converter.are_worth_chaining(first_converter, sec_conv):
                        return False
            else:
                # Neither is a chain
                if not Converter.are_worth_chaining(first_converter, second_converter):
                    return False

        # finally return True if nothing proved otherwise
        return True
197904
@Trivial
    private static int getPriority(Converter<?> converter) {
        int value = ConfigConstants.DEFAULT_CONVERTER_PRIORITY;
        //get Priority annotations from class only, not from the super-class
        Priority[] priorities = converter.getClass().getDeclaredAnnotationsByType(Priority.class);
        if (priorities != null && priorities.length > 0) {
            Priority priority = priorities[0];
            value = priority.value();
        }
        return value;
    }
1317001
def xor_key(first, second, trafaret):
    
    trafaret = t.Trafaret._trafaret(trafaret)

    def check_(value):
        if (first in value) ^ (second in value):
            key = first if first in value else second
            yield first, t.catch_error(trafaret, value[key]), (key,)
        elif first in value and second in value:
            yield first, t.DataError(error='correct only if {} is not defined'.format(second)), (first,)
            yield second, t.DataError(error='correct only if {} is not defined'.format(first)), (second,)
        else:
            yield first, t.DataError(error='is required if {} is not defined'.format('second')), (first,)
            yield second, t.DataError(error='is required if {} is not defined'.format('first')), (second,)

    return check_
229752
def _coerce_method(converter):
    

    def wrapper(self):
        if len(self) == 1:
            return converter(self.iloc[0])
        raise TypeError("cannot convert the series to "
                        "{0}".format(str(converter)))

    wrapper.__name__ = "__{name}__".format(name=converter.__name__)
    return wrapper
471183
def converted_value(other_unit)
      if other_unit.special?
        other_unit.magnitude scalar
      else
        scalar / other_unit.scalar
      end
    end
1108380
public void init(Converter converter, Converter convIndent, int iIndentAmount)
    {
        m_convIndent = null;
        m_iIndentAmount = 0;
        super.init(converter);
        m_convIndent = convIndent;
        m_iIndentAmount = iIndentAmount;
    }
604168
def _hash_pair(first: bytes, second: bytes) -> bytes:
    
    if first is None:
        return second

    if second is None:
        return first

    if first > second:
        return keccak(second + first)
    else:
        return keccak(first + second)
1095376
def get_value(self, source):
    
    if self.source_name is None:
      present, value = True, self.convert(source)
      converted = True
    else:
      present, value = has_value(source, self.source_name)
      converted = False

    if not present or value is None:
      if self.is_required:
        raise ValueError("required value not present")
      else:
        return None
    else:
      if converted:
        return value
      else:
        return self.convert(value)
951665
def convert(self, element):
        """"""
        if isinstance(element, self.base_link_type):
            return element
        for converter in self.converters:
            link = converter(element)
            if link is not NotImplemented:
                return link
        raise TypeError('%r cannot be converted to a chainlink' % element)
429657
public void init(Converter converter, int iBitNumber, boolean trueIfMatch, boolean bTrueIfNull)
    {
        super.init(converter);
        m_iBitNumber = iBitNumber;
        m_bTrueIfMatch = trueIfMatch;
        m_bTrueIfNull = bTrueIfNull;
    }
133185
def union(self, other):
        
        if self._slideDuration != other._slideDuration:
            raise ValueError("the two DStream should have same slide duration")
        return self.transformWith(lambda a, b: a.union(b), other, True)
900368
def link(self, thing1, thing2):
		
		thing1 = thing1.strip().lower()
		thing2 = thing2.strip().lower()
		if thing1 == thing2:
			raise SameName("Attempted to link two of the same name")
		self.change(thing1, 0)
		self.change(thing2, 0)
		return self._link(thing1, thing2)
183380
def get_representative_chain_mapping(self, representative_id_1, representative_id_2):
        ''''''
        d = {}
        for pdb1_chain_id, matched_chain_list in self.chain_mapping[(representative_id_1, representative_id_2)].iteritems():
            d[pdb1_chain_id] = matched_chain_list.get_related_chains_ids('EC{0}'.format(representative_id_2))
        return d
1228988
def firstvalue(self, *fieldspecs, **kwargs):
        
        default = kwargs.get('default', None)
        values = [val for val in self.itervalues(*fieldspecs, **kwargs)]
        if values:
            return values[0]
        else:
            return default
979102
private final static boolean valuesMatch(Object value1, Object value2) {
        if (value1 == null) {
            return value2 == null;
        } else {
            return value1.equals(value2);
        }
    }
1112475
def chain(self, operation=ChainOperator.AND):
        
        if isinstance(operation, str):
            operation = ChainOperator(operation)
        self._chain = operation
        return self
1051640
function chain(fn, m) {
  if(!isFunction(fn)) {
    throw new TypeError('chain: Chain returning function required for first argument')
  }

  if(!(isChain(m) || isArray(m))) {
    throw new TypeError('chain: Chain of the same type required for second argument')
  }

  if(isArray(m)) {
    return _chain(fn, m)
  }

  return (m[fl.chain] || m.chain).call(m, fn)
}