process

Here are the examples of how to process in python. These are taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2537 Examples 7

    def _process(self):
        form = AgreementForm()
        if form.validate_on_submit() and self.agreement.pending:
            reason = form.reason.data if not form.agreed.data else None
            func = self.agreement.accept if form.agreed.data else self.agreement.reject
            func(from_ip=request.remote_addr, reason=reason)
            if self.agreement.definition.event_settings.get(self.event_new, 'manager_notifications_enabled'):
                notify_new_signature_to_manager(self.agreement)
            return redirect(url_for('.agreement_form', self.agreement, uuid=self.agreement.uuid))
        html = self.agreement.render(form)
        return WPAgreementForm.render_string(html, self._conf)

    def _process( self ):

        ipAddress = self._params.get('ipAddress', None)

        if ipAddress:
            try:
                ipAddress = unicode(ip_address(unicode(ipAddress)))
            except ValueError as exc:
                raise MaKaCError("IP Address {} is not valid: {}".format(ipAddress, exc))
            else:
                minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
                ip_acl_mgr = minfo.getIPBasedACLMgr()
                ip_acl_mgr.grant_full_access(ipAddress)

        self._redirect(urlHandlers.UHIPBasedACL.getURL())

    def _process( self ):
        choice = self._target.getConference().getConfPaperReview().getChoice()
        if choice == 2 or choice == 4:
            self._rm.addReviewer(user.AvatarHolder().getById(self._reviewer))
            self._redirect(url_for('event_mgmt.contributionReviewing', self.contrib))
        else:
            raise MaKaCError("Reviewing mode does not allow content reviewing")

    def _process(self):
        self.regform.end_dt = now_utc()
        if not self.regform.has_started:
            self.regform.start_dt = self.regform.end_dt
        flash(_("Registrations for {} are now closed").format(self.regform.title), 'success')
        logger.info("Registrations for %s closed by %s", self.regform, session.user)
        return redirect(url_for('.manage_regform', self.regform))

    def _process(self):
        form = SessionForm(obj=self.session, event=self.event_new)
        if form.validate_on_submit():
            update_session(self.session, form.data)
            return jsonify_data(html=_render_session_list(self.event_new))
        return jsonify_form(form)

def _process(name, lexer):
    from pygments import highlight
    from pygments.formatters import HtmlFormatter
    source = open("templates/front/snippets/%s.txt" % name).read()
    processed = highlight(source, lexer, HtmlFormatter())
    processed = processed.replace("PING_URL", "{{ ping_url }}")
    processed = processed.replace("SITE_ROOT", "{{ SITE_ROOT }}")
    processed = processed.replace("PING_ENDPOINT", "{{ PING_ENDPOINT }}")
    with open("templates/front/snippets/%s.html" % name, "w") as out:
        out.write(processed)

    def _process(self):
        room_event_assocs = VCRoomEventAssociation.find_for_event(self.event_new, include_hidden=True,
                                                                  include_deleted=True).all()
        event_vc_rooms = [event_vc_room for event_vc_room in room_event_assocs if event_vc_room.vc_room.plugin]
        return WPVCManageEvent.render_template('manage_event.html', self._conf, event=self._conf,
                                               event_vc_rooms=event_vc_rooms, plugins=get_vc_plugins().values())

    def _process(self):
        extra_preferences = [pref(self.user) for pref in values_from_signal(signals.users.preferences.send(self.user))]
        form_class = UserPreferencesForm
        defaults = FormDefaults(**self.user.settings.get_all(self.user))
        for pref in extra_preferences:
            form_class = pref.extend_form(form_class)
            pref.extend_defaults(defaults)
        form = form_class(obj=defaults)
        if form.validate_on_submit():
            data = form.data
            for pref in extra_preferences:
                pref.process_form_data(data)
            self.user.settings.set_multi(data)
            session.lang = self.user.settings.get('lang')
            session.timezone = (self.user.settings.get('timezone') if self.user.settings.get('force_timezone')
                                else 'LOCAL')
            flash(_('Preferences saved'), 'success')
            return redirect(url_for('.user_preferences'))
        return WPUser.render_template('preferences.html', 'preferences', user=self.user, form=form)

    def _process(self):
        if self.list_generator.static_link_used:
            return redirect(self.list_generator.get_list_url())
        reg_list_kwargs = self.list_generator.get_list_kwargs()
        return WPManageRegistration.render_template('management/regform_reglist.html', self.event, regform=self.regform,
                                                    event=self.event, **reg_list_kwargs)

    def _process( self ):
        url = urlHandlers.UHTrackAbstractModif.getURL( self._track, self._abstract )
        if self._action == "CANCEL":
            self._redirect( url )
        elif self._action == "GO":
            if self._propTracks != []:
                r = self._getUser()
                self._abstract.proposeForOtherTracks( r, self._track, self._comment, self._propTracks )
            self._redirect( url )
        else:
            p = tracks.WPAbstractPropForOtherTracks( self, self._track, self._abstract )
            return p.display()

    def _process(self):
        urls = {}
        api_key = session.user.api_key if session.user else None
        url_format = '/export/event/{0}/{1}/{2}.ics'
        if isinstance(self.object, Contribution):
            event = self.object.event_new
            urls = generate_public_auth_request(api_key, url_format.format(event.id, 'contribution', self.object.id))
        elif isinstance(self.object, Session):
            event = self.object.event_new
            urls = generate_public_auth_request(api_key, url_format.format(event.id, 'session', self.object.id))
        elif isinstance(self.object, Category):
            urls = generate_public_auth_request(api_key, '/export/categ/{0}.ics'.format(self.object.id))
        elif isinstance(self.object, Event):
            urls = generate_public_auth_request(api_key, '/export/event/{0}.ics'.format(self.object.id))
            event_urls = generate_public_auth_request(api_key, '/export/event/{0}.ics'.format(self.object.id),
                                                      {'detail': 'contribution'})
            urls['publicRequestDetailedURL'] = event_urls['publicRequestURL']
            urls['authRequestDetailedURL'] = event_urls['authRequestURL']
        return jsonify_data(flash=False, urls=urls)

