Create an I/O handler that reads and writes a single data_and_metadata.

        :param io_handler_delegate: A delegate object :py:class:`DataAndMetadataIOHandlerInterface`

        .. versionadded:: 1.0

        Scriptable: No
194242
def create_data_and_metadata_io_handler(self, io_handler_delegate):
        
        class DelegateIOHandler(ImportExportManager.ImportExportHandler):
            def __init__(self):
                super().__init__(io_handler_delegate.io_handler_id, io_handler_delegate.io_handler_name, io_handler_delegate.io_handler_extensions)

            def read_data_elements(self, ui, extension, file_path):
                data_and_metadata = io_handler_delegate.read_data_and_metadata(extension, file_path)
                data_element = ImportExportManager.create_data_element_from_extended_data(data_and_metadata)
                return [data_element]

            def can_write(self, data_and_metadata, extension):
                return io_handler_delegate.can_write_data_and_metadata(data_and_metadata, extension)

            def write_display_item(self, ui, display_item: DisplayItemModule.DisplayItem, file_path: str, extension: str) -> None:
                data_item = display_item.data_item
                if data_item:
                    self.write_data_item(ui, data_item, file_path, extension)

            def write_data_item(self, ui, data_item, file_path, extension):
                data_and_metadata = data_item.xdata
                data = data_and_metadata.data
                if data is not None:
                    if hasattr(io_handler_delegate, "write_data_item"):
                        io_handler_delegate.write_data_item(DataItem(data_item), file_path, extension)
                    else:
                        assert hasattr(io_handler_delegate, "write_data_and_metadata")
                        io_handler_delegate.write_data_and_metadata(data_and_metadata, file_path, extension)

        class IOHandlerReference:

            def __init__(self):
                self.__io_handler_delegate = io_handler_delegate
                self.__io_handler = DelegateIOHandler()
                ImportExportManager.ImportExportManager().register_io_handler(self.__io_handler)

            def __del__(self):
                self.close()

            def close(self):
                if self.__io_handler_delegate:
                    io_handler_delegate_close_fn = getattr(self.__io_handler_delegate, "close", None)
                    if io_handler_delegate_close_fn:
                       io_handler_delegate_close_fn()
                    ImportExportManager.ImportExportManager().unregister_io_handler(self.__io_handler)
                    self.__io_handler_delegate = None

        return IOHandlerReference()
934482
function execObjectBindingHandlerOnNode(bindingKeyAndHandler, node, getValueAccessor, allBindings, bindingContext, reportBindingError) {
      var handlerInitFn = bindingKeyAndHandler.handler["init"],
          handlerUpdateFn = bindingKeyAndHandler.handler["update"],
          bindingKey = bindingKeyAndHandler.key,
          controlsDescendantBindings = false;

      // Run init, ignoring any dependencies
      if (typeof handlerInitFn === "function") {
          try {
              ignore(function() {
                  var initResult = handlerInitFn(node, getValueAccessor(bindingKey), allBindings, bindingContext.$data, bindingContext);

                  // If this binding handler claims to control descendant bindings, make a note of this
                  if (initResult && initResult.controlsDescendantBindings) {
                      controlsDescendantBindings = true;
                  }
              });
          } catch(ex) {
              reportBindingError('init', ex);
          }
      }

      // Run update in its own computed wrapper
      if (typeof handlerUpdateFn === "function") {
          computed(
              function() {
                  try {
                      handlerUpdateFn(node, getValueAccessor(bindingKey), allBindings, bindingContext.$data, bindingContext);
                  } catch (ex) {
                      reportBindingError('update', ex);
                  }
              },
              null,
              { disposeWhenNodeIsRemoved: node }
          );
      }
      return controlsDescendantBindings;
  }
