Combine --pythonpath and --pants_config_files(pants.ini) files that are in {buildroot} dir
    with those invalidation_globs provided by users
    :param bootstrap_options:
    :return: A list of invalidation_globs
1683
def compute_invalidation_globs(bootstrap_options):
    
    buildroot = get_buildroot()
    invalidation_globs = []
    globs = bootstrap_options.pythonpath + \
      bootstrap_options.pants_config_files + \
      bootstrap_options.pantsd_invalidation_globs

    for glob in globs:
      glob_relpath = os.path.relpath(glob, buildroot)
      if glob_relpath and (not glob_relpath.startswith("../")):
        invalidation_globs.extend([glob_relpath, glob_relpath + '/**'])
      else:
        logging.getLogger(__name__).warning("Changes to {}, outside of the buildroot"
                                            ", will not be invalidated.".format(glob))

    return invalidation_globs
767323
def _check_load_paths(load_path):
    '''
    
    '''
    if load_path is None or not isinstance(load_path, six.string_types):
        return None

    _paths = []

    for _path in load_path.split(':'):
        if os.path.isabs(_path) and os.path.isdir(_path):
            _paths.append(_path)
        else:
            log.info('Invalid augeas_cfg load_path entry: %s removed', _path)

    if not _paths:
        return None

    return ':'.join(_paths)
592148
def to_filespec(cls, args, root='', exclude=None):
    
    result = {'globs': [os.path.join(root, arg) for arg in args]}
    if exclude:
      result['exclude'] = []
      for exclude in exclude:
        if hasattr(exclude, 'filespec'):
          result['exclude'].append(exclude.filespec)
        else:
          result['exclude'].append({'globs': [os.path.join(root, x) for x in exclude]})
    return result
398472
function buildSources (path, options) {
  var excludes = options.excludes;
  var sources = [];

  if (options.defaults) {
    sources = options.defaults.concat(sources);
  }

  var environment = getEnvironment(options);

  var basename = nodePath.basename(path);
  var ext = nodePath.extname(basename);

  var pathNoExt = path.slice(0, 0 - ext.length);

  if (!ext) {
    ext = '.json';
  }

  sources.push(pathNoExt + ext);

  if (excludes['env-file'] !== true) {
    sources.push(pathNoExt + '-' + environment + ext);
  }

  if (excludes['local-file'] !== true) {
    sources.push(pathNoExt + '-local' + ext);
  }

  if (excludes['env'] !== true) {
    sources.push(getEnvNodeConfig());
  }

  if (excludes['command-line'] !== true) {
    sources.push(getCommandLineNodeConfig());
  }

  if (options.overrides) {
    sources = sources.concat(options.overrides);
  }

  if (typeof options.sources === 'function') {
    var newSources = options.sources(sources);
    if (newSources != null) {
      sources = newSources;
    }
  }

  return sources;
}
410694
def insert_system_path(opts, paths):
    '''
    
    '''
    if isinstance(paths, six.string_types):
        paths = [paths]
    for path in paths:
        path_options = {'path': path, 'root_dir': opts['root_dir']}
        prepend_root_dir(path_options, path_options)
        if (os.path.isdir(path_options['path'])
                and path_options['path'] not in sys.path):
            sys.path.insert(0, path_options['path'])
654014
def config_file(kind="local"):
    
    if kind == 'local':
        return 'setup.cfg'
    if kind == 'global':
        return os.path.join(
            os.path.dirname(distutils.__file__), 'distutils.cfg'
        )
    if kind == 'user':
        dot = os.name == 'posix' and '.' or ''
        return os.path.expanduser(convert_path("~/%spydistutils.cfg" % dot))
    raise ValueError(
        "config_file() type must be 'local', 'global', or 'user'", kind
    )