def _process(value, sha=False):
    if isinstance(value, (six.text_type, bytes)):
        if sha:
            return hashlib.sha1(to_bytes(value)).hexdigest()
        return 'h', hash(value)
    if isinstance(value, dict):
        return {_process(k, sha=True): _process(v, sha) for k, v in value.items()}
    if isinstance(value, (list, tuple)):
        return [_process(v, sha) for v in value]
    return value

    def _process(self):
        msg = spade.ACLMessage.ACLMessage()
        msg.setPerformative("inform")
        msg.addReceiver(spade.AID.aid("[email protected]" + host, ["http://" + host + ":2100/b"]))
        msg.setContent("HTTPtestSendJSONMsg")
        msg.setAclRepresentation(spade.ACLMessage.FIPA_ACL_REP_JSON)

        self.myAgent.send(msg)

    def _process(self):

        aad = spade.AMS.AmsAgentDescription()
        #aad.setAID(spade.AID.aid(self.s+"@"+host,["xmpp://"+self.s+"@"+host]))
        aad.ownership = "UNITTEST"
        self.myAgent.result = self.myAgent.modifyAgent(aad)

        aad = spade.AMS.AmsAgentDescription()
        aad.setAID(spade.AID.aid(self.s + "@" + host, ["xmpp://" + self.s + "@" + host]))
        self.myAgent.search = self.myAgent.searchAgent(aad)

    def _process(self):
        if not self.category.has_icon:
            raise NotFound
        metadata = self.category.icon_metadata
        return send_file(metadata['filename'], BytesIO(self.category.icon), mimetype=metadata['content_type'],
                         conditional=True)

    def _process(self):
        form = AdminAccountRegistrationForm()
        if form.validate_on_submit():
            data = form.data
            identity = Identity(provider='indico', identifier=data.pop('username'), password=data.pop('password'))
            user = create_user(data.pop('email'), data, identity, from_moderation=True)
            msg = Markup('{} <a href="{}">{}</a>').format(
                escape(_('The account has been created.')),
                url_for('users.user_profile', user),
                escape(_('Show details'))
            )
            flash(msg, 'success')
            return jsonify_data()
        return jsonify_template('users/users_admin_create.html', form=form)

    def _process( self ):
        url=urlHandlers.UHAbstractManagment.getURL(self._target)
        if isinstance(self._abstract.getCurrentStatus(), (review.AbstractStatusWithdrawn, review.AbstractStatusRejected)):
            self._abstract.setCurrentStatus(review.AbstractStatusSubmitted(self._abstract))
        elif isinstance(self._abstract.getCurrentStatus(), review.AbstractStatusAccepted):
            # remove the associated contribution
            self._removeAssociatedContribution()
            # set submittted status
            self._abstract.setCurrentStatus(review.AbstractStatusSubmitted(self._abstract))
        self._redirect(url)

    def _process(self):
        defaults = FormDefaults(self.entry)
        if self.entry.is_user_link:
            form_cls = MenuLinkForm
        elif self.entry.is_page:
            form_cls = MenuPageForm
            defaults['html'] = self.entry.page.html
        else:
            form_cls = MenuBuiltinEntryForm
            defaults = FormDefaults(self.entry, skip_attrs={'title'},
                                    title=self.entry.title or self.entry.default_data.title,
                                    custom_title=self.entry.title is not None)
        form = form_cls(entry=self.entry, obj=defaults)
        if form.validate_on_submit():
            form.populate_obj(self.entry, skip={'html', 'custom_title'})
            if self.entry.is_page:
                self.entry.page.html = form.html.data
            return jsonify_data(entry=_render_menu_entry(self.entry))
        return jsonify_form(form)

    def _process(self, lnst_recipe):
        recipe = XmlData(lnst_recipe)

        # machines
        machines_tag = lnst_recipe.find("network")
        if machines_tag is not None:
            machines = recipe["machines"] = XmlCollection(machines_tag)
            for machine_tag in machines_tag:
                machines.append(self._process_machine(machine_tag))

        # tasks
        tasks = recipe["tasks"] = XmlCollection()
        task_tags = lnst_recipe.findall("task")
        for task_tag in task_tags:
            tasks.append(self._process_task(task_tag))

        return recipe

    def _process(self, g, m):
        """
        Estimate the orientation Quaternion from the observed vectors.

        @param g: the observed gravitational field vector (3x1 L{np.ndarray})
        @param m: the observed magnetic field vector (3x1 L{np.ndarray})
        @return: The estimated orientation L{Quaternion}
        """
        z = g / vectors.norm(g)
        y = vectors.cross(z, m)
        y /= vectors.norm(y)
        x = vectors.cross(y, z)

        return Quaternion.fromVectors(x, y, z)