406909
def _container_handler(ion_type, ctx):
    
    transition = None
    first = True
    at_top = ctx.depth == 0
    while True:
        data_event, self = (yield transition)
        if data_event is not None and data_event.type is ReadEventType.SKIP:
            yield ctx.read_data_transition(ctx.remaining, self, skip=True)

        if ctx.queue.position == ctx.limit:
            # We are at the end of the container.
            # Yield the close event and go to enclosing container.
            yield Transition(
                IonEvent(IonEventType.CONTAINER_END, ion_type, depth=ctx.depth-1),
                ctx.whence
            )

        if ion_type is IonType.STRUCT:
            # Read the field name.
            self_handler = _create_delegate_handler(self)
            (field_sid, _), _ = yield ctx.immediate_transition(
                _var_uint_field_handler(self_handler, ctx)
            )
            field_name = SymbolToken(None, field_sid)
        else:
            field_name = None

        expects_ivm = first and at_top
        transition = ctx.immediate_transition(
            _start_type_handler(field_name, self, ctx, expects_ivm, at_top=at_top)
        )
        first = False
470988
def handle_read_header(self, byte):
        '''
            
        '''
        
        (_, frmtcode, _, frmtidx, val) = self.util.find(byte)
        template = self._templatelist[frmtidx - 1]
        
        segmenttype = template.value.segmenttype        
        # single byte segment
       
        if segmenttype is SegmentType.SINGLE_BYTE:
            self._scstate = self.next_state_afterraw()
            self._state = self.create_state(frmtcode, template);
            self.events.append((self.value_event_type(EventType.VALUE), frmtcode, val))
            
        # next we should expect value
        elif segmenttype is SegmentType.HEADER_VALUE_PAIR:
            self._scstate = ScannerState.WAITING_FOR_VALUE
            self._state = self.create_state(frmtcode, template, length=template.value.length * template.value.multiplier);
        # next we should expect value
        elif segmenttype is SegmentType.HEADER_WITH_LENGTH_VALUE_PAIR:
            length = val * template.value.multiplier
            self._state = self.create_state(frmtcode, template, length=length);
            if self._state[1].value.valuetype is ValueType.NESTED:                
                self.events.append((self._state[1].value.startevent, frmtcode, None))
                if length is 0:
                    self._scstate = ScannerState.SEGMENT_ENDED
                else:
                    if template.value.multiplier is 2:
                        self.parentismap = 1
                        self.waitingforprop = 1
                    else:
                        self.parentismap = 0
                        self.waitingforprop = 0
                    self.push_state()
                    self._scstate = ScannerState.WAITING_FOR_HEADER
            else:          
                if length is 0:
                    self.events.append((self.value_event_type(EventType.VALUE), self._state[0], self.empty_value(self._state[0])))
                    self._scstate = self.next_state_afterraw()
                else:
                    self._scstate = ScannerState.WAITING_FOR_VALUE
        # next we should expect length
        elif segmenttype is SegmentType.VARIABLE_LENGTH_VALUE:
            self._scstate = ScannerState.WAITING_FOR_LENGTH
            self._state = self.create_state(frmtcode, template, length=template.value.length);
        # next we should expect length
        elif segmenttype is SegmentType.EXT_FORMAT:
            self._scstate = ScannerState.WAITING_FOR_LENGTH
            self._state = self.create_state(frmtcode, template, length=template.value.length);
        # next we should expect type       
        elif segmenttype is SegmentType.FIXED_EXT_FORMAT:
            self._state = self.create_state(frmtcode, template, length=template.value.length);
            self._scstate = ScannerState.WAITING_FOR_EXT_TYPE
        else:
            raise InvalidStateException(self._scstate, "header")
7900
private void handleWithDelegate(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
        //Delegate to handler
        boolean foundHandler = REST_HANDLER_CONTAINER.handleRequest(new ServletRESTRequestImpl(request), new ServletRESTResponseImpl(response));
        //RESTHandler handler = REST_HANDLER_CONTAINER.getHandler(pathInfo);
        if (!foundHandler) {
            //No handler found, so we send back a 404 "not found" response.
            String errorMsg = Tr.formatMessage(tc, "HANDLER_NOT_FOUND_ERROR", request.getRequestURI());
            response.sendError(HttpServletResponse.SC_NOT_FOUND, errorMsg);
        }
    }