389251
function buildResolverOptions(options, base) {
  var pathFilter = options.pathFilter;

  options.basedir = base;
  options.pathFilter = function(info, resvPath, relativePath) {
    if (relativePath[0] !== '.') {
      relativePath = './' + relativePath;
    }
    var mappedPath;
    if (pathFilter) {
      mappedPath = pathFilter.apply(this, [info, resvPath, path.normalize(relativePath)]);
    }
    if (mappedPath) {
      return mappedPath;
    }
    return;
  };
  return options;
}
604426
def install_bootstrapped_files(nb_path=None, server_config=True, DEBUG=False):
    

    install_path = None
    print('Starting hide_code.js install...')
    current_dir = path.abspath(path.dirname(__file__))
    config_dirs = j_path.jupyter_config_path()
    notebook_module_path = Utils.get_notebook_module_dir()

    # check for config directory with a "custom" folder
    # TODO update this logic to check if custom.js file exists
    for dir in config_dirs:
        custom_dir = path.join(dir, "custom")
        if path.isdir(custom_dir):
            install_path = custom_dir
            break

    # last ditch effort in case jupyter config directories don't contain custom/custom.js
    if install_path == None:
        print("No config directories contain \"custom\" folder. Trying Jupyter notebook module path...")
        install_path = path.join(notebook_module_path, "static", "custom")

    if nb_path != None:
        install_path = nb_path
        print("Using argument supplied path: " + install_path)

    if DEBUG:
        print(install_path)

    # copy js into static/custom directory in Jupyter/iPython directory
    if path.isdir(install_path):
        shutil.copyfile(path.join(current_dir, "hide_code.js"), path.join(install_path, "hide_code.js"))
        print('Copying hide_code.js to ' + install_path)

        # add require to end of custom.js to auto-load on notebook startup
        print("Attempting to configure custom.js to auto-load hide_code.js...")
        try:
            with open(path.join(current_dir, "auto-load.txt")) as auto:
                auto_load_txt = auto.read();
                auto_loaded = False

                # check if auto-load.txt is already in custom.js
                with open(path.join(install_path, "custom.js"), 'r') as customJS:
                    if auto_load_txt in customJS.read():
                        auto_loaded = True
                        print("Custom.js already configured to auto-load hide_code.js.")

                if not auto_loaded:  # append auto load require to end of custom.js
                    with open(path.join(install_path, "custom.js"), 'a') as customJS:
                        customJS.write(auto_load_txt)
                        print("Configured custom.js to auto-load hide_code.js.")
        except:
            print("Custom.js not in custom directory.")
    else:
        print('Unable to install into ' + install_path)
        print('Directory doesn\'t exist.')
        print('Make sure Jupyter is installed.')

    if server_config:
        print("Attempting to configure auto-loading for hide_code export handlers.")
        try:
            # Activate the Python server extension
            server_cm = ConfigManager(config_dir=j_path.jupyter_config_dir())
            cfg = server_cm.get('jupyter_notebook_config')
            server_extensions = (cfg.setdefault('NotebookApp', {})
                                 .setdefault('server_extensions', [])
                                 )
            extension = 'hide_code.hide_code'
            if extension not in server_extensions:
                cfg['NotebookApp']['server_extensions'] += [extension]
                server_cm.update('jupyter_notebook_config', cfg)
                print('Configured jupyter to auto-load hide_code export handlers.')
            else:
                print("Jupyter already configured to auto-load export handlers.")
        except:
            print('Unable to install server extension.')
839863
def bootstrap(**kwargs):
    
    # the user for the image is `ec2-user`, there is no sudo, but we can su to root w/o password
    original_host = env.host_string
    env.host_string = 'ec2-user@%s' % env.instance.uid
    bootstrap_files = env.instance.config.get('bootstrap-files', 'bootstrap-files')
    put('%s/authorized_keys' % bootstrap_files, '/tmp/authorized_keys')
    put(join(bsdploy_path, 'enable_root_login_on_daemonology.sh'), '/tmp/', mode='0775')
    run("""su root -c '/tmp/enable_root_login_on_daemonology.sh'""")
    # revert back to root
    env.host_string = original_host
    # give sshd a chance to restart
    sleep(2)
    run('rm /tmp/enable_root_login_on_daemonology.sh')

    # allow overwrites from the commandline
    env.instance.config.update(kwargs)

    bu = BootstrapUtils()
    bu.ssh_keys = None
    bu.upload_authorized_keys = False
    bu.bootstrap_files_yaml = 'daemonology-files.yml'
    bu.print_bootstrap_files()

    bu.create_bootstrap_directories()
    bu.upload_bootstrap_files({})
    # we need to install python here, because there is no way to install it via
    # ansible playbooks
    bu.install_pkg('/', chroot=False, packages=['python27'])
1019596
protected function bootstrapStandaloneFiles()
    {
        $files = $this->files->listFiles($this->paths->getUserlandPath(), true);

        // Build queue, placing tasks first, events after
        $queue = [];
        foreach ($files as $file) {
            $path = $this->files->getAdapter()->applyPathPrefix($file['path']);
            if (mb_strpos($path, 'tasks') !== false) {
                array_unshift($queue, $path);
            } else {
                $queue[] = $path;
            }
        }

        // Include files
        foreach ($queue as $path) {
            include $path;
        }
    }
63567
def sprockets(source_file, opts={})
      require 'sprockets'
      source_path = source_file || opt[:main] || opt[:from]
      env = ::Sprockets::Environment.new site.root
      env.append_path File.expand_path(File.join site.source_path, File.dirname(source_path))
      env.append_path site.source_path
      # env.append_path File.dirname(source_path)
      [opts[:paths]].flatten.each do |path|
        env.append_path(path) unless path.nil?
      end
      content= env[ source_path ].to_s
    rescue LoadError
      raise StandardError, "Sprockets can't be loaded. Please add it to your Gemfile."
    end