3
File: api.py, Project: wikiwho, View license
uses: requests.codes.ok
	def __process(self, requester, data):
		data.update({'format': 'json'})
		response = requester(self.uri, data)
	
		if response.status_code == requests.codes.ok:
			#print(response.text)
			js = json.loads(response.text)
			if 'error' in js: 
				raise MediaWikiAPIError("%s: %s" % (js['error'].get('code'), js['error'].get('info')))
			else:
				return js
			
		else:
			response.raise_for_status()

    def _process(self, q_target_beats):
        from abjad.tools import quantizationtools
        for q_target_beat in q_target_beats:
            q_grids = q_target_beat.q_grids
            if q_grids:
                sorted_q_grids = sorted(
                    q_grids, key=lambda x: (x.distance, len(x.leaves)))
                q_target_beat._q_grid = sorted_q_grids[0]
            else:
                q_target_beat._q_grid = quantizationtools.QGrid()
        return q_target_beats

    def _process(self):
        form = ApplicationForm(obj=FormDefaults(is_enabled=True))
        if form.validate_on_submit():
            application = OAuthApplication()
            form.populate_obj(application)
            db.session.add(application)
            db.session.flush()
            logger.info("Application %s created by %s", application, session.user)
            flash(_("Application {} registered successfully").format(application.name), 'success')
            return redirect(url_for('.app_details', application))
        return WPOAuthAdmin.render_template('app_new.html', form=form)

    def _process(self):
        room = self._reservation.room
        form = ModifyBookingForm(obj=self._reservation,
                                 old_start_dt=self._reservation.start_dt, old_end_dt=self._reservation.end_dt)
        form.used_equipment.query = room.find_available_vc_equipment()

        if not room.notification_for_assistance and not self._reservation.needs_assistance:
            del form.needs_assistance

        invalid_form = form.is_submitted() and not form.validate()
        if invalid_form:
            occurrences = {}
            candidates = {}
            conflicts = {}
            pre_conflicts = {}
        else:
            occurrences, candidates = self._get_all_occurrences([room.id], form, reservation_id=self._reservation.id)
            conflicts, pre_conflicts = self._get_all_conflicts(room, form, self._reservation.id)

        if form.validate_on_submit() and not form.submit_check.data:
            try:
                self._reservation.modify(form.data, session.user)
                flash(_(u'Booking updated'), 'success')
            except NoReportError as e:
                transaction.abort()
                return jsonify(success=False, msg=unicode(e))
            return jsonify(success=True, url=self._get_success_url())

        elif invalid_form and not form.submit_check.data and request.is_xhr:
            return jsonify(success=False, msg='\n'.join(form.error_list))

        return self._get_view(form=form, room=room, rooms=Room.find_all(), occurrences=occurrences,
                              candidates=candidates, conflicts=conflicts, pre_conflicts=pre_conflicts,
                              start_dt=form.start_dt.data, end_dt=form.end_dt.data, only_conflicts=False,
                              repeat_frequency=form.repeat_frequency.data, repeat_interval=form.repeat_interval.data,
                              reservation=self._reservation,
                              can_override=room.can_be_overridden(session.user)).display()

    def _process(self):
        custom_fields = self.event_new.contribution_fields.order_by(ContributionField.position)
        custom_field_types = sorted(get_contrib_field_types().values(), key=attrgetter('friendly_name'))
        return jsonify_template('events/contributions/management/fields_dialog.html', event=self.event_new,
                                custom_fields=custom_fields, custom_field_types=custom_field_types)

    def _process(self):
        user = User.get(int(request.view_args['fav_user_id']))
        if user in self.user.favorite_users:
            self.user.favorite_users.remove(user)
        return jsonify(success=True)

    def _process(self):
        if not self.plugin.can_manage_vc_rooms(session.user, self.event_new):
            flash(_('You are not allowed to create {plugin_name} rooms for this event.').format(
                plugin_name=self.plugin.friendly_name), 'error')
            return redirect(url_for('.manage_vc_rooms', self.event_new))

        form = self.plugin.create_form(event=self.event_new)

        if form.validate_on_submit():
            vc_room = VCRoom(created_by_user=session.user)
            vc_room.type = self.plugin.service_name
            vc_room.status = VCRoomStatus.created

            event_vc_room = process_vc_room_association(self.plugin, self.event_new, vc_room, form)
            if not event_vc_room:
                return redirect(url_for('.manage_vc_rooms', self.event_new))

            with db.session.no_autoflush:
                self.plugin.update_data_vc_room(vc_room, form.data)

            try:
                # avoid flushing the incomplete vc room to the database
                with db.session.no_autoflush:
                    self.plugin.create_room(vc_room, self.event_new)
                notify_created(self.plugin, vc_room, event_vc_room, self.event_new, session.user)
            except VCRoomError as err:
                if err.field is None:
                    raise
                field = getattr(form, err.field)
                field.errors.append(err.message)
                transaction.abort()  # otherwise the incomplete vc room would be added to the db!
            else:
                db.session.add(vc_room)
                # TODO: notify_created(vc_room, self.event_new, session.user)

                flash(_("{plugin_name} room '{room.name}' created").format(
                    plugin_name=self.plugin.friendly_name, room=vc_room), 'success')
                return jsonify_data(flash=False)

        form_html = self.plugin.render_form(plugin=self.plugin, event=self.event_new, form=form,
                                            skip_fields=form.skip_fields | {'name'})

        return jsonify(html=form_html, js=_pop_injected_js())

    def __process(self, apiData, classFilter=None, internals=False, privates=False, printErrors=True, highlightCode=True):
        
        knownClasses = set(list(apiData))


        #
        # Attaching Links to Source Code (Lines)
        # Building Docuementation Summaries
        #

        
        Console.info("Adding Source Links...")

        for className in apiData:
            classApi = apiData[className]

            constructData = getattr(classApi, "construct", None)
            if constructData is not None:
                if "line" in constructData:
                    constructData["sourceLink"] = "source:%s~%s" % (className, constructData["line"])

            for section in ("properties", "events", "statics", "members"):
                sectionData = getattr(classApi, section, None)

                if sectionData is not None:
                    for name in sectionData:
                        if "line" in sectionData[name]:
                            sectionData[name]["sourceLink"] = "source:%s~%s" % (className, sectionData[name]["line"])



        #
        # Including Mixins / IncludedBy
        #

        Console.info("Resolving Mixins...")
        Console.indent()

        # Just used temporary to keep track of which classes are merged
        mergedClasses = set()

        def getApi(className):
            classApi = apiData[className]

            if className in mergedClasses:
                return classApi

            classIncludes = getattr(classApi, "includes", None)
            if classIncludes:
                for mixinName in classIncludes:
                    if not mixinName in apiData:
                        Console.error("Invalid mixin %s in class %s", className, mixinName)
                        continue
                        
                    mixinApi = apiData[mixinName]
                    if not hasattr(mixinApi, "includedBy"):
                        mixinApi.includedBy = set()

                    mixinApi.includedBy.add(className)
                    mergeMixin(className, mixinName, classApi, getApi(mixinName))

            mergedClasses.add(className)

            return classApi

        for className in apiData:
            apiData[className] = getApi(className)

        Console.outdent()



        #
        # Checking links
        #
        
        Console.info("Checking Links...")
        
        additionalTypes = ("Call", "Identifier", "Map", "Integer", "Node", "Element")
        
        def checkInternalLink(link, className):
            match = internalLinkParse.match(link)
            if not match:
                return 'Invalid link "#%s"' % link
                
            if match.group(3) is not None:
                className = match.group(3)
                
            if not className in knownClasses and not className in apiData:
                return 'Invalid class in link "#%s"' % link
                
            # Accept all section/item values for named classes,
            # as it might be pretty complicated to verify this here.
            if not className in apiData:
                return True
                
            classApi = apiData[className]
            sectionName = match.group(2)
            itemName = match.group(5)
            
            if itemName is None:
                return True
                
            if sectionName is not None:
                if not sectionName in linkMap:
                    return 'Invalid section in link "#%s"' % link
                    
                section = getattr(classApi, linkMap[sectionName], None)
                if section is None:
                    return 'Invalid section in link "#%s"' % link
                else:
                    if itemName in section:
                        return True
                        
                    return 'Invalid item in link "#%s"' % link
            
            for sectionName in ("statics", "members", "properties", "events"):
                section = getattr(classApi, sectionName, None)
                if section and itemName in section:
                    return True
                
            return 'Invalid item link "#%s"' % link


        def checkLinksInItem(item):
            
            # Process types
            if "type" in item:
                
                if item["type"] == "Function":

                    # Check param types
                    if "params" in item:
                        for paramName in item["params"]:
                            paramEntry = item["params"][paramName]
                            if "type" in paramEntry:
                                for paramTypeEntry in paramEntry["type"]:
                                    if not paramTypeEntry["name"] in knownClasses and not paramTypeEntry["name"] in additionalTypes and not ("builtin" in paramTypeEntry or "pseudo" in paramTypeEntry):
                                        item["errornous"] = True
                                        Console.error('Invalid param type "%s" in %s' % (paramTypeEntry["name"], className))

                                    if not "pseudo" in paramTypeEntry and paramTypeEntry["name"] in knownClasses:
                                        paramTypeEntry["linkable"] = True
                
                
                    # Check return types
                    if "returns" in item:
                        for returnTypeEntry in item["returns"]:
                            if not returnTypeEntry["name"] in knownClasses and not returnTypeEntry["name"] in additionalTypes and not ("builtin" in returnTypeEntry or "pseudo" in returnTypeEntry):
                                item["errornous"] = True
                                Console.error('Invalid return type "%s" in %s' % (returnTypeEntry["name"], className))
                            
                            if not "pseudo" in returnTypeEntry and returnTypeEntry["name"] in knownClasses:
                                returnTypeEntry["linkable"] = True
                            
                elif not item["type"] in builtinTypes and not item["type"] in pseudoTypes and not item["type"] in additionalTypes:
                    item["errornous"] = True
                    Console.error('Invalid type "%s" in %s' % (item["type"], className))
            
            
            # Process doc
            if "doc" in item:
                
                def processInternalLink(match):
                    linkUrl = match.group(2)

                    if linkUrl.startswith("#"):
                        linkCheck = checkInternalLink(linkUrl[1:], className)
                        if linkCheck is not True:
                            item["errornous"] = True

                            if sectionName:
                                Console.error("%s in %s:%s~%s" % (linkCheck, sectionName, className, name))
                            else:
                                Console.error("%s in %s" % (linkCheck, className))
            
                linkExtract.sub(processInternalLink, item["doc"])


        Console.indent()

        # Process APIs
        for className in apiData:
            classApi = apiData[className]
            
            sectionName = None
            constructData = getattr(classApi, "construct", None)
            if constructData is not None:
                checkLinksInItem(constructData)

            for sectionName in ("properties", "events", "statics", "members"):
                section = getattr(classApi, sectionName, None)

                if section is not None:
                    for name in section:
                         checkLinksInItem(section[name])

        Console.outdent()



        #
        # Filter Internals/Privates
        #
        
        Console.info("Filtering Items...")
        
        def isVisible(entry):
            if "visibility" in entry:
                visibility = entry["visibility"]
                if visibility == "private" and not privates:
                    return False
                if visibility == "internal" and not internals:
                    return False

            return True

        def filterInternalsPrivates(classApi, field):
            data = getattr(classApi, field, None)
            if data:
                for name in list(data):
                    if not isVisible(data[name]):
                        del data[name]

        for className in apiData:
            filterInternalsPrivates(apiData[className], "statics")
            filterInternalsPrivates(apiData[className], "members")



        #
        # Connection Interfaces / ImplementedBy
        #
        
        Console.info("Connecting Interfaces...")
        Console.indent()
        
        for className in apiData:
            classApi = getApi(className)
            
            if not hasattr(classApi, "main"):
                continue
                
            classType = classApi.main["type"]
            if classType == "core.Class":
                
                classImplements = getattr(classApi, "implements", None)
                if classImplements:
                    
                    for interfaceName in classImplements:
                        interfaceApi = apiData[interfaceName]
                        implementedBy = getattr(interfaceApi, "implementedBy", None)
                        if not implementedBy:
                            implementedBy = interfaceApi.implementedBy = []
                            
                        implementedBy.append(className)
                        connectInterface(className, interfaceName, classApi, interfaceApi)
        
        Console.outdent()
        
        
        #
        # Merging Named Classes
        #
        
        Console.info("Merging Named Classes...")
        Console.indent()
        
        for className in list(apiData):
            classApi = apiData[className]
            destName = classApi.main["name"]
            
            if destName is not None and destName != className:

                Console.debug("Extending class %s with %s", destName, className)

                if destName in apiData:
                    destApi = apiData[destName]
                    destApi.main["from"].append(className)
                
                else:
                    destApi = apiData[destName] = Data.ApiData(destName, highlight=highlightCode)
                    destApi.main = {
                        "type" : "Extend",
                        "name" : destName,
                        "from" : [className]
                    }
                    
                # If there is a "main" tag found in the class use its API description
                if "tags" in classApi.main and classApi.main["tags"] is not None and "main" in classApi.main["tags"]:
                    if "doc" in classApi.main:
                        destApi.main["doc"] = classApi.main["doc"]
                
                classApi.main["extension"] = True
                    
                # Read existing data
                construct = getattr(classApi, "construct", None)
                statics = getattr(classApi, "statics", None)
                members = getattr(classApi, "members", None)

                if construct is not None:
                    if hasattr(destApi, "construct"):
                        Console.warn("Overriding constructor in extension %s by %s", destName, className)
                        
                    destApi.construct = copy.copy(construct)

                if statics is not None:
                    if not hasattr(destApi, "statics"):
                        destApi.statics = {}

                    for staticName in statics:
                        destApi.statics[staticName] = copy.copy(statics[staticName])
                        destApi.statics[staticName]["from"] = className
                        destApi.statics[staticName]["fromLink"] = "static:%s~%s" % (className, staticName)

                if members is not None:
                    if not hasattr(destApi, "members"):
                        destApi.members = {}
                        
                    for memberName in members:
                        destApi.members[memberName] = copy.copy(members[memberName])
                        destApi.members[memberName]["from"] = className
                        destApi.members[memberName]["fromLink"] = "member:%s~%s" % (className, memberName)

        Console.outdent()
        

        #
        # Connecting Uses / UsedBy
        #

        Console.info("Collecting Use Patterns...")

        # This matches all uses with the known classes and only keeps them if matched
        allClasses = set(list(apiData))
        for className in apiData:
            uses = apiData[className].uses

            # Rebuild use list
            cleanUses = set()
            for use in uses:
                if use != className and use in allClasses:
                    cleanUses.add(use)

                    useEntry = apiData[use]
                    if not hasattr(useEntry, "usedBy"):
                        useEntry.usedBy = set()

                    useEntry.usedBy.add(className)

            apiData[className].uses = cleanUses

        
        
        #
        # Collecting errors
        #
        
        Console.info("Collecting Errors...")
        Console.indent()
        
        for className in sorted(apiData):
            classApi = apiData[className]
            errors = []

            if isErrornous(classApi.main):
                errors.append({
                    "kind": "Main",
                    "name": None,
                    "line": 1
                })
            
            if hasattr(classApi, "construct"):
                if isErrornous(classApi.construct):
                    errors.append({
                        "kind": "Constructor",
                        "name": None,
                        "line": classApi.construct["line"]
                    })
            
            for section in ("statics", "members", "properties", "events"):
                items = getattr(classApi, section, {})
                for itemName in items:
                    item = items[itemName]
                    if isErrornous(item):
                        errors.append({
                            "kind": itemMap[section],
                            "name": itemName,
                            "line": item["line"]
                        })
                        
            if errors:
                if printErrors:
                    Console.warn("Found errors in %s", className)
                    
                errorsSorted = sorted(errors, key=lambda entry: entry["line"])
                
                if printErrors:
                    Console.indent()
                    for entry in errorsSorted:
                        if entry["name"]:
                            Console.warn("%s: %s (line %s)", entry["kind"], entry["name"], entry["line"])
                        else:
                            Console.warn("%s (line %s)", entry["kind"], entry["line"])
                
                    Console.outdent()
                    
                classApi.errors = errorsSorted
                
        Console.outdent()
        
        
        
        #
        # Building Search Index
        #

        Console.info("Building Search Index...")
        search = {}

        def addSearch(classApi, field):
            data = getattr(classApi, field, None)
            if data:
                for name in data:
                    if not name in search:
                        search[name] = set()

                    search[name].add(className)

        for className in apiData:

            classApi = apiData[className]

            addSearch(classApi, "statics")
            addSearch(classApi, "members")
            addSearch(classApi, "properties")
            addSearch(classApi, "events")
        
        
        
        #
        # Post Process (dict to sorted list)
        #
        
        Console.info("Post Processing Data...")
        
        for className in sorted(apiData):
            classApi = apiData[className]
            
            convertTags(classApi.main)
            
            construct = getattr(classApi, "construct", None)
            if construct:
                convertFunction(construct)
                convertTags(construct)

            for section in ("statics", "members", "properties", "events"):
                items = getattr(classApi, section, None)
                if items:
                    sortedList = []
                    for itemName in sorted(items):
                        item = items[itemName]
                        item["name"] = itemName
                        
                        if "type" in item and item["type"] == "Function":
                            convertFunction(item)
                                
                        convertTags(item)
                        sortedList.append(item)

                    setattr(classApi, section, sortedList)
        
        
        
        #
        # Collecting Package Docs
        #

        Console.info("Collecting Package Docs...")
        Console.indent()
        
        # Inject existing package docs into api data
        for project in self.__session.getProjects():
            docs = project.getDocs()
            
            for packageName in docs:
                if self.__isIncluded(packageName, classFilter):
                    Console.debug("Creating package docuementation %s", packageName)
                    apiData[packageName] = docs[packageName].getApi()
        
        
        # Fill missing package docs
        for className in sorted(apiData):
            splits = className.split(".")
            packageName = splits[0]
            for split in splits[1:]:
                if not packageName in apiData:
                    Console.warn("Missing package docuementation %s", packageName)
                    apiData[packageName] = Data.ApiData(packageName, highlight=highlightCode)
                    apiData[packageName].main = {
                        "type" : "Package",
                        "name" : packageName
                    }
                        
                packageName = "%s.%s" % (packageName, split)


        # Now register all classes in their parent namespace/package
        for className in sorted(apiData):
            splits = className.split(".")
            packageName = ".".join(splits[:-1])
            if packageName:
                package = apiData[packageName]
                # debug("- Registering class %s in parent %s", className, packageName)
                
                entry = {
                    "name" : splits[-1],
                    "link" : className,
                }
                
                classMain = apiData[className].main
                if "doc" in classMain and classMain["doc"]:
                    summary = Text.extractSummary(classMain["doc"])
                    if summary:
                        entry["summary"] = summary
                        
                if "type" in classMain and classMain["type"]:
                    entry["type"] = classMain["type"]
                
                if not hasattr(package, "content"):
                    package.content = [entry]
                else:
                    package.content.append(entry)
                    
        Console.outdent()



        #
        # Writing API Index
        #
        
        Console.debug("Building Index...")
        index = {}
        
        for className in sorted(apiData):
            
            classApi = apiData[className]
            mainInfo = classApi.main
            
            # Create structure for className
            current = index
            for split in className.split("."):
                if not split in current:
                    current[split] = {}
            
                current = current[split]
            
            # Store current type
            current["$type"] = mainInfo["type"]
            
            # Keep information if
            if hasattr(classApi, "content"):
                current["$content"] = True
        
        
        
        #
        # Return
        #
        
        return apiData, index, search

    def _process(self):
        return RHRoomBookingCancelBookingOccurrence._process(self)

    def _process(self):
        return RHRoomBookingNewBooking._process(self)

    def _process(self, p, element, ranges={}):
        # Creates a unified Dataset.data attribute
        # to draw the data from
        if isinstance(element.data, np.ndarray):
            if 'dataframe' in Dataset.datatype:
                el_data = element.table('dataframe')
            else:
                el_data = element.table('dictionary')
        else:
            el_data = element.data

        # Get dimensions to plot against each other
        dims = [d for d in element.dimensions()
                if _is_number(element.range(d)[0])]
        permuted_dims = [(d1, d2) for d1 in dims
                         for d2 in dims[::-1]]

        data = {}
        for d1, d2 in permuted_dims:
            if d1 == d2:
                if p.diagonal_type is Histogram:
                    bin_range = ranges.get(d1.name, element.range(d1))
                    el = element.hist(dimension=d1.name,
                                      bin_range=bin_range,
                                      adjoin=False)(norm=dict(axiswise=True, framewise=True))
                else:
                    values = element.dimension_values(d1)
                    el = p.diagonal_type(values, vdims=[d1])
            else:
                el = p.chart_type(el_data, kdims=[d1],
                                  vdims=[d2], datatype=['dataframe', 'dictionary'])
            data[(d1.name, d2.name)] = el
        return data

    def _process(self):
        db.session.delete(self.contrib_field)
        db.session.flush()
        self.event_new.log(EventLogRealm.management, EventLogKind.negative, 'Contributions',
                           'Deleted field: {}'.format(self.contrib_field.title), session.user)

    def _process(self):
        db.session.delete(self.paper_file)
        return jsonify_data(html=_render_paper_file_list(self.contrib))

        def _process(self):
            self.result = []
            iq = Iq(to=self.muc_name, typ='get', attrs={"id": self.ID})
            query = Protocol('query', xmlns="http://jabber.org/protocol/disco#items")
            iq.addChild(node=query)
            self.myAgent.jabber.send(iq)
            msg = self._receive(True, 10)
            if msg:
                if query:
                    items = msg.getQueryChildren()
                    for item in items:
                        if item.getAttr("jid"):
                            iq = Iq(to=item.getAttr("jid"), typ='get', attrs={"id": self.ID})
                            query = Protocol('query', xmlns="http://jabber.org/protocol/disco#info")
                            iq.addChild(node=query)
                            name = str(item.getAttr("name"))
                            self.myAgent.jabber.send(iq)
                            template = Iq(frm=item.getAttr("jid"), typ='result', attrs={"id": self.ID})
                            t = Behaviour.MessageTemplate(template)
                            self.setTemplate(t)
                            msg = self._receive(True, 10)
                            if msg:
                                query = msg.getTag("query")
                                if query:
                                    x = query.getTag("x")
                                    if x:
                                        items = x.getChildren()
                                        for item in items:
                                            value = None
                                            if item.getAttr("var") == "muc#roominfo_type":
                                                if item.getTags("value"):
                                                    value = item.getTags("value")[0].getData()
                                                    if  value == "Unit:" + self.roomname:
                                                        self.result.append(name)

    def _process(self):
        return WPRoomBookingMapOfRooms(self, roomID=self._room_id).display()

    def _process(self):
        self._conf.setClosed(False)
        flash(_('The event is now unlocked.'), 'success')
        return redirect(url_for('event_mgmt.conferenceModification', self._conf))

    def _process(self, stream, varname, has_nl):
        # SQL query asignation to varname
        if self.count > 1:
            yield sql.Token(T.Whitespace, '\n')
        yield sql.Token(T.Name, varname)
        yield sql.Token(T.Whitespace, ' ')
        yield sql.Token(T.Operator, '=')
        yield sql.Token(T.Whitespace, ' ')
        if has_nl:
            yield sql.Token(T.Operator, '(')
        yield sql.Token(T.Text, "'")

        # Print the tokens on the quote
        for token in stream:
            # Token is a new line separator
            if token.is_whitespace and '\n' in token.value:
                # Close quote and add a new line
                yield sql.Token(T.Text, " '")
                yield sql.Token(T.Whitespace, '\n')

                # Quote header on secondary lines
                yield sql.Token(T.Whitespace, ' ' * (len(varname) + 4))
                yield sql.Token(T.Text, "'")

                # Indentation
                after_lb = token.value.split('\n', 1)[1]
                if after_lb:
                    yield sql.Token(T.Whitespace, after_lb)
                continue

            # Token has escape chars
            elif "'" in token.value:
                token.value = token.value.replace("'", "\\'")

            # Put the token
            yield sql.Token(T.Text, token.value)

        # Close quote
        yield sql.Token(T.Text, "'")
        if has_nl:
            yield sql.Token(T.Operator, ')')

