Distribute an existing event tuple.

        Args:
            mesg ((str,dict)):  An event tuple.

        Example:

            await base.dist( ('foo',{'bar':'baz'}) )
979832
async def dist(self, mesg):
        '''
        

        '''
        if self.isfini:
            return ()

        ret = []
        for func in self._syn_funcs.get(mesg[0], ()):

            try:
                ret.append(await s_coro.ornot(func, mesg))
            except asyncio.CancelledError:
                raise
            except Exception:
                logger.exception('base %s error with mesg %s', self, mesg)

        for func in self._syn_links:
            try:
                ret.append(await func(mesg))
            except asyncio.CancelledError:
                raise
            except Exception:
                logger.exception('base %s error with mesg %s', self, mesg)

        return ret
936143
def pave_event_space(fn=pair):
    
    global _event_space
    event_space = next(_event_space)

    @_ensure_seeders_list
    def p(seeders, delegator_factory, *args, **kwargs):
        return fn(seeders + [per_event_source_id(event_space)],
                  delegator_factory, *args, event_space=event_space, **kwargs)
    return p
1243602
def route_sns_task(event, context):
    
    record = event['Records'][0]
    message = json.loads(
            record['Sns']['Message']
        )
    return run_message(message)
1141330
def update(self, dist):
        
        assert isinstance(dist, DDist)
        for k, c in iteritems(dist.counts):
            self.counts[k] += c
        self.total += dist.total
1021782
def etag(self, etag):
        
        if not isinstance(etag, bytes):
            etag = bytes(etag, "utf-8")
        self._etag.append(etag)
1104619
def do_gn(self, arg):
        
        if self.cmdprefix:
            raise CmdError("prefix not allowed")
        if arg:
            raise CmdError("too many arguments")
        if self.lastEvent:
            self.lastEvent.continueStatus = win32.DBG_EXCEPTION_NOT_HANDLED
        return self.do_go(arg)
310829
def generate_localized_events(generator):
    

    if "i18n_subsites" in generator.settings["PLUGINS"]:
        if not os.path.exists(generator.settings['OUTPUT_PATH']):
            os.makedirs(generator.settings['OUTPUT_PATH'])

        for e in events:
            if "lang" in e.metadata:
                localized_events[e.metadata["lang"]].append(e)
            else:
                log.debug("event %s contains no lang attribute" % (e.metadata["title"],))
644131
def add_distribution(self, dist):
        
        logger.debug('adding distribution %s', dist)
        name = dist.key
        self.dists_by_name[name] = dist
        self.dists[(name, dist.version)] = dist
        for p in dist.provides:
            name, version = parse_name_and_version(p)
            logger.debug('Add to provided: %s, %s, %s', name, version, dist)
            self.provided.setdefault(name, set()).add((version, dist))
619857
def push_event(self, event_name, event_type, block_id):
        """"""
        self._db.rpush(event_name, dict(type=event_type, id=block_id))
528637
def put(self, event_type, event_data={}, **kwargs):
        
        event = dict(type=event_type, data=event_data)

        event["time"] = kwargs.get("time", datetime.utcnow().isoformat())

        if kwargs.get("id"):
            event["id"] = kwargs.get("id")

        data = json.dumps([event])

        r = requests.post(self.collector_url + 'event/put',
                          data=data,
                          headers={'content-type': 'application/json'})
        r.raise_for_status()

        return [event]
1124488
def pushmem(self, data, size):
        
        return lib.zmsg_pushmem(self._as_parameter_, data, size)
819177
def add_event_source(event_source, lambda_arn, target_function, boto_session, dry=False):
    

    event_source_obj, ctx, funk = get_event_source(event_source, lambda_arn, target_function, boto_session, dry=False)
    # TODO: Detect changes in config and refine exists algorithm
    if not dry:
        if not event_source_obj.status(funk):
            event_source_obj.add(funk)
            return 'successful' if event_source_obj.status(funk) else 'failed'
        else:
            return 'exists'

    return 'dryrun'
737824
def _create_event(self, alert_type, msg_title, msg, server, tags=None):
        
        msg_title = 'Couchbase {}: {}'.format(server, msg_title)
        msg = 'Couchbase instance {} {}'.format(server, msg)

        return {
            'timestamp': int(time.time()),
            'event_type': 'couchbase_rebalance',
            'msg_text': msg,
            'msg_title': msg_title,
            'alert_type': alert_type,
            'source_type_name': self.SOURCE_TYPE_NAME,
            'aggregation_key': server,
            'tags': tags,
        }