1111197
private void writeToDelegate(byte[] data) {

        if (m_delegateStream != null) {
            try {
                m_delegateStream.write(data);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
705628
def request_io(self, iocb):
        """"""
        if _debug: IOController._debug("request_io %r", iocb)

        # check that the parameter is an IOCB
        if not isinstance(iocb, IOCB):
            raise TypeError("IOCB expected")

        # bind the iocb to this controller
        iocb.ioController = self

        try:
            # hopefully there won't be an error
            err = None

            # change the state
            iocb.ioState = PENDING

            # let derived class figure out how to process this
            self.process_io(iocb)
        except:
            # extract the error
            err = sys.exc_info()[1]

        # if there was an error, abort the request
        if err:
            self.abort_io(iocb, err)
1066771
private void handleWithDelegate(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
        //Delegate to handler
        boolean foundHandler = REST_HANDLER_CONTAINER.handleRequest(new ServletRESTRequestImpl(request), new ServletRESTResponseImpl(response));

        if (!foundHandler) {
            //No handler found, so we send back a 404 "not found" response.
            String errorMsg = TraceNLS.getFormattedMessage(this.getClass(),
                                                           TraceConstants.TRACE_BUNDLE_CORE,
                                                           "HANDLER_NOT_FOUND_ERROR",
                                                           new Object[] { request.getRequestURI() },
                                                           "CWWKO1000E: There are no registered handlers that match the requested URL {0}");
            response.sendError(HttpServletResponse.SC_NOT_FOUND, errorMsg);
        }
    }
1066131
def set_event_handler(self, event_handler):
        '''
        
        '''
        assert not self._run_io_loop_sync

        if not self.cpub:
            self.connect_pub()

        self.subscriber.callbacks.add(event_handler)
        if not self.subscriber.reading:
            # This will handle reconnects
            return self.subscriber.read_async()
12102
def _execute(self, ifile, process):
        
        if self._protocol_version == 2:
            result = self._read_chunk(ifile)

            if not result:
                return

            metadata, body = result
            action = getattr(metadata, 'action', None)

            if action != 'execute':
                raise RuntimeError('Expected execute action, not {}'.format(action))

        self._record_writer.write_records(self.generate())
        self.finish()
172812
public synchronized void setHandler(Handler handler) {
        String handlerId = CollectorManagerUtils.getHandlerId(handler);
        HandlerManager hdlrMgr;
        if (!handlerMgrs.containsKey(handlerId)) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "Adding handler to the list", handler.getClass());
            }
            hdlrMgr = new HandlerManager(handler);
            handlerMgrs.put(hdlrMgr.getHandlerId(), hdlrMgr);
            hdlrMgr.getHandler().init(this);
        }
    }
1005319
def log_level(io_handler, level=None, name=None):
        
        # Get the logger
        logger = logging.getLogger(name)

        # Normalize the name
        if not name:
            name = "Root"

        if not level:
            # Level not given: print the logger level
            io_handler.write_line(
                "{0} log level: {1} (real: {2})",
                name,
                logging.getLevelName(logger.getEffectiveLevel()),
                logging.getLevelName(logger.level),
            )
        else:
            # Set the logger level
            try:
                logger.setLevel(level.upper())
                io_handler.write_line("New level for {0}: {1}", name, level)
            except ValueError:
                io_handler.write_line("Invalid log level: {0}", level)