def _process(G, name, value):
    '''
    Determines whether parameter is a template or a value. Adds graph nodes and edges accordingly.
    '''
    # Jinja defaults to ascii parser in python 2.x unless you set utf-8 support on per module level
    # Instead we're just assuming every string to be a unicode string
    if isinstance(value, str):
        value = to_unicode(value)

    complex_value_str = None
    if isinstance(value, list) or isinstance(value, dict):
        complex_value_str = str(value)

    is_jinja_expr = (
        jinja_utils.is_jinja_expression(value) or jinja_utils.is_jinja_expression(
            complex_value_str
        )
    )

    if is_jinja_expr:
        G.add_node(name, template=value)

        template_ast = ENV.parse(value)
        LOG.debug('Template ast: %s', template_ast)
        # Dependencies of the node represent jinja variables used in the template
        # We're connecting nodes with an edge for every depencency to traverse them
        # in the right order and also make sure that we don't have missing or cyclic
        # dependencies upfront.
        dependencies = meta.find_undeclared_variables(template_ast)
        LOG.debug('Dependencies: %s', dependencies)
        if dependencies:
            for dependency in dependencies:
                G.add_edge(dependency, name)
    else:
        G.add_node(name, value=value)

    def __process(self):
        """Private handler to handle one job. """
        console.info('blade worker %d starts to process' % self.thread_id)
        console.info('blade worker %d finish' % self.thread_id)
        return

    def _process(self):
        form = ParticipantsDisplayFormColumnsForm()
        if form.validate_on_submit():
            registration_settings.set_participant_list_columns(self.event, form.json.data['columns'], self.regform)
            flash(_('The settings for "{}" have been saved.').format(self.regform.title), 'success')
            return jsonify_data()

        available_fields = {field.id: field for field in self.regform.active_fields}
        enabled_fields = []
        for field_id in registration_settings.get_participant_list_columns(self.event, self.regform):
            try:
                field = available_fields[field_id]
            except KeyError:
                continue
            enabled_fields.append(field)
            del available_fields[field_id]

        disabled_fields = available_fields.values()
        return jsonify_template('events/registration/management/regform_display_form_columns.html', form=form,
                                enabled_columns=enabled_fields, disabled_columns=disabled_fields)

    def _process(self, request, collection, action, resource_id=None,
                 success_status_code=200, **kwargs):

        payload = {}

        request_body = yield from request.text()

        if request_body:
            try:
                request_body = json.loads(request_body)
                payload.update(request_body)
            except (ValueError, UnicodeDecodeError):
                self.logger.warning('Bad body: %s',
                                    request_body,
                                    exc_info=True)

        payload.update({'collection_name': collection, 'action': action})

        if resource_id:
            payload['resource_id'] = resource_id
        payload.update(kwargs)

        self.logger.info('Payload %s' % payload)

        try:
            result = yield from self.service.send(**payload)
            self.logger.info('Result is %s' % result)
        except UnknownService as e:
            self.logger.error('Payload error %s' % e)
            err_body = json.dumps({'error': str(e)}).encode('utf-8')
            raise web.HTTPNotFound(content_type="application/json",
                                   body=err_body)
        else:
            response_body = json.dumps(result).encode('utf-8')
            return web.Response(content_type="application/json",
                                body=response_body, status=success_status_code)

    def _process(self):
        invitations = _query_invitation_list(self.regform)
        return WPManageRegistration.render_template('management/regform_invitations.html', self.event,
                                                    regform=self.regform, invitations=invitations)

    def _process(self, program):

        def process ():

            # session to be used by executor and handlers
            session = Session()

            task = session.merge(program)

            log.debug("[start] %s" % str(task))

            site=Site()
            nowmjd=site.MJD()
            log.debug("[start] Current MJD is %f",nowmjd)
            if program.slewAt:
                waittime=(program.slewAt-nowmjd)*86.4e3
                if waittime>0.0:
                    log.debug("[start] Waiting until MJD %f to start slewing",program.slewAt)
                    log.debug("[start] Will wait for %f seconds",waittime)
                    time.sleep(waittime)
                else:
                    log.debug("[start] Specified slew start MJD %s has already passed; proceeding without waiting",program.slewAt)
            else:
               log.debug("[start] No slew time specified, so no waiting")
            log.debug("[start] Current MJD is %f",site.MJD())
            log.debug("[start] Proceeding since MJD %f should have passed",program.slewAt)
            self.controller.programBegin(program)

            try:
                self.executor.execute(task)
                log.debug("[finish] %s" % str(task))
                self.scheduler.done(task)
                self.controller.programComplete(program, SchedulerStatus.OK)
                self.state(State.IDLE)
            except ProgramExecutionException, e:
                self.scheduler.done(task, error=e)
                self.controller.programComplete(program, SchedulerStatus.ERROR, str(e))
                self.state(State.IDLE)
                log.debug("[error] %s (%s)" % (str(task), str(e)))
            except ProgramExecutionAborted, e:
                self.scheduler.done(task, error=e)
                self.controller.programComplete(program, SchedulerStatus.ABORTED, "Aborted by user.")
                self.state(State.OFF)
                log.debug("[aborted by user] %s" % str(task))

            session.commit()

        t = threading.Thread(target=process)
        t.setDaemon(False)
        t.start()

  def _process(self, cursor=None):
    """Query and process through all pipeline work items."""
    query = WorkItem.query()
    query = query.filter(WorkItem.work_index == self.work_index)

    results, cursor, has_more = query.fetch_page(PIPELINES_BATCH_SIZE,
                                                 start_cursor=cursor)
    if not results:
      return

    # Use fan-out to process in batches using cursor.
    if has_more:
      deferred.defer(self._process, cursor=cursor, _queue=PIPELINES_QUEUE)

    # Process the stored items.
    processor = None
    result_keys = []
    process_errors = []
    for result in results:
      try:
        if processor is None:
          processor = pickle.loads(result.processor)
        processor.process(json.loads(result.data))
        result_keys.append(result.key)
      except Exception as e:
        logging.exception('Error processing data in the batch.')
        process_errors.append(e)

    try:
      processor.finalize()
      # Only remove when they successfully finalize.
      self._cleanup(result_keys)
    except Exception as e:
      logging.exception('Error finalizing data in the batch.')
      process_errors.append(e)

    if process_errors:
      raise PipelineProcessError(process_errors)

    logging.info(
        'Processed {} WorkItems in the {} task'.format(
            len(result_keys), os.environ.get('HTTP_X_APPENGINE_TASKNAME', '')))

    def _process(self):
        ical_params = get_base_ical_parameters(session.user, self.event_new, 'sessions',
                                               '/export/event/{0}/session/{1}.ics'.format(self.event_new.id,
                                                                                          self.session.id))
        tz = timezone(DisplayTZ(session.user, self._conf).getDisplayTZ())
        contributions_strategy = subqueryload('contributions')
        _contrib_tte_strategy = contributions_strategy.joinedload('timetable_entry')
        _contrib_tte_strategy.lazyload('*')
        contributions_strategy.joinedload('person_links')
        blocks_strategy = joinedload('blocks')
        blocks_strategy.joinedload('person_links')
        _block_tte_strategy = blocks_strategy.joinedload('timetable_entry')
        _block_tte_strategy.lazyload('*')
        _block_tte_strategy.joinedload('children')
        sess = (Session.query
                .filter_by(id=self.session.id)
                .options(contributions_strategy, blocks_strategy)
                .one())
        return self.view_class.render_template('display/session_display.html', self._conf, sess=sess,
                                               event=self.event_new, timezone=tz, **ical_params)

    def _process(self):
        return render_acl(self.session)

    def _process(self):
        return jsonify_data(flash=False,
                            **serialize_category_chain(self.category, include_children=True, include_parents=True))

    def _process(self):
        pdf = get_timetable_offline_pdf_generator(self.event_new)
        return send_file('timetable.pdf', BytesIO(pdf.getPDFBin()), 'application/pdf')

    def _process(self):
        if not request.is_xhr:
            return WPCategory.render_template('display/calendar.html', self.category,
                                              start_dt=request.args.get('start_dt'))
        tz = self.category.display_tzinfo
        start = tz.localize(dateutil.parser.parse(request.args['start'])).astimezone(utc)
        end = tz.localize(dateutil.parser.parse(request.args['end'])).astimezone(utc)
        query = (Event.query
                 .filter(Event.starts_between(start, end),
                         Event.is_visible_in(self.category),
                         ~Event.is_deleted)
                 .options(load_only('id', 'title', 'start_dt', 'end_dt', 'category_id')))
        events = self._get_event_data(query)
        ongoing_events = (Event.query
                          .filter(Event.is_visible_in(self.category),
                                  Event.start_dt < start,
                                  Event.end_dt > end)
                          .options(load_only('id', 'title', 'start_dt', 'end_dt', 'timezone'))
                          .order_by(Event.title)
                          .all())
        return jsonify_data(flash=False, events=events, ongoing_event_count=len(ongoing_events),
                            ongoing_events_html=self._render_ongoing_events(ongoing_events))

    def _process(self):
        group = self.group
        tpl = get_template_module('groups/_group_members.html')
        return jsonify(success=True, html=tpl.group_members(group))