Creates linked navigators from a HAL response body
765072
def _make_links_from(self, body):
        ''''''
        ld = utils.CurieDict(self._core.default_curie, {})
        for rel, link in body.get('_links', {}).items():
            if rel != 'curies':
                if isinstance(link, list):
                    ld[rel] = utils.LinkList(
                        (self._navigator_or_thunk(lnk), lnk) for lnk in link)
                else:
                    ld[rel] = self._navigator_or_thunk(link)
        return ld
440039
def link(self):
        """"""
        if self.linked:
            return self

        self.linked = True

        included_modules = []

        # Link includes
        for include in self.includes.values():
            included_modules.append(include.link().surface)

        self.scope.add_surface('__includes__', tuple(included_modules))
        self.scope.add_surface('__thrift_source__', self.thrift_source)

        # Link self
        for linker in LINKERS:
            linker(self.scope).link()

        self.scope.add_surface('loads', Deserializer(self.protocol))
        self.scope.add_surface('dumps', Serializer(self.protocol))

        return self
415844
private void createNavigationInternal(StringBuffer buffer, List<CmsJspNavElement> navElements) {

        // take the element to render.
        CmsJspNavElement element = navElements.remove(0);
        int elementLevel = element.getNavTreeLevel();
        String spacing = getSpaces(elementLevel * 2);
        // render element:
        buffer.append(spacing).append("<li>\n");
        buffer.append(spacing).append("  <a href=\"");
        buffer.append(m_jsp.link(element.getResourceName()));
        buffer.append("\" title=\"");
        buffer.append(element.getNavText());
        buffer.append("\"");
        if (elementLevel == 1) {
            buffer.append(" class=\"bold\"");
        }
        buffer.append(">");
        buffer.append(element.getNavText());
        buffer.append("</a>\n");

        // peek at the next (list is depth - first by contract)
        if (!navElements.isEmpty()) {
            CmsJspNavElement child = navElements.get(0);
            int childLevel = child.getNavTreeLevel();
            if (elementLevel < childLevel) {
                // next one goes down a level: it is a child by tree means
                buffer.append(spacing).append("  <ul>\n");
            } else if (elementLevel == childLevel) {
                // it is a sibling: close our list item, no recursion
                buffer.append(spacing).append("</li>\n");
            } else {
                // next element gets up one layer
                // this has to happen because of the depth-first contract!
                buffer.append(spacing).append("  </li>\n").append(spacing).append("</ul>\n");
            }
            createNavigationInternal(buffer, navElements);
        } else {
            // no more next elements: get back and close all lists (by using the recursion we are in)
            buffer.append(spacing).append("  </li>\n").append(spacing).append("</ul>\n");
        }

    }
521228
function (navigationInstruction, callbackName, next, ignoreResult) {
        var plan = navigationInstruction.plan;
        var infos = findDeactivatable(plan, callbackName);
        var i = infos.length; // query from inside out
        function inspect(val) {
            if (ignoreResult || shouldContinue(val)) {
                return iterate();
            }
            return next.cancel(val);
        }
        function iterate() {
            if (i--) {
                try {
                    var viewModel = infos[i];
                    var result = viewModel[callbackName](navigationInstruction);
                    return processPotential(result, inspect, next.cancel);
                }
                catch (error) {
                    return next.cancel(error);
                }
            }
            navigationInstruction.router.couldDeactivate = true;
            return next();
        }
        return iterate();
    }
1321691
function NavigationFrame(editor, selectionObj) {
        this.cm = editor._codeMirror;
        this.filePath = editor.document.file._path;
        this.inMem = editor.document.file.constructor.name === "InMemoryFile";
        this.paneId = editor._paneId;
        this._hash = editor.document.file._hash;
        this.uId = (new Date()).getTime();
        this.selections = [];
        this.bookMarkIds = [];
        this._createMarkers(selectionObj.ranges);
    }
585848
function createNavigationPropertyBinding(oAssociationSetFrom, oAssociationSetTo) {
				var oEntitySet = oEntityContainer[oAssociationSetFrom.entitySetName],
					oToRole = oAssociation.roles[oAssociationSetTo.roleName];

				if (oToRole.propertyName) {
					oEntitySet.$NavigationPropertyBinding
						= oEntitySet.$NavigationPropertyBinding || {};
					oEntitySet.$NavigationPropertyBinding[oToRole.propertyName]
						= oAssociationSetTo.entitySetName;
				}
			}
75521
def _generate_list_skippers(self):
        

        container = self.parser.find(
            '#'
            + AccessibleNavigationImplementation.ID_CONTAINER_SKIPPERS
        ).first_result()
        html_list = None
        if container is None:
            local = self.parser.find('body').first_result()
            if local is not None:
                container = self.parser.create_element('div')
                container.set_attribute(
                    'id',
                    AccessibleNavigationImplementation.ID_CONTAINER_SKIPPERS
                )
                local.prepend_element(container)
        if container is not None:
            html_list = self.parser.find(container).find_children(
                'ul'
            ).first_result()
            if html_list is None:
                html_list = self.parser.create_element('ul')
                container.append_element(html_list)
        self.list_skippers_added = True

        return html_list
1071668
def wrap_httplib_response(response_func):
    

    def call(self, *args, **kwargs):
        _tracer = execution_context.get_opencensus_tracer()
        current_span_id = execution_context.get_opencensus_attr(
            'httplib/current_span_id')

        span = _tracer.current_span()

        # No corresponding request span is found, request not traced.
        if not span or span.span_id != current_span_id:
            return response_func(self, *args, **kwargs)

        result = response_func(self, *args, **kwargs)

        # Add the status code to attributes
        _tracer.add_attribute_to_current_span(
            HTTP_STATUS_CODE, str(result.status))

        _tracer.end_span()
        return result

    return call
