Creates new extractor capable of extracting a saga instance key from a message.
549341
public static <MESSAGE, KEY> FunctionKeyReader<MESSAGE, KEY> create(
            final Class<MESSAGE> messageClazz,
            final ContextKeyExtractFunction<MESSAGE, KEY>  contextReadFunction) {
        return new FunctionKeyReader<>(messageClazz, contextReadFunction);
    }
31118
public static Extractor createExtractor(String expression) {
        try {
            return INSTANCE.ctorExtractor.newInstance(expression);
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
586708
function extractMessages(nodes, interpolationConfig, implicitTags, implicitAttrs) {
	      var visitor = new _Visitor(implicitTags, implicitAttrs);
	      return visitor.extract(nodes, interpolationConfig);
	  }
1335272
function (message) {
    var objs = [], collector = '', chr, msglen, data;

    this.data += message;
    data = new Buffer(this.data, 'utf8');

    for (var i = 0; i < data.length; i += 1) {
        chr = data[i];
        if (chr > 47 && chr < 58) {
            collector += String.fromCharCode(chr);
        } else if (chr !== 10 && chr !== 13) {
            msglen = parseInt(collector, 10);

            if (msglen + i <= data.length) {
              objs.push(JSON.parse(data.toString('utf8', i, msglen + i)));
              data = data.slice(i + msglen);
              collector = '';
              i = 0;
            } else {
              break;
            }
        }
    }
    this.data = data.toString('utf8');
    return objs;
}
695882
public static MessageBuilder fromMessage(Message message) {
        MessageBuilder builder = new MessageBuilder();
        builder.getStringBuilder().append(message.getContent());
        if (!message.getEmbeds().isEmpty()) {
            builder.setEmbed(message.getEmbeds().get(0).toBuilder());
        }
        for (MessageAttachment attachment : message.getAttachments()) {
            // Since spoiler status is encoded in the file name, it is copied automatically.
            builder.addAttachment(attachment.getUrl());
        }
        return builder;
    }
331042
def extract(self, doc):
        
        if isinstance(self.jsonpaths, JSONPath):
            input_field = self.extractor.get_renamed_input_fields()
            if isinstance(self.extractor.get_renamed_input_fields(), list):
                input_field = input_field[0]

            jsonpath = self.jsonpaths
            renamed_inputs = dict()
            if self.flat_map_inputs:
                flat_mapped = itertools.chain.from_iterable(
                    [iter(match.value)
                     if hasattr(match.value, '__iter__') and
                     not isinstance(match.value, dict) and
                     not isinstance(match.value, basestring)
                     else iter([match.value])
                     for match in jsonpath.find(doc)])
                renamed_inputs[input_field] = flat_mapped
                if input_field in renamed_inputs:
                    self.extract_from_renamed_inputs(doc, renamed_inputs)

            else:
                for value in [match.value for match in jsonpath.find(doc)]:
                    renamed_inputs[input_field] = value
                    self.extract_from_renamed_inputs(doc, renamed_inputs)

        elif isinstance(self.jsonpaths, types.ListType):

            renamed_inputs_lists = dict()
            for jsonpath, renamed_input in \
                    itertools.izip(
                    iter(self.jsonpaths),
                    iter(self.extractor.get_renamed_input_fields())):
                renamed_inputs_lists[renamed_input] = [
                    match.value for match in jsonpath.find(doc)]

            if self.flat_map_inputs:
                renamed_inputs_tuple_lists = [
                    (x, itertools.chain.from_iterable(
                        [iter(z) if hasattr(z, '__iter__') and
                         not isinstance(z, dict) and
                         not isinstance(z, basestring)
                         else iter([z])for z in y]))
                    for x, y in renamed_inputs_lists.iteritems()]
                renamed_inputs = reduce(
                    ExtractorProcessor.add_tuple_to_doc,
                    renamed_inputs_tuple_lists, dict())
                self.extract_from_renamed_inputs(doc, renamed_inputs)
            else:
                renamed_inputs_lists_lists = [[(x, z) for z in y]
                                              for x, y in
                                              renamed_inputs_lists.iteritems()]
                for i in itertools.product(*renamed_inputs_lists_lists):
                    renamed_inputs = reduce(
                        ExtractorProcessor.add_tuple_to_doc, i, dict())
                    self.extract_from_renamed_inputs(doc, renamed_inputs)
        else:
            raise ValueError("input_fields must be a string or a list")

        return doc
1319343
def make_keyword_extractor(method):
    

    args, _1, _2, defs = inspect.getargspec(method)
    key_args = args[-len(defs or []):]
    def extractor(keys):
        new = {}
        for a in key_args:
            if a in keys:
                new[a] = keys[a]
                del keys[a]
        return new
    return extractor
835922
Object extractKey(DocumentExtractor extractor, int docIndex) {
      String strKey;
      try {
         strKey = (String) extractor.extract(docIndex).getId();
      } catch (IOException e) {
         throw new SearchException("Error while extracting key", e);
      }

      return keyTransformationHandler.stringToKey(strKey);
   }
618438
def _extract_sender(
    message: Message, resent_dates: List[Union[str, Header]] = None
) -> str:
    
    if resent_dates:
        sender_header = "Resent-Sender"
        from_header = "Resent-From"
    else:
        sender_header = "Sender"
        from_header = "From"

    # Prefer the sender field per RFC 2822:3.6.2.
    if sender_header in message:
        sender = message[sender_header]
    else:
        sender = message[from_header]

    return str(sender) if sender else ""
788149
private void extractInstance(ExtractionInstance instance) {
    PrototypeMemberDeclaration first = instance.declarations.get(0);
    String className = first.qualifiedClassName;
    if (pattern == Pattern.USE_GLOBAL_TEMP) {
      // Use the temp variable to hold the prototype.
      Node classNameNode = NodeUtil.newQName(compiler, className);
      classNameNode.putBooleanProp(Node.IS_CONSTANT_NAME, first.constant);
      Node stmt =
          IR.exprResult(
              IR.assign(
                  IR.name(PROTOTYPE_ALIAS),
                  IR.getprop(
                      classNameNode, IR.string("prototype"))))
          .useSourceInfoIfMissingFromForTree(first.node);

      instance.parent.addChildBefore(stmt, first.node);
      compiler.reportChangeToEnclosingScope(stmt);
    } else if (pattern == Pattern.USE_IIFE) {
      Node block = IR.block();
      Node func = IR.function(
           IR.name(""),
           IR.paramList(IR.name(PROTOTYPE_ALIAS)),
           block);

      Node call = IR.call(func,
           NodeUtil.newQName(
               compiler, className + ".prototype",
               instance.parent, className + ".prototype"));
      call.putIntProp(Node.FREE_CALL, 1);

      Node stmt = IR.exprResult(call);
      stmt.useSourceInfoIfMissingFromForTree(first.node);
      instance.parent.addChildBefore(stmt, first.node);
      compiler.reportChangeToEnclosingScope(stmt);
      for (PrototypeMemberDeclaration declar : instance.declarations) {
        compiler.reportChangeToEnclosingScope(declar.node);
        block.addChildToBack(declar.node.detach());
      }
    }
    // Go through each member declaration and replace it with an assignment
    // to the prototype variable.
    for (PrototypeMemberDeclaration declar : instance.declarations) {
      replacePrototypeMemberDeclaration(declar);
    }
  }
812271
def from_httplib(cls, message, duplicates=('set-cookie',)): # Python 2
        """"""
        ret = cls(message.items())
        # ret now contains only the last header line for each duplicate.
        # Importing with all duplicates would be nice, but this would
        # mean to repeat most of the raw parsing already done, when the
        # message object was created. Extracting only the headers of interest 
        # separately, the cookies, should be faster and requires less
        # extra code.
        for key in duplicates:
            ret.discard(key)
            for val in message.getheaders(key):
                ret.add(key, val)
            return ret
137254
function extractElementMessageWithoutSideEffects(jsxElement) {
    (0, _errors.assertInput)((0, _ast.isElementMarker)(jsxElement), "Attempted to extract message from non-marker", jsxElement);
    return Object.keys(extractFromSource((0, _generation2.default)(jsxElement)))[0];
}
334735
private Multimap<Class, SagaType> initializeMessageMappings(final Map<Class<? extends Saga>, SagaHandlersMap> handlersMap) {
        Multimap<Class, SagaType> scannedTypes = LinkedListMultimap.create();

        for (Map.Entry<Class<? extends Saga>, SagaHandlersMap> entry : handlersMap.entrySet()) {
            Class<? extends Saga> sagaClass = entry.getKey();

            Collection<MessageHandler> sagaHandlers = entry.getValue().messageHandlers();
            for (MessageHandler handler : sagaHandlers) {

                // remember all message types where a completely new saga needs to be started.
                if (handler.getStartsSaga()) {
                    scannedTypes.put(handler.getMessageType(), SagaType.startsNewSaga(sagaClass));
                } else {
                    scannedTypes.put(handler.getMessageType(), SagaType.continueSaga(sagaClass));
                }
            }
        }

        return scannedTypes;
    }
1000526
def from_dict(cls, serialized):
        '''
        '''
        # Some servers return lower case field names for message and code.
        # The Go client is tolerant of this, so be similarly tolerant here.
        def field(name):
            return serialized.get(name) or serialized.get(name.lower())
        return Error(
            code=field('Code'),
            message=field('Message'),
            info=ErrorInfo.from_dict(field('Info')),
            version=bakery.LATEST_VERSION,
        )
1293132
def parseLedgerForHaAndKeys(ledger, returnActive=True, ledger_size=None):
        
        nodeReg = OrderedDict()
        cliNodeReg = OrderedDict()
        nodeKeys = {}
        activeValidators = set()
        try:
            TxnStackManager._parse_pool_transaction_file(
                ledger, nodeReg, cliNodeReg, nodeKeys, activeValidators,
                ledger_size=ledger_size)
        except ValueError:
            errMsg = 'Pool transaction file corrupted. Rebuild pool transactions.'
            logger.exception(errMsg)
            exit(errMsg)

        if returnActive:
            allNodes = tuple(nodeReg.keys())
            for nodeName in allNodes:
                if nodeName not in activeValidators:
                    nodeReg.pop(nodeName, None)
                    cliNodeReg.pop(nodeName + CLIENT_STACK_SUFFIX, None)
                    nodeKeys.pop(nodeName, None)

            return nodeReg, cliNodeReg, nodeKeys
        else:
            return nodeReg, cliNodeReg, nodeKeys, activeValidators
458954
@Override
    @Nullable
    public KEY readKey(final MESSAGE message, final LookupContext context) {
        return extractFunction.key(message, context);
    }
998170
private <T extends Number> Gauge<Long> createKeyspaceGauge(String name, final MetricValue extractor)
    {
        allMetrics.add(name);
        return Metrics.newGauge(factory.createMetricName(name), new Gauge<Long>()
        {
            public Long value()
            {
                long sum = 0;
                for (ColumnFamilyStore cf : keyspace.getColumnFamilyStores())
                {
                    sum += extractor.getValue(cf.metric);
                }
                return sum;
            }
        });
    }