154316
def load_config(configfile):
    

    configfile = os.path.abspath(configfile)
    config = configobj.ConfigObj(configfile)

    config_extension = '.conf'

    #########################################################################
    # Load up other config files
    #########################################################################

    if 'configs' in config:
        config_extension = config['configs'].get('extension', config_extension)

        # Load other configs
        if 'path' in config['configs']:
            for cfgfile in os.listdir(config['configs']['path']):
                cfgfile = os.path.join(config['configs']['path'],
                                       cfgfile)
                cfgfile = os.path.abspath(cfgfile)
                if not cfgfile.endswith(config_extension):
                    continue
                newconfig = configobj.ConfigObj(cfgfile)
                config.merge(newconfig)

    #########################################################################

    if 'server' not in config:
        raise Exception('Failed to load config file %s!' % configfile)

    #########################################################################
    # Load up handler specific configs
    #########################################################################

    if 'handlers' not in config:
        config['handlers'] = configobj.ConfigObj()

    if 'handlers_config_path' in config['server']:
        handlers_config_path = config['server']['handlers_config_path']
        if os.path.exists(handlers_config_path):
            for cfgfile in os.listdir(handlers_config_path):
                cfgfile = os.path.join(handlers_config_path, cfgfile)
                cfgfile = os.path.abspath(cfgfile)
                if not cfgfile.endswith(config_extension):
                    continue
                filename = os.path.basename(cfgfile)
                handler = os.path.splitext(filename)[0]

                if handler not in config['handlers']:
                    config['handlers'][handler] = configobj.ConfigObj()

                newconfig = configobj.ConfigObj(cfgfile)
                config['handlers'][handler].merge(newconfig)

    #########################################################################
    # Load up Collector specific configs
    #########################################################################

    if 'collectors' not in config:
        config['collectors'] = configobj.ConfigObj()

    if 'collectors_config_path' in config['server']:
        collectors_config_path = config['server']['collectors_config_path']
        if os.path.exists(collectors_config_path):
            for cfgfile in os.listdir(collectors_config_path):
                cfgfile = os.path.join(collectors_config_path, cfgfile)
                cfgfile = os.path.abspath(cfgfile)
                if not cfgfile.endswith(config_extension):
                    continue
                filename = os.path.basename(cfgfile)
                collector = os.path.splitext(filename)[0]

                if collector not in config['collectors']:
                    config['collectors'][collector] = configobj.ConfigObj()

                try:
                    newconfig = configobj.ConfigObj(cfgfile)
                except Exception as e:
                    raise Exception("Failed to load config file %s due to %s" %
                                    (cfgfile, e))

                config['collectors'][collector].merge(newconfig)

    # Convert enabled to a bool
    for collector in config['collectors']:
        if 'enabled' in config['collectors'][collector]:
            config['collectors'][collector]['enabled'] = str_to_bool(
                config['collectors'][collector]['enabled']
            )

    #########################################################################

    return config
261598
def relative_startup_config_file(self):
        

        path = os.path.join(self.working_dir, 'startup-config.cfg')
        if os.path.exists(path):
            return 'startup-config.cfg'
        else:
            return None
948735
def project_local_dir(self):
        

        # depending on where we are in bootstrapping the BaseGlobalConfig
        # the canonical projectname could be located in one of two places
        if self.project__name:
            name = self.project__name
        else:
            name = self.config_project.get("project", {}).get("name", "")
        if name is None:
            name = (
                ""
            )  # not entirely sure why this was happening in tests but this is the goal...

        path = os.path.join(
            os.path.expanduser("~"), self.global_config_obj.config_local_dir, name
        )
        if not os.path.isdir(path):
            os.makedirs(path)
        return path
1255758
function loadBootstrap(appPath, modules, type = 'worker') {
  let bootstrapPath = '';
  if (modules.length) {
    bootstrapPath = path.join(appPath, 'common/bootstrap');
  } else {
    bootstrapPath = path.join(appPath, 'bootstrap');
  }
  const filepath = path.join(bootstrapPath, `${type}.js`);
  if (helper.isFile(filepath)) {
    debug(`load file: ${filepath}`);
    return require(filepath);
  }
}
918381
def glob(self):
		
		matches = []
		for root, dirnames, filenames in os.walk(self.path):
			if not self.recursive:
				while len(dirnames) > 0:
					dirnames.pop()
			for include in self.include:
				for filename in fnmatch.filter(filenames, include):
					matches.append(os.path.join(root, filename))
		return matches
589107
def _add_plugin_paths(self):
        
        base_dir = os.path.join(os.path.dirname(__file__), 'plugins')
        ansible_mitogen.loaders.connection_loader.add_directory(
            os.path.join(base_dir, 'connection')
        )
        ansible_mitogen.loaders.action_loader.add_directory(
            os.path.join(base_dir, 'action')
        )