Select the right URI implementation regarding the Ecore model path schema.
771375
def select_uri_implementation(ecore_model_path):
    """"""
    if URL_PATTERN.match(ecore_model_path):
        return pyecore.resources.resource.HttpURI
    return pyecore.resources.URI
1125584
def get_default_view_path(resource):
    ""

    parts = [a.member_name for a in resource.ancestors] +\
            [resource.collection_name or resource.member_name]

    if resource.prefix:
        parts.insert(-1, resource.prefix)

    view_file = '%s' % '_'.join(parts)
    view = '%s:%sView' % (view_file, snake2camel(view_file))

    app_package_name = get_app_package_name(resource.config)
    return '%s.views.%s' % (app_package_name, view)
157796
def choose
      validate_path
      search_paths_list = search_paths
      if search_paths_list.empty?
        puts "\nThere is no /schema[^\/]*.rb$/ in the directory #{@path}"
        exit
      end

      search_paths_list.each_with_index {|path,indx|  puts "#{indx}. #{path}" }

      begin
        print "\nSelect a path to the target schema: "
      end while search_paths_list[(id = STDIN.gets.to_i)].nil?

      search_paths_list[id]
    end
676532
private Attribute checkContext(URI type, URI id, URI issuer,
                                        URI category, int designatorType) {
        if (!STRING_ATTRIBUTE_TYPE_URI.equals(type)) return null;
        String [] values = null;
        switch(designatorType){
            case AttributeDesignator.SUBJECT_TARGET:
                values = context.getSubjectValues(id.toString());
                break;
            case AttributeDesignator.RESOURCE_TARGET:
                values = context.getResourceValues(id);
                break;
            case AttributeDesignator.ACTION_TARGET:
                values = context.getActionValues(id);
                break;
            case AttributeDesignator.ENVIRONMENT_TARGET:
                values = context.getEnvironmentValues(id);
                break;
        }
        if (values == null || values.length == 0) return null;
        String iString = (issuer == null) ? null : issuer.toString();
        String tString = type.toString();
        if (values.length == 1) {
            AttributeValue val = stringToValue(values[0], tString);
            return (val == null) ? null :
                new SingletonAttribute(id, iString, getCurrentDateTime(), val);
        } else {
            ArrayList<AttributeValue> valCollection = new ArrayList<AttributeValue>(values.length);
            for (int i=0;i<values.length;i++) {
                AttributeValue val = stringToValue(values[i], tString);
                if (val != null) valCollection.add(val);
            }
            return new BasicAttribute(id, type, iString, getCurrentDateTime(), valCollection);
        }
    }
1060680
private void checkResourceURI(String resourceURI, String relName)
            throws SAXException {

        URI uri;
        try {
            uri = new URI(resourceURI);
        } catch (Exception e) {
            throw new SAXException("RelsExtValidator:"
                    + "Error in relationship '" + relName + "'."
                    + " The RDF 'resource' is not a valid URI.");
        }

        if (!uri.isAbsolute()) {
            throw new SAXException("RelsValidator:" + "Error in relationship '"
                    + relName + "'."
                    + " The specified RDF 'resource' is not an absolute URI.");
        }
    }
460719
def uri(self):
        """"""
        uristring = self.path
        if self.query:
            uristring += "?{}".format(self.query)
        if self.fragment:
            uristring += "#{}".format(self.fragment)

        return uristring
662441
def get_path_fields(self, path, method, view):
        
        model = getattr(getattr(view, 'queryset', None), 'model', None)
        fields = []

        for variable in uritemplate.variables(path):

            if variable == 'version':
                continue

            title = ''
            description = ''
            schema_cls = coreschema.String
            kwargs = {}
            if model is not None:
                # Attempt to infer a field description if possible.
                try:
                    model_field = model._meta.get_field(variable)
                except:
                    model_field = None

                if model_field is not None and model_field.verbose_name:
                    title = force_text(model_field.verbose_name)

                if model_field is not None and model_field.help_text:
                    description = force_text(model_field.help_text)
                elif model_field is not None and model_field.primary_key:
                    description = get_pk_description(model, model_field)

                if hasattr(view, 'lookup_value_regex') and view.lookup_field == variable:
                    kwargs['pattern'] = view.lookup_value_regex
                elif isinstance(model_field, models.AutoField):
                    schema_cls = coreschema.Integer

            field = Field(
                name=variable,
                location='path',
                required=True,
                schema=schema_cls(title=title, description=description, **kwargs)
            )
            fields.append(field)

        return fields
648428
def resource_url(self, entity_id, name, revision):
        '''
        
        '''
        return '{}/{}/resource/{}/{}'.format(self.url,
                                             _get_path(entity_id),
                                             name,
                                             revision)
