Get the JavaScript converter function from a rule.
961675
def js_to_url_function(converter):
    """"""
    if hasattr(converter, 'js_to_url_function'):
        data = converter.js_to_url_function()
    else:
        for cls in getmro(type(converter)):
            if cls in js_to_url_functions:
                data = js_to_url_functions[cls](converter)
                break
        else:
            return 'encodeURIComponent'
    return '(function(value) { %s })' % data
266934
def Convert(self, metadata, yara_match, token=None):
    """"""

    conv = ProcessToExportedProcessConverter(options=self.options)
    process = list(
        conv.Convert(ExportedMetadata(), yara_match.process, token=token))[0]

    seen_rules = set()
    for m in yara_match.match:
      if m.rule_name in seen_rules:
        continue

      seen_rules.add(m.rule_name)
      yield ExportedYaraProcessScanMatch(
          metadata=metadata,
          process=process,
          rule_name=m.rule_name,
          scan_time_us=yara_match.scan_time_us)
1095393
function getFormatFunction(name) {
  // lookup format
  const fmt = formats[name] || name || formats.default;
  // return compiled format
  return typeof fmt !== 'function' ? compile(fmt) : fmt;
}
302283
function validateRule(rule, value) {
    // For a given rule, get the first letter of the string name of its
    // constructor function. "R" -> RegExp, "F" -> Function (these shouldn't
    // conflict with any other types one might specify). Note: instead of
    // getting .toString from a new object {} or Object.prototype, I'm assuming
    // that exports will always be an object, and using its .toString method.
    // Bad idea? Let me know by filing an issue
    var type = exports.toString.call(rule).charAt(8);
    // If regexp, match. If function, invoke. Otherwise, compare. Note that ==
    // is used because type coercion is needed, as `value` will always be a
    // string, but `rule` might not.
    return type === "R" ? rule.test(value) : type === "F" ? rule(value) : rule == value;
  }
142596
def get_default_object_converters(conversion_finder: ConversionFinder) \
        -> List[Union[Converter[Any, Type[None]], Converter[Type[None], Any]]]:
    

    return [
            ConverterFunction(from_type=b64str, to_type=AnyObject, conversion_method=base64_ascii_str_pickle_to_object),
            ConverterFunction(from_type=DictOfDict, to_type=Any, conversion_method=dict_to_object,
                              custom_name='dict_of_dict_to_object',
                              is_able_to_convert_func=_is_valid_for_dict_to_object_conversion, unpack_options=False,
                              function_args={'conversion_finder': conversion_finder, 'is_dict_of_dicts': True}),
            ConverterFunction(from_type=dict, to_type=AnyObject, conversion_method=dict_to_object,
                              custom_name='dict_to_object', unpack_options=False,
                              is_able_to_convert_func=_is_valid_for_dict_to_object_conversion,
                              function_args={'conversion_finder': conversion_finder, 'is_dict_of_dicts': False})
            ]
174035
function typeOf (rule) {
  var ruleType = typeof rule
  
  return ruleType === 'function'
    ? ruleType
    : ruleType !== 'object'
      ? (rule.length === 0
          ? 'noop'
          : (rule === 0
              ? 'zero'
              : ruleType
            )
        )
      : Buffer.isBuffer(rule)
        ? 'buffer'
        : !isArray(rule)
          ? ((has(rule, 'start') && has(rule, 'end')
              ? 'range'
              : has(rule, 'start')
                ? 'rangestart'
                : has(rule, 'end')
                  ? 'rangeend'
                  : has(rule, 'firstOf')
                    ? (( (isArray(rule.firstOf) && sameTypeArray(rule.firstOf) )
                        || typeof rule.firstOf === 'string'
                        )
                      && rule.firstOf.length > 1
                      )
                        ? 'firstof'
                        : 'invalid firstof'
                    : 'invalid'
              )
              + '_object'
            )
          : !sameTypeArray(rule)
            ? 'multi types array'
            : ((Buffer.isBuffer( rule[0] )
                ? 'buffer'
                : typeof rule[0]
                )
                + '_array'
              )
}
1152712
def GetConvertersByClass(value_cls):
    """"""
    try:
      return ExportConverter.converters_cache[value_cls]
    except KeyError:
      results = [
          cls for cls in itervalues(ExportConverter.classes)
          if cls.input_rdf_type == value_cls
      ]
      if not results:
        results = [DataAgnosticExportConverter]

      ExportConverter.converters_cache[value_cls] = results
      return results
393630
def getsource(obj):
    """"""
    try:
        try:
            src = to_text_string(inspect.getsource(obj))
        except TypeError:
            if hasattr(obj, '__class__'):
                src = to_text_string(inspect.getsource(obj.__class__))
            else:
                # Bindings like VTK or ITK require this case
                src = getdoc(obj)
        return src
    except (TypeError, IOError):
        return
