Decide which filesource we are using and serve
971736
private function _serve_file()
    {
        // Set either the source or cache file as our datasource
        if ($this->serve_default) {
            $file_data = $this->source_file;
        } else {
            $file_data = $this->cached_file;
        }
        
        // Output the file
        $this->_output_file($file_data);
    }
298495
def _get_source(self):
        "  "
        source_dir = op.join(self.deploy_dir, 'source')
        for tp, cmd in settings.SRC_CLONE:
            if self.src.startswith(tp + '+'):
                program = which(tp)
                assert program, '%s not found.' % tp
                cmd = cmd % dict(src=self.src[len(tp) + 1:],
                                 source_dir=source_dir,
                                 branch=self.branch)
                cmd = "sudo -u %s %s" % (self['src_user'], cmd)
                call(cmd, shell=True)
                self.templates.append('src-%s' % tp)
                break
        else:
            self.templates.append('src-dir')
            copytree(self.src, source_dir)

        return source_dir
1153415
def _serve_asset(self, path, gzipped_asset_bytes, request):
    """"""
    mimetype = mimetypes.guess_type(path)[0] or 'application/octet-stream'
    return http_util.Respond(
        request, gzipped_asset_bytes, mimetype, content_encoding='gzip')
1159754
def setup_file_watcher(path, use_polling=False):
    
    if use_polling:
        observer_class = watchdog.observers.polling.PollingObserver
    else:
        observer_class = EVENTED_OBSERVER

    file_event_handler = _SourceChangesHandler(patterns=["*.py"])
    file_watcher = observer_class()
    file_watcher.schedule(file_event_handler, path, recursive=True)
    file_watcher.start()
    return file_watcher
517996
def set_file_system(self, source_url=False, build_url=False):
        """"""

        assert isinstance(source_url, string_types) or source_url is None or source_url is False
        assert isinstance(build_url, string_types) or build_url is False

        if source_url:
            self._source_url = source_url
            self.dataset.config.library.source.url = self._source_url
            self._source_fs = None

        elif source_url is None:
            self._source_url = None
            self.dataset.config.library.source.url = self._source_url
            self._source_fs = None

        if build_url:
            self._build_url = build_url
            self.dataset.config.library.build.url = self._build_url
            self._build_fs = None

        self.dataset.commit()
273287
function(checks, callback) {
      fs.lstat(options.source, function(err, stats) {
        /* istanbul ignore else  */
        if (stats.isFile()) {
          copyFile(options, callback);
        } else if (stats.isDirectory()) {
          copyDir(options, callback);
        } else if (stats.isSymbolicLink()) {
          copySymlink(options, callback);
        } else {
          callback(new Error('Unsupported file type !'));
        }
      });
    }
770420
def qualified_files(self, absolute=True):
        """"""
        prefix = self.get_directory() if absolute else "."
        for rel_dir_name, file_name in self.files():
            yield os.path.join(prefix, rel_dir_name, file_name)
1167533
def openSource(p, filetype=None):
    ''
    if not filetype:
        filetype = options.filetype
    if isinstance(p, str):
        if '://' in p:
            return openSource(UrlPath(p), filetype)  # convert to Path and recurse
        elif p == '-':
            return openSource(PathFd('-', vd().stdin), filetype)
        else:
            return openSource(Path(p), filetype)  # convert to Path and recurse
    elif isinstance(p, UrlPath):
        openfunc = 'openurl_' + p.scheme
        return getGlobals()[openfunc](p, filetype=filetype)
    elif isinstance(p, Path):
        if not filetype:
            filetype = p.suffix or 'txt'

        if os.path.isdir(p.resolve()):
            filetype = 'dir'

        openfunc = 'open_' + filetype.lower()
        if openfunc not in getGlobals():
            warning('no %s function' % openfunc)
            filetype = 'txt'
            openfunc = 'open_txt'
        vs = getGlobals()[openfunc](p)
    else:  # some other object
        status('unknown object type %s' % type(p))
        vs = None

    if vs:
        status('opening %s as %s' % (p.name, filetype))

    return vs
999195
def serve(self, filename):
        ''''''
        if not self.exists(filename):
            abort(404)
        return self.backend.serve(filename)
142115
def getabsfile(object):
    """"""
    return os.path.normcase(
        os.path.abspath(getsourcefile(object) or getfile(object)))
