Function that returns a Python callback to pretty print the events.
4439
def print_event(attributes=[]):
    
    def python_callback(event):
        cls_name = event.__class__.__name__
        attrs = ', '.join(['{attr}={val}'.format(attr=attr, val=event.__dict__[attr])
                       for attr in attributes])
        print('{cls_name}({attrs})'.format(cls_name=cls_name, attrs=attrs))
    return python_callback
1084077
def processEvent(cls, event):
        
        callbacks = cls.callbacks(type(event))
        keep_going = True
        remove_callbacks = []

        for callback, record, once in callbacks:
            if record is not None and record != event.record:
                continue

            callback(event)
            if once:
                remove_callbacks.append((callback, record))

            if event.preventDefault:
                keep_going = False
                break

        for callback, record in remove_callbacks:
            cls.removeCallback(type(event), callback, record=record)

        return keep_going
1228701
def debug_callback(event, *args, **kwds):
    '''
    '''
    l = ['event %s' % (event.type,)]
    if args:
        l.extend(map(str, args))
    if kwds:
        l.extend(sorted('%s=%s' % t for t in kwds.items()))
    print('Debug callback (%s)' % ', '.join(l))
1267919
def get_events(self):
        '''
        
        '''
        ret = []
        while True:
            event = self.event.get_event(wait=1, full=True)
            if event is None:
                return ret
            ret.append(event)
748335
def print_events(events):
    """"""
    columns = ['Date', 'Type', 'IP Address', 'label', 'username']
    table = formatting.Table(columns)
    for event in events:
        table.add_row([event.get('eventCreateDate'), event.get('eventName'),
                       event.get('ipAddress'), event.get('label'), event.get('username')])
    return table
283267
def pretty_print(self, obj=None):
        
        print(self.pretty(obj if obj is not None else self.obj))
1256121
def print_callback(val):
    
    success = False
    try:
        # for reasons I cannot fathom, regular printing, even directly
        # to io.stdout does not work.
        # I have to intrude rather deep into IPython to make it behave
        if have_ipython:
            if InteractiveShell.initialized():
                IPython.display.publish_display_data({'text/plain':val,'text/html':'<pre>' + val + '</pre>'})
                success = True
    except:
        pass

    if not success:
        print(val)
        sys.stdout.flush()
308615
def emit(self, event, *args, **kwargs):
        
        callbacks = self._callbacks.get(event, [])
        # Call the last callback if this is a single event.
        single = kwargs.pop('single', None)
        if single and callbacks:
            return callbacks[-1](*args, **kwargs)
        # Otherwise, return the list of callback outputs.
        res = []
        for callback in callbacks:
            res.append(callback(*args, **kwargs))
        return res
1291827
def callbacks(cls, eventType=None):
        
        key = '_{0}__callbacks'.format(cls.__name__)
        try:
            callbacks = getattr(cls, key)
        except AttributeError:
            callbacks = {}
            setattr(cls, key, callbacks)

        return callbacks.get(eventType, []) if eventType is not None else callbacks
356910
def event_return(events):
    '''
    
    '''

    for event in events:
        ret = event.get('data', False)

        if ret:
            returner(ret)
854231
def callback(self, output, inputs=[], state=[], events=[]): # pylint: disable=dangerous-default-value
        ''

        if isinstance(output, (list, tuple)):
            fixed_outputs = [self._fix_callback_item(x) for x in output]
            # Temporary check; can be removed once the library has been extended
            raise NotImplementedError("django-plotly-dash cannot handle multiple callback outputs at present")
        else:
            fixed_outputs = self._fix_callback_item(output)

        return super(WrappedDash, self).callback(fixed_outputs,
                                                 [self._fix_callback_item(x) for x in inputs],
                                                 [self._fix_callback_item(x) for x in state])
1114659
def event_return(events):
    '''
    
    '''
    if not events:
        # events is an empty list.
        # Don't open the logfile in vain.
        return
    opts = _get_options({})  # Pass in empty ret, since this is a list of events
    try:
        with salt.utils.files.flopen(opts['filename'], 'a') as logfile:
            for event in events:
                salt.utils.json.dump(event, logfile)
                logfile.write(str('\n'))  # future lint: disable=blacklisted-function
    except Exception:
        log.error('Could not write to rawdata_json file %s', opts['filename'])
        raise
29030
def listener(self, event):
        

        def decorator(listener):
            self.listeners[event].append(listener)
            return listener

        return decorator
131717
def emit(events, stream=None, Dumper=Dumper,
        canonical=None, indent=None, width=None,
        allow_unicode=None, line_break=None):
    
    getvalue = None
    if stream is None:
        from StringIO import StringIO
        stream = StringIO()
        getvalue = stream.getvalue
    dumper = Dumper(stream, canonical=canonical, indent=indent, width=width,
            allow_unicode=allow_unicode, line_break=line_break)
    try:
        for event in events:
            dumper.emit(event)
    finally:
        dumper.dispose()
    if getvalue:
        return getvalue()
328005
def print(self, *args, **kwargs):
        '''
        
        '''
        if self._last_args and self._last_args.verbose:
            print(*args, **kwargs)
1107592
def do_printActivities(self,args):
        """"""
        parser = CommandArgumentParser("printActivities")
        parser.add_argument('-r','--refresh',action='store_true',dest='refresh',help='refresh');
        args = vars(parser.parse_args(args))
        refresh = args['refresh'] or not self.activities

        if refresh:
            response = self.client.describe_scaling_activities(AutoScalingGroupName=self.scalingGroup)
            self.activities = response['Activities']
        
        index = 0
        for activity in self.activities:
            print "{}: {} -> {} {}: {}".format(index,activity['StartTime'],stdplus.defaultifyDict(activity,'EndTime',''),activity['StatusCode'],activity['Description'])
            index = index + 1
808326
function(events, name, callback, context, ctx) {
  if (callback) {
    var handlers = events[name] || (events[name] = []);
    handlers.push({callback: callback, context: context, ctx: context || ctx});
  }
  return events;
}