1127949
function Converter(srcAlphabet, dstAlphabet) {
    if (!srcAlphabet || !dstAlphabet || !srcAlphabet.length || !dstAlphabet.length) {
        throw new Error('Bad alphabet');
    }
    this.srcAlphabet = srcAlphabet;
    this.dstAlphabet = dstAlphabet;
}
1331161
function rule(analyzer) {
	var debug = require('debug');

	analyzer.setMetric('propertyResets');

	analyzer.on('selector', function(rule, selector) {
		var declarations = rule.declarations || [],
			properties;

		// prepare the list of properties used in this selector
		properties = declarations.
		map(function(declaration) {
			return (declaration.type === 'declaration') ? declaration.property : false;
		}).
		filter(function(item) {
			return item !== false;
		});

		debug('%s: %j', selector, properties);

		// iterate through all properties, expand shorthand properties and
		// check if there's no expanded version of it earlier in the array
		properties.forEach(function(property, idx) {
			var expanded;

			// skip if the current property is not the shorthand version
			if (typeof shorthandProperties.shorthandProperties[property] === 'undefined') {
				return;
			}

			// property = 'margin'
			// expanded = [ 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' ]
			expanded = shorthandProperties.expand(property);
			debug('%s: %s', property, expanded.join(', '));

			expanded.forEach(function(expandedProperty) {
				var propertyPos = properties.indexOf(expandedProperty);

				if (propertyPos > -1 && propertyPos < idx) {
					analyzer.incrMetric('propertyResets');
					analyzer.addOffender('propertyResets', format('%s: "%s" resets "%s" property set earlier', selector, property, expandedProperty));
				}
			});
		});
	});
}
922808
def convert(self, args, handler=None):
        """"""
        name = args
        field = attr = None
        opts = ()
        if isinstance(args, (list, tuple)):
            name, *opts = args
            if opts:
                attr = opts.pop()
            if opts:
                field = opts.pop()

        if not field and handler and handler.Schema:
            field = handler.Schema._declared_fields.get(attr or name) or \
                self.FILTER_CLASS.field_cls()
            field.attribute = field.attribute or attr or name
        return self.FILTER_CLASS(name, attr=attr, field=field, *opts)
438196
function getComputedTranslations(el, property) {
  // The transform being returned by `getComputedStyle` is in the format:
  // `matrix(a, b, c, d, translateX, translateY)` if defined and `none`
  // if the element doesn't have a transform.
  var transform = getComputedStyle(el[0] || el)[property];
  var openIndex = transform.indexOf('(');
  var closeIndex = transform.lastIndexOf(')');
  var output = { x: 0, y: 0 };

  if (openIndex > -1 && closeIndex > -1) {
    var parsedValues = transform
      .substring(openIndex + 1, closeIndex)
      .split(', ')
      .slice(-2);

    output.x = parseInt(parsedValues[0]);
    output.y = parseInt(parsedValues[1]);
  }

  return output;
}
332363
function Converter(css) {
  var parse = require('css-parse');
  this.css = css;
  this.root = parse(css, { position: false });
  this.indents = 0;
}
744890
function(field, rule) {
            var
              $field       = module.get.field(field.identifier),
              type         = rule.type,
              value        = $field.val(),
              isValid      = true,
              ancillary    = module.get.ancillaryValue(rule),
              ruleName     = module.get.ruleName(rule),
              ruleFunction = settings.rules[ruleName]
            ;
            if( !$.isFunction(ruleFunction) ) {
              module.error(error.noRule, ruleName);
              return;
            }
            // cast to string avoiding encoding special values
            value = (value === undefined || value === '' || value === null)
              ? ''
              : $.trim(value + '')
            ;
            return ruleFunction.call($field, value, ancillary);
          }
112893
function (ruleString) {
    var rule = {},
      ruleArray;

    rule.name = ruleString;

    if (ruleString.indexOf(':') >= 0) {
      ruleArray = ruleString.split(':');
      rule.name = ruleArray[0];
      rule.value = ruleArray.slice(1).join(":");
    }

    return rule;
  }
851428
private PropertyConverter getConverterForType(Class pType) {
        Object converter;
        Class cl = pType;

        // Loop until we find a suitable converter
        do {
            // Have a match, return converter
            if ((converter = getInstance().converters.get(cl)) != null) {
                return (PropertyConverter) converter;
            }

        }
        while ((cl = cl.getSuperclass()) != null);

        // No converter found, return null
        return null;
    }
1272089
def pw_converter(handler, flt):
    """"""
    import peewee as pw

    if isinstance(flt, Filter):
        return flt

    model = handler.model
    field = getattr(model, flt)

    if isinstance(field, pw.BooleanField):
        return PWBoolFilter(flt)

    if field.choices:
        choices = [(Filter.default, '---')] + list(field.choices)
        return PWChoiceFilter(flt, choices=choices)

    return PWFilter(flt)