Create a blueprint static route from a decorated function.

        :param uri: endpoint at which the route will be accessible.
        :param file_or_directory: Static asset.
548479
def static(self, uri, file_or_directory, *args, **kwargs):
        
        static = FutureStatic(uri, file_or_directory, args, kwargs)
        self.statics.append(static)
1271863
def add_swagger_api_route(app, target_route, swagger_json_route):
    
    static_root = get_swagger_static_root()
    swagger_body = generate_swagger_html(
        STATIC_ROOT, swagger_json_route
    ).encode("utf-8")

    async def swagger_ui(request):
        return HTTPResponse(body_bytes=swagger_body, content_type="text/html")

    bp = Blueprint('swagger')
    bp.static(STATIC_ROOT, static_root)

    app.add_route(swagger_ui, target_route, methods=["GET"])
    app.blueprint(bp)
1034540
def _relative(self, uri):
        

        if uri.startswith("http:") or \
           uri.startswith("https:") or \
           uri.startswith("file:") or \
           uri.startswith("/"):
            return uri

        elif exists(uri):
            return relpath(uri, self.basedir)

        else:
            return uri
345967
def build_urls(self: NodeVisitor, node: inheritance_diagram) -> Mapping[str, str]:
    
    current_filename = self.builder.current_docname + self.builder.out_suffix
    urls = {}
    for child in node:
        # Another document
        if child.get("refuri") is not None:
            uri = child.get("refuri")
            package_path = child["reftitle"]
            if uri.startswith("http"):
                _, _, package_path = uri.partition("#")
            else:
                uri = (
                    pathlib.Path("..")
                    / pathlib.Path(current_filename).parent
                    / pathlib.Path(uri)
                )
                uri = str(uri).replace(os.path.sep, "/")
            urls[package_path] = uri
        # Same document
        elif child.get("refid") is not None:
            urls[child["reftitle"]] = (
                "../" + current_filename + "#" + child.get("refid")
            )
    return urls
255090
public RouteBuilder on(String uri) {
        if (!uri.startsWith("/")) {
            this.uri = "/" + uri;
        } else {
            this.uri = uri;
        }
        return this;
    }
575698
def urls_from_file_tree(template_dir):
    """"""
    urls = []  # keep a list of of all the files/paths

    # Should be somethign like:
    # /path/to/myproject/templates/staticflatpages
    root_dir = join(template_dir, 'staticflatpages')

    for root, dirs, files in walk(template_dir):
        # Only do this for the ``staticflatpages`` directory or sub-directories
        if "staticflatpages" in root:
            root = root.replace(root_dir, '')
            for f in files:
                path = join(root, f)
                path = _format_as_url(path)
                urls.append(path)
    return urls
798353
function createSourceFilesMiddleware (filesPromise, serveFile, basePath, urlRoot) {
  return function (request, response, next) {
    const requestedFilePath = composeUrl(request.url, basePath, urlRoot)
    // When a path contains HTML-encoded characters (e.g %2F used by Jenkins for branches with /)
    const requestedFilePathUnescaped = composeUrl(querystring.unescape(request.url), basePath, urlRoot)

    request.pause()

    log.debug(`Requesting ${request.url}`)
    log.debug(`Fetching ${requestedFilePath}`)

    return filesPromise.then(function (files) {
      // TODO(vojta): change served to be a map rather then an array
      const file = findByPath(files.served, requestedFilePath) || findByPath(files.served, requestedFilePathUnescaped)
      const rangeHeader = request.headers['range']

      if (file) {
        const acceptEncodingHeader = request.headers['accept-encoding']
        const matchedEncoding = Object.keys(file.encodings).find(
          (encoding) => new RegExp(`(^|.*, ?)${encoding}(,|$)`).test(acceptEncodingHeader)
        )
        const content = file.encodings[matchedEncoding] || file.content

        serveFile(file.contentPath || file.path, rangeHeader, response, function () {
          if (/\?\w+/.test(request.url)) {
            common.setHeavyCacheHeaders(response) // files with timestamps - cache one year, rely on timestamps
          } else {
            common.setNoCacheHeaders(response) // without timestamps - no cache (debug)
          }
          if (matchedEncoding) {
            response.setHeader('Content-Encoding', matchedEncoding)
          }
        }, content, file.doNotCache)
      } else {
        next()
      }

      request.resume()
    })
  }
}
1373423
def create_at_path(self, asset_content, url_path, tags=''):
        

        return self._create_asset({
            'asset': b64encode(asset_content),
            'url-path': url_path,
            'tags': tags,
            'type': 'base64'
        })