347639
def _handle_socket(self, event: int, fd: int, multi: Any, data: bytes) -> None:
        
        event_map = {
            pycurl.POLL_NONE: ioloop.IOLoop.NONE,
            pycurl.POLL_IN: ioloop.IOLoop.READ,
            pycurl.POLL_OUT: ioloop.IOLoop.WRITE,
            pycurl.POLL_INOUT: ioloop.IOLoop.READ | ioloop.IOLoop.WRITE,
        }
        if event == pycurl.POLL_REMOVE:
            if fd in self._fds:
                self.io_loop.remove_handler(fd)
                del self._fds[fd]
        else:
            ioloop_event = event_map[event]
            # libcurl sometimes closes a socket and then opens a new
            # one using the same FD without giving us a POLL_NONE in
            # between.  This is a problem with the epoll IOLoop,
            # because the kernel can tell when a socket is closed and
            # removes it from the epoll automatically, causing future
            # update_handler calls to fail.  Since we can't tell when
            # this has happened, always use remove and re-add
            # instead of update.
            if fd in self._fds:
                self.io_loop.remove_handler(fd)
            self.io_loop.add_handler(fd, self._handle_events, ioloop_event)
            self._fds[fd] = ioloop_event
1374214
def _create_handler(self, handler_class, level):
        """"""
        if handler_class == logging.StreamHandler:
            handler = handler_class()
            handler.setLevel(level)
        elif handler_class == logging.handlers.SysLogHandler:
            handler = handler_class(address='/dev/log')
            handler.setLevel(level)
        elif handler_class == logging.handlers.TimedRotatingFileHandler:
            handler = handler_class(self.filename, when='midnight')
            handler.setLevel(level)
        elif handler_class == AlkiviEmailHandler:
            handler = handler_class(mailhost='127.0.0.1',
                                    fromaddr="%s@%s" % (USER, HOST),
                                    toaddrs=self.emails,
                                    level=self.min_log_level_to_mail)
            # Needed, we want all logs to go there
            handler.setLevel(0)

        formatter = self.get_formatter(handler)
        handler.setFormatter(formatter)
        self.handlers.append(handler)
        self.logger.addHandler(handler)
243432
def __handler(self, connection, event):
        
        try:
            # Find local handler
            method = getattr(self, "on_{0}".format(event.type))
        except AttributeError:
            pass
        else:
            try:
                # Call it
                return method(connection, event)
            except Exception as ex:
                logging.exception("Error calling handler: %s", ex)
321490
private void writeMetaData(Definition def, Writer out, int indent) throws IOException
   {
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent,
            " * Gets the information on the underlying EIS instance represented through an active connection.\n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent,
            " * @return ConnectionMetaData instance representing information about the EIS instance\n");
      writeWithIndent(out, indent,
            " * @throws ResourceException Failed to get information about the connected EIS instance. \n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "@Override\n");
      writeWithIndent(out, indent, "public ConnectionMetaData getMetaData() throws ResourceException");
      writeLeftCurlyBracket(out, indent);

      writeWithIndent(out, indent + 1, "return new " + def.getMcfDefs().get(getNumOfMcf()).getConnMetaClass() + "();");
      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
60260
public Metadata readMetadata(InputStream stream, Charset encoding, String filePath, @Nullable CharHandler otherHandler) {
    LineCounter lineCounter = new LineCounter(filePath, encoding);
    FileHashComputer fileHashComputer = new FileHashComputer(filePath);
    LineOffsetCounter lineOffsetCounter = new LineOffsetCounter();

    if (otherHandler != null) {
      CharHandler[] handlers = {lineCounter, fileHashComputer, lineOffsetCounter, otherHandler};
      readFile(stream, encoding, filePath, handlers);
    } else {
      CharHandler[] handlers = {lineCounter, fileHashComputer, lineOffsetCounter};
      readFile(stream, encoding, filePath, handlers);
    }
    return new Metadata(lineCounter.lines(), lineCounter.nonBlankLines(), fileHashComputer.getHash(), lineOffsetCounter.getOriginalLineStartOffsets(),
      lineOffsetCounter.getOriginalLineEndOffsets(),
      lineOffsetCounter.getLastValidOffset());
  }