1001262
function mapHeader (h) {
    if (h === undefined) return undefined;

    return {
      test: toBoolean(getElementText(h, 'Test', mes)),
      id: getElementText(h, 'ID', mes),
      prepared: getElementText(h, 'Prepared', mes),
      sender: mapParty(_getFirstChildNS(h, 'Sender', mes)),
      receiver: mapParty(_getFirstChildNS(h, 'Receiver', mes))
    };
  }
428188
def from_headers (strheader):
    
    res = []
    fp = StringIO(strheader)
    headers = httplib.HTTPMessage(fp, seekable=True)
    if "Host" not in headers:
        raise ValueError("Required header 'Host:' missing")
    host = headers["Host"]
    path= headers.get("Path", "/")
    for header in headers.getallmatchingheaders("Set-Cookie"):
        headervalue = header.split(':', 1)[1]
        for pairs in cookielib.split_header_words([headervalue]):
            for name, value in pairs:
                cookie = requests.cookies.create_cookie(name, value,
                    domain=host, path=path)
                res.append(cookie)
    return res
935662
def from_response(response):
        '''
        
        '''
        cls = PLAID_ERROR_TYPE_MAP.get(response['error_type'], PlaidError)
        return cls(response['error_message'],
                   response['error_type'],
                   response['error_code'],
                   response['display_message'],
                   response['request_id'],
                   response.get('causes'))
345340
def _wrap_paginated_response(cls, request, response, controls, data,
                                 head=None):
        
        paging_response = response['paging']
        if head is None:
            head = response['head_id']
        link = cls._build_url(
            request,
            head=head,
            start=paging_response['start'],
            limit=paging_response['limit'])

        paging = {}
        limit = controls.get('limit')
        start = controls.get("start")
        paging["limit"] = limit
        paging["start"] = start
        # If there are no resources, there should be nothing else in paging
        if paging_response.get("next") == "":
            return cls._wrap_response(
                request,
                data=data,
                metadata={
                    'head': head,
                    'link': link,
                    'paging': paging
                })

        next_id = paging_response['next']
        paging['next_position'] = next_id

        # Builds paging urls specific to this response
        def build_pg_url(start=None):
            return cls._build_url(request, head=head, limit=limit, start=start)

        paging['next'] = build_pg_url(paging_response['next'])

        return cls._wrap_response(
            request,
            data=data,
            metadata={
                'head': head,
                'link': link,
                'paging': paging
            })
508787
function objToGraph(obj, containerName) {
    if (!containerName) containerName = 'definitions';
    let graph = [];

    for (let p in obj[containerName]) {
        let entry = {};
        entry._id = '#/'+containerName+'/'+p;
        entry.links = [];
        graph.push(entry);
    }

    recurse(obj,{identityDetection:true},function(obj,key,state){
        if (isRef(obj,key)) {
            let ptr = obj[key].replace('/$ref','');
            let spath = state.path.replace('/$ref','');
            let target = graph.find(function(e){
                return e._id === ptr;
            });
            if (target) {
                target.links.push(ptr);
            }
            else {
                target = {};
                target._id = ptr;
                target.links = [];
                target.links.push(ptr);
                graph.push(target);
            }
            let source = graph.find(function(e){
                return e._id === spath;
            });
            if (source) {
                //source.links.push(spath);
            }
            else {
                source = {};
                source._id = spath
                source.links = [];
                graph.push(source);
            }
        }
    });

    return graph;
}
119823
def _get_responses(link):
    
    template = link.response_schema
    template.update({'description': 'Success'})
    res = {200: template}
    res.update(link.error_status_codes)
    return res
739296
function getSourceTrees(pathsToSearch) {
	return {
		read: function(readTree) {
			var promises = _.map(pathsToSearch, function(path) {
				return new Promise(function(resolve) {
					fs.exists(path, function(exists) {
						resolve((exists) ? path : null);
					});
				});
			});

			return Promise.all(promises)
				.then(function(paths) {
					paths = _.filter(paths);
					if (paths.length === 0) throw new Error('No source paths found');
					return paths;
				})
				.then(function(paths) {
					console.log('Found source paths: ' + paths.join(', '));

					var pathTrees = _.map(paths, function(path) {
						return new Funnel(path, { srcDir: '.', destDir: path });
					});

					return readTree(mergeTrees(pathTrees));
				});
		},

		cleanup: function() {}
	};
}
964972
def cache(self, link, nav):
        ''''''
        if link is None:
            return  # We don't cache navigators without a Link
        elif hasattr(link, 'uri'):
            self.id_map[link.uri] = nav
        else:
            self.id_map[link] = nav
679298
def _parse_header_links(response):
    
    values = response.headers.getRawHeaders(b'link', [b''])
    value = b','.join(values).decode('ascii')
    with LOG_HTTP_PARSE_LINKS(raw_link=value) as action:
        links = {}
        replace_chars = u' \'"'
        for val in re.split(u', *<', value):
            try:
                url, params = val.split(u';', 1)
            except ValueError:
                url, params = val, u''

            link = {}
            link[u'url'] = url.strip(u'<> \'"')
            for param in params.split(u';'):
                try:
                    key, value = param.split(u'=')
                except ValueError:
                    break
                link[key.strip(replace_chars)] = value.strip(replace_chars)
            links[link.get(u'rel') or link.get(u'url')] = link
        action.add_success_fields(parsed_links=links)
        return links