814335
def create_same_as_file(self):
        

        def find_preferred_uri(uri_list):
            index = None
            for i, uri in enumerate(uri_list):
                if uri.startswith("<http://id.loc.gov/authorities/subjects/"):
                        index = i
                        print(uri)
                        break
            if not index:
                for i, uri in enumerate(uri_list):
                    if uri.startswith(\
                            "<http://id.loc.gov/authorities/childrensSubjects/"):
                        index = i
                        print(uri)
                        break
            if not index:
                index = 0
            return (uri_list.pop(index), uri_list)


        with open(os.path.join(CFG.LOCAL_DATA_PATH, self.local_filename),
                  "w") as file_obj:
            file_obj.write(NSM.prefix("turtle"))
            for item in self.uri_list:
                uris = item['uris']['value'].split(",")
                new_list = find_preferred_uri(uris)
                uris = uris[1:]
                for uir in new_list[1]:
                    file_obj.write("%s kds:mergeWith %s .\n" % (uir,
                                                                new_list[0]))
870231
def blueprint(self) -> Optional[str]:
        
        if self.endpoint is not None and '.' in self.endpoint:
            return self.endpoint.rsplit('.', 1)[0]
        else:
            return None
1275010
public static Uri getUri(Context context, File file) {
        if (file != null) {
            return FileProvider.getUriForFile(context, FILE_PROVIDER_AUTHORITY, file);
            //Uri.fromFile(file);
        }
        return null;
    }
131203
def _add_url_route(self, endpoint, rule, view_func, method):
        
        if self.api_prefix:
            rule = self.api_prefix + rule

        if self.endpoint_prefix:
            endpoint = self.endpoint_prefix + endpoint

        self.app.add_url_rule(
            rule,
            endpoint,
            self._apply_auth(view_func),
            methods=[method]
        )
79190
static File resolveDirectory(String[] args) {
    return Optional.of(resolveArgument(args)).map(File::new).filter(File::isDirectory)
      .orElseThrow(() -> newIllegalArgumentException("Argument [%s] is not a valid directory", args[0]));
  }
1036931
@NonNull
    @Override
    public Uri toUri(@NonNull final File file) {
        return FileProvider
                .getUriForFile(getContext(),
                        getContext().getApplicationContext().getPackageName() + ".provider",
                        file);
    }
81209
def get_static_folder(app_or_blueprint):
    
    if not hasattr(app_or_blueprint, 'static_folder'):
        # I believe this is for app objects in very old Flask
        # versions that did not support custom static folders.
        return path.join(app_or_blueprint.root_path, 'static')

    if not app_or_blueprint.has_static_folder:
        # Use an exception type here that is not hidden by spit_prefix.
        raise TypeError(('The referenced blueprint %s has no static '
                         'folder.') % app_or_blueprint)
    return app_or_blueprint.static_folder
773393
def cache_resource(dest_dir=@local_cache_dir, options={})
      unless dest_dir
        raise ArgumentError, "Must specify destination directory when creating resource", caller
      end
      self.local_cache_dir=dest_dir
      @size = update_cache(@url, @local_path, options)
      if options[:include_pack_gz]
        @relative_local_path_pack_gz = "#{@relative_local_path}.pack.gz"
        @local_path_pack_gz = "#{dest_dir}/#{@relative_local_path_pack_gz}"
        @size_pack_gz = update_cache(@url_pack_gz, @local_path_pack_gz, options)
      end
      @signature_verified ? @size : @signature_verified
    end
431117
@NonNull
    public static Uri getUri(@NonNull Context context, @NonNull File outPath) {
        Uri uri;
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
            uri = Uri.fromFile(outPath);
        } else {
            uri = CameraFileProvider.getUriForFile(context, CameraFileProvider.getProviderName(context), outPath);
        }
        return uri;
    }