1210017
def explode(prefix: str):
    
    def _app(i, e=None):
        if i is not None:
            return {k: v for (k, v) in iter_fields(i)}, None
        return i, e

    def iter_fields(event_field: Union[dict, list]):
        if type(event_field) is dict:
            for key, val in event_field.items():
                yield (key, val)
        elif type(event_field) is list:
            for i, value in enumerate(event_field):
                for key, val in value.items():
                    if not i == 0:
                        yield ("{}_{}".format(key, i), val)
                    else:
                        yield (key, val)

    return compose(_app, add_column_prefix(prefix))
1063238
def run_mecab_process(content, *args, **kwargs):
    '''  '''
    encoding = 'utf-8' if 'encoding' not in kwargs else kwargs['encoding']
    mecab_loc = kwargs['mecab_loc'] if 'mecab_loc' in kwargs else None
    if mecab_loc is None:
        mecab_loc = MECAB_LOC
    proc_args = [mecab_loc]
    if args:
        proc_args.extend(args)
    output = subprocess.run(proc_args,
                            input=content.encode(encoding),
                            stdout=subprocess.PIPE)
    output_string = os.linesep.join(output.stdout.decode(encoding).splitlines())
    return output_string
871295
def lambda_handler(event, context=None, settings_name="zappa_settings"):  # NoQA
    
    time_start = datetime.datetime.now()

    # If in DEBUG mode, log all raw incoming events.
    if settings.DEBUG:
        logger.info('Zappa Event: {}'.format(event))

    # This is a normal HTTP request
    if event.get('method', None):

        # Create the environment for WSGI and handle the request
        environ = create_wsgi_request(event, script_name=settings.SCRIPT_NAME)

        # We are always on https on Lambda, so tell our wsgi app that.
        environ['HTTPS'] = 'on'
        environ['wsgi.url_scheme'] = 'https'

        wrap_me = get_wsgi_application()
        app = ZappaWSGIMiddleware(wrap_me)

        # Execute the application
        response = Response.from_app(app, environ)
        response.content = response.data

        # Prepare the special dictionary which will be returned to the API GW.
        returnme = {'Content': response.data}

        # Pack the WSGI response into our special dictionary.
        for (header_name, header_value) in response.headers:
            returnme[header_name] = header_value
        returnme['Status'] = response.status_code

        # To ensure correct status codes, we need to
        # pack the response as a deterministic B64 string and raise it
        # as an error to match our APIGW regex.
        # The DOCTYPE ensures that the page still renders in the browser.
        exception = None
        if response.status_code in ERROR_CODES:
            content = u"<!DOCTYPE html>" + unicode(response.status_code) + unicode('<meta charset="utf-8" />') + response.data.encode('utf-8')
            b64_content = base64.b64encode(content)
            exception = (b64_content)
        # Internal are changed to become relative redirects
        # so they still work for apps on raw APIGW and on a domain.
        elif 300 <= response.status_code < 400 and response.has_header('Location'):
            location = returnme['Location']
            location = '/' + location.replace("http://zappa/", "")
            exception = location

        # Calculate the total response time,
        # and log it in the Common Log format.
        time_end = datetime.datetime.now()
        delta = time_end - time_start
        response_time_ms = delta.total_seconds() * 1000
        common_log(environ, response, response_time=response_time_ms)

        # Finally, return the response to API Gateway.
        if exception:
            raise Exception(exception)
        else:
            return returnme

    # This is a management command invocation.
    elif event.get('command', None):
        from django.core import management

        # Couldn't figure out how to get the value into stdout with StringIO..
        # Read the log for now. :[]
        management.call_command(*event['command'].split(' '))
        return {}
    elif event.get('detail'):
        module, function = event['detail'].rsplit('.', 1)

        app_module = importlib.import_module(module)
        app_function = getattr(app_module, function)

        # Execute the function!
        app_function()
        return
    else:
        logger.error('Unhandled event: {}'.format(json.dumps(event)))
959340
def process(self, msg, kwargs):
        """"""
        prefixed_dict = {}
        prefixed_dict['repo_vcs'] = self.bin_name
        prefixed_dict['repo_name'] = self.name

        kwargs["extra"] = prefixed_dict

        return msg, kwargs