46128
function () {
  'use strict';
  var options = {
    config: {
      relative: true
    },
    src: './index.html', // source file with types of files to be glob-injected
    files: [// relative paths to files to be globbed
      '!./node_modules/**/*',
      '!./_gulp/*',
      './**/*'

    ],
    dest: './', // destination directory where we'll write our ammended source file
    taskName: 'file-glob-inject', // default task name
    dependencies: [] // gulp tasks which should be run before this task
  };

  return options;
}
632419
def prepare_files(self, finder, force_root_egg_info=False, bundle=False):
        """"""
        unnamed = list(self.unnamed_requirements)
        reqs = list(self.requirements.values())
        while reqs or unnamed:
            if unnamed:
                req_to_install = unnamed.pop(0)
            else:
                req_to_install = reqs.pop(0)
            req_version = None
            install = True
            best_installed = False
            if not self.ignore_installed and not req_to_install.editable:
                req_to_install.check_if_exists()
                if req_to_install.satisfied_by:
                    if self.upgrade:
                        if not self.force_reinstall:
                            try:
                                url, req_version = finder.find_requirement(
                                    req_to_install, self.upgrade)
                            except BestVersionAlreadyInstalled:
                                best_installed = True
                                install = False
                            else:
                                # Avoid the need to call find_requirement again
                                req_to_install.url = url.url

                        if not best_installed:
                            req_to_install.conflicts_with = req_to_install.satisfied_by
                            req_to_install.satisfied_by = None
                    else:
                        install = False
                if req_to_install.satisfied_by:
                    if best_installed:
                        logger.notify('Requirement already up-to-date: %s'
                                      % req_to_install)
                    else:
                        logger.notify('Requirement already satisfied '
                                      '(use --upgrade to upgrade): %s'
                                      % req_to_install)
            if req_to_install.editable:
                logger.notify('Obtaining %s' % req_to_install)
            elif install:
                if req_to_install.url and req_to_install.url.lower().startswith('file:'):
                    logger.notify('Unpacking %s' % display_path(url_to_path(req_to_install.url)))
                else:
                    logger.notify('Downloading/unpacking %s' % req_to_install)
            logger.indent += 2
            try:
                is_bundle = False
                if req_to_install.editable:
                    if req_to_install.source_dir is None:
                        location = req_to_install.build_location(self.src_dir)
                        req_to_install.source_dir = location
                    else:
                        location = req_to_install.source_dir
                    if not os.path.exists(self.build_dir):
                        _make_build_dir(self.build_dir)
                    req_to_install.update_editable(not self.is_download)
                    if self.is_download:
                        req_to_install.run_egg_info()
                        req_to_install.archive(self.download_dir)
                    else:
                        req_to_install.run_egg_info()
                elif install:
                    ##@@ if filesystem packages are not marked
                    ##editable in a req, a non deterministic error
                    ##occurs when the script attempts to unpack the
                    ##build directory

                    location = req_to_install.build_location(self.build_dir, not self.is_download)
                    ## FIXME: is the existance of the checkout good enough to use it?  I don't think so.
                    unpack = True
                    if not os.path.exists(os.path.join(location, 'setup.py')):
                        ## FIXME: this won't upgrade when there's an existing package unpacked in `location`
                        if req_to_install.url is None:
                            url, req_version = finder.find_requirement(req_to_install, upgrade=self.upgrade)
                        else:
                            ## FIXME: should req_to_install.url already be a link?
                            url = Link(req_to_install.url)
                            assert url
                        if url:
                            try:
                                self.unpack_url(req_to_install, req_version, url, location, self.is_download)
                            except HTTPError:
                                e = sys.exc_info()[1]
                                logger.fatal('Could not install requirement %s because of error %s'
                                             % (req_to_install, e))
                                raise InstallationError(
                                    'Could not install requirement %s because of HTTP error %s for URL %s'
                                    % (req_to_install, e, url))
                        else:
                            unpack = False
                    if unpack:
                        is_bundle = req_to_install.is_bundle
                        url = None
                        if is_bundle:
                            req_to_install.move_bundle_files(self.build_dir, self.src_dir)
                            for subreq in req_to_install.bundle_requirements():
                                reqs.append(subreq)
                                self.add_requirement(subreq)
                        elif self.is_download:
                            req_to_install.source_dir = location
                            if url and url.scheme in vcs.all_schemes:
                                req_to_install.run_egg_info()
                                req_to_install.archive(self.download_dir)
                        else:
                            req_to_install.source_dir = location
                            req_to_install.run_egg_info()
                            if force_root_egg_info:
                                # We need to run this to make sure that the .egg-info/
                                # directory is created for packing in the bundle
                                req_to_install.run_egg_info(force_root_egg_info=True)
                            req_to_install.assert_source_matches_version()
                            #@@ sketchy way of identifying packages not grabbed from an index
                            if bundle and req_to_install.url:
                                self.copy_to_build_dir(req_to_install)
                                install = False
                        # req_to_install.req is only avail after unpack for URL pkgs
                        # repeat check_if_exists to uninstall-on-upgrade (#14)
                        req_to_install.check_if_exists()
                        if req_to_install.satisfied_by:
                            if self.upgrade or self.ignore_installed:
                                req_to_install.conflicts_with = req_to_install.satisfied_by
                                req_to_install.satisfied_by = None
                            else:
                                install = False
                if not is_bundle and not self.is_download:
                    ## FIXME: shouldn't be globally added:
                    finder.add_dependency_links(req_to_install.dependency_links)
                    if (req_to_install.extras):
                        logger.notify("Installing extra requirements: %r" % ','.join(req_to_install.extras))
                    if not self.ignore_dependencies:
                        for req in req_to_install.requirements(req_to_install.extras):
                            try:
                                name = pkg_resources.Requirement.parse(req).project_name
                            except ValueError:
                                e = sys.exc_info()[1]
                                ## FIXME: proper warning
                                logger.error('Invalid requirement: %r (%s) in requirement %s' % (req, e, req_to_install))
                                continue
                            if self.has_requirement(name):
                                ## FIXME: check for conflict
                                continue
                            subreq = InstallRequirement(req, req_to_install)
                            reqs.append(subreq)
                            self.add_requirement(subreq)
                    if req_to_install.name not in self.requirements:
                        self.requirements[req_to_install.name] = req_to_install
                else:
                    self.reqs_to_cleanup.append(req_to_install)
                if install:
                    self.successfully_downloaded.append(req_to_install)
                    if bundle and (req_to_install.url and req_to_install.url.startswith('file:///')):
                        self.copy_to_build_dir(req_to_install)
            finally:
                logger.indent -= 2