868836
def processURI(self, uri, prefix=''):
        
        components = urlparse.urlparse(uri)
        query = dict(urlparse.parse_qsl(components.query))
        bust = True
        bust &= bool(query)  # bust the cache if the query has stuff in it
        # bust the cache if the query key 'cache' isn't true
        bust &= query.get('cache') != 'true'
        return prefix + components.path, bust
1224331
def get_uris(self, base_uri, filter_list=None):
        """"""
        return {
            re.sub(r'^/', base_uri, link.attrib['href'])
            for link in self.parsedpage.get_nodes_by_selector('a')
            if 'href' in link.attrib and (
                link.attrib['href'].startswith(base_uri) or
                link.attrib['href'].startswith('/')
            ) and
            not is_uri_to_be_filtered(link.attrib['href'], filter_list)
        }
1054260
def get_uri(endpoint_context, request, uri_type):
    
    if uri_type in request:
        verify_uri(endpoint_context, request, uri_type)
        uri = request[uri_type]
    else:
        try:
            _specs = endpoint_context.cdb[
                str(request["client_id"])]["{}s".format(uri_type)]
        except KeyError:
            raise ParameterError(
                "Missing {} and none registered".format(uri_type))
        else:
            if len(_specs) > 1:
                raise ParameterError(
                    "Missing {} and more than one registered".format(uri_type))
            else:
                uri = join_query(*_specs[0])

    return uri
182300
public static final String getRelativeURI( String contextPath, String uri )
    {
        String requestUrl = uri;
        int overlap = requestUrl.indexOf( contextPath + '/' );
        assert overlap != -1 : "contextPath: " + contextPath + ", uri: " + uri;
        return requestUrl.substring( overlap + contextPath.length() );
    }
1362223
public static void listUnificationXrefsPerPathway(Model model)
	{
		// This is a visitor for elements in a pathway - direct and indirect
		Visitor visitor = new Visitor()
		{
			public void visit(BioPAXElement domain, Object range, Model model, PropertyEditor editor)
			{
				if (range instanceof physicalEntity)
				{
					// Do whatever you want with the pe and xref here
					physicalEntity pe = (physicalEntity) range;
					ClassFilterSet<xref,unificationXref> unis = new ClassFilterSet<xref,unificationXref>(pe.getXREF(),
					                                                                           unificationXref.class);
					for (unificationXref uni : unis)
					{
						System.out.println("pe.getNAME() = " + pe.getNAME());
						System.out.println("uni = " + uni.getID());
					}
				}
			}
		};

		Traverser traverser = new Traverser(SimpleEditorMap.L2, visitor);

		Set<pathway> pathways = model.getObjects(pathway.class);
		for (pathway pathway : pathways)
		{
			traverser.traverse(pathway, model);
		}
	}
638611
private String convertURItoURL(String uri) {
        int indexScheme = uri.indexOf("://");
        if (-1 != indexScheme) {
            int indexQuery = uri.indexOf('?');
            if (-1 == indexQuery || indexScheme < indexQuery) {
                // already a full url
                return uri;
            }
        }
        StringBuilder sb = new StringBuilder();
        String scheme = this.request.getScheme();
        sb.append(scheme).append("://");
        sb.append(this.request.getServerName());
        int port = this.request.getServerPort();
        if ("http".equalsIgnoreCase(scheme) && 80 != port) {
            sb.append(':').append(port);
        } else if ("https".equalsIgnoreCase(scheme) && 443 != port) {
            sb.append(':').append(port);
        }
        String data = this.request.getContextPath();
        if (!"".equals(data)) {
            sb.append(data);
        }
        if (0 == uri.length()) {
            sb.append('/');
        } else if (uri.charAt(0) == '/') {
            // relative to servlet container root...
            sb.append(uri);
        } else {
            // relative to current URI,
            data = this.request.getServletPath();
            if (!"".equals(data)) {
                sb.append(data);
            }
            data = this.request.getPathInfo();
            if (null != data) {
                sb.append(data);
            }
            sb.append('/');
            sb.append(uri);
            // TODO: webcontainer converted "/./" and "/../" info too
        }

        return sb.toString();
    }
602570
def target_schema(link)
      if link.target_schema
        link.target_schema
      elsif legacy_hyper_schema_rel?(link)
        link.parent
      end
    end
1159713
def _strip_schema(url):
    """"""
    result = parse_url(url, allow_fragments=False)
    return result.netloc + result.path
740481
protected URI buildLocationUri(MODEL_ID id, boolean useTemplate) {
        if (id == null) {
            throw new NotFoundException();
        }
        UriBuilder ub = uriInfo.getAbsolutePathBuilder();
        if (useTemplate) {
            return ub.build(id);
        } else {
            return ub.path(idToString(id)).build();
        }
    }