119331
function serve(name, options, init) {
    var _pkg = pkg();
    if (chek_1.isPlainObject(name)) {
        init = options;
        options = name;
        name = undefined;
    }
    if (chek_1.isBoolean(options)) {
        init = options;
        options = undefined;
    }
    var defaults = {
        server: {
            baseDir: './dist'
        }
    };
    name = name || 'dev-server';
    options = chek_1.extend({}, defaults, options);
    var bsync = chek_1.tryRootRequire('browser-sync');
    if (!bsync)
        logger_1.log.error('browser-sync not found try >> npm install browser-sync -s');
    var server = bsync.create(name);
    if (init !== false)
        server.init(options, function (err) {
            if (err) {
                logger_1.log.error(err);
            }
            else {
                logger_1.log.notify("browser Sync server " + name + " started.");
            }
        });
    return server;
}
464814
def _handle_browse(self, relpath, params):
    """"""
    abspath = os.path.normpath(os.path.join(self._root, relpath))
    if not abspath.startswith(self._root):
      raise ValueError  # Prevent using .. to get files from anywhere other than root.
    if os.path.isdir(abspath):
      self._serve_dir(abspath, params)
    elif os.path.isfile(abspath):
      self._serve_file(abspath, params)
1167505
function findSourceFile(fileName, path, isDefaultLib, isReference, refFile, refPos, refEnd) {
            if (filesByName.contains(path)) {
                var file_1 = filesByName.get(path);
                // try to check if we've already seen this file but with a different casing in path
                // NOTE: this only makes sense for case-insensitive file systems
                if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
                    reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd);
                }
                // If the file was previously found via a node_modules search, but is now being processed as a root file,
                // then everything it sucks in may also be marked incorrectly, and needs to be checked again.
                if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) {
                    sourceFilesFoundSearchingNodeModules[file_1.path] = false;
                    if (!options.noResolve) {
                        processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib);
                        processTypeReferenceDirectives(file_1);
                    }
                    modulesWithElidedImports[file_1.path] = false;
                    processImportedModules(file_1, ts.getDirectoryPath(fileName));
                }
                else if (file_1 && modulesWithElidedImports[file_1.path]) {
                    if (currentNodeModulesDepth < maxNodeModulesJsDepth) {
                        modulesWithElidedImports[file_1.path] = false;
                        processImportedModules(file_1, ts.getDirectoryPath(fileName));
                    }
                }
                return file_1;
            }
            // We haven't looked for this file, do so now and cache result
            var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) {
                if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
                    fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
                }
                else {
                    fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
                }
            });
            filesByName.set(path, file);
            if (file) {
                sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0);
                file.path = path;
                if (host.useCaseSensitiveFileNames()) {
                    // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case
                    var existingFile = filesByNameIgnoreCase.get(path);
                    if (existingFile) {
                        reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd);
                    }
                    else {
                        filesByNameIgnoreCase.set(path, file);
                    }
                }
                skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
                var basePath = ts.getDirectoryPath(fileName);
                if (!options.noResolve) {
                    processReferencedFiles(file, basePath, isDefaultLib);
                    processTypeReferenceDirectives(file);
                }
                // always process imported modules to record module name resolutions
                processImportedModules(file, basePath);
                if (isDefaultLib) {
                    files.unshift(file);
                }
                else {
                    files.push(file);
                }
            }
            return file;
        }
976704
def file_or_resource(fname=None):
    '''
    '''
    if fname is not None:
        filename = os.path.expanduser(fname)
    
        resource_package = opentargets_validator.__name__
        resource_path = os.path.sep.join(('resources', filename))

        abs_filename = os.path.join(os.path.abspath(os.getcwd()), filename) \
                       if not os.path.isabs(filename) else filename

        return abs_filename if os.path.isfile(abs_filename) \
            else res.resource_filename(resource_package, resource_path)
1004585
async function host(filename, options) {
    let files = [path.join(__dirname, "html")];
    if (options.assets) {
        files = [options.assets, ...files];
    }
    const server = new WebSocketHost({assets: files, port: options.port});
    let file;
    if (filename) {
        file = fs.readFileSync(filename).toString();
    } else {
        file = await read_stdin();
    }
    server.host_table("data_source_one", table(file));
    if (options.open) {
        open_browser(options.port);
    }
}