Generate global name cache for project files

        If `resources` is a list of `rope.base.resource.File`\s, only
        those files are searched; otherwise all python modules in the
        project are cached.
548422
def generate_cache(self, resources=None, underlined=None,
                       task_handle=taskhandle.NullTaskHandle()):
        
        if resources is None:
            resources = self.project.get_python_files()
        job_set = task_handle.create_jobset(
            'Generatig autoimport cache', len(resources))
        for file in resources:
            job_set.started_job('Working on <%s>' % file.path)
            self.update_resource(file, underlined)
            job_set.finished_job()
1209468
def get_source_files(target, build_context) -> list:
    """"""
    all_sources = list(target.props.sources)
    for proto_dep_name in target.props.protos:
        proto_dep = build_context.targets[proto_dep_name]
        all_sources.extend(proto_dep.artifacts.get(AT.gen_cc).keys())
    return all_sources
469165
def get_cached_files(url, server_name="", document_root=None):
    
    import glob
    url_info = process_url(url, server_name, document_root, check_security=False)

    # get path to cache directory with basename of file (no extension)
    filedir = os.path.dirname(url_info['requested_file'])
    fileglob = '{0}*{1}'.format(url_info['base_filename'], url_info['ext'])
    return glob.glob(os.path.join(filedir, fileglob))
1193168
private List<String> getProjectResources() {

        if (m_projectResources == null) {
            try {
                m_projectResources = getCms().readProjectResources(getReferenceProject());
            } catch (Throwable e) {
                LOG.error(e.getLocalizedMessage(), e);
                // use an empty list (all resources are "outside")
                m_projectResources = new ArrayList<String>();
            }
        }
        return m_projectResources;
    }
274454
def load_and_parse(self, package_name, root_dir, relative_dirs,
                       resource_type, tags=None):
        """"""

        extension = "[!.#~]*.sql"

        if tags is None:
            tags = []

        if dbt.flags.STRICT_MODE:
            dbt.contracts.project.ProjectList(**self.all_projects)

        file_matches = dbt.clients.system.find_matching(
            root_dir,
            relative_dirs,
            extension)

        result = []

        for file_match in file_matches:
            file_contents = dbt.clients.system.load_file_contents(
                file_match.get('absolute_path'))

            parts = dbt.utils.split_path(file_match.get('relative_path', ''))
            name, _ = os.path.splitext(parts[-1])

            path = self.get_compiled_path(name,
                                          file_match.get('relative_path'))

            original_file_path = os.path.join(
                file_match.get('searched_path'),
                path)

            result.append({
                'name': name,
                'root_path': root_dir,
                'resource_type': resource_type,
                'path': path,
                'original_file_path': original_file_path,
                'package_name': package_name,
                'raw_sql': file_contents
            })

        return self.parse_sql_nodes(result, tags)
1092718
function searchCache(moduleName, callback) {
        // Resolve the module identified by the specified name
        var mod = module.constructor._resolveFilename(moduleName, module);

        // Check if the module has been resolved and found within
        // the cache
        if (mod && (mod = module.constructor._cache[mod]) !== undefined) {
            // Recursively go over the results
            (function run(mod) {
                // Go over each of the module's children and
                // run over it
                mod.children.forEach(function (child) {
                    return run(child);
                });

                // Call the specified callback providing the
                // found module
                callback(mod);
            })(mod);
        }
    }
713535
def resources_files
      target.resources_build_phase.files.map do |build_file|
        if build_file.file_ref.is_a?(Xcodeproj::Project::Object::PBXGroup)
          build_file.file_ref.recursive_children
        else
          [build_file.file_ref]
        end
      end.flatten.compact
    end
388434
def set_prefs(prefs):
    """"""

    # Specify which files and folders to ignore in the project.
    # Changes to ignored resources are not added to the history and
    # VCSs.  Also they are not returned in `Project.get_files()`.
    # Note that ``?`` and ``*`` match all characters but slashes.
    # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc'
    # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc'
    # '.svn': matches 'pkg/.svn' and all of its children
    # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o'
    # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o'
    prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject',
                                  '.hg', '.svn', '_svn', '.git', '.tox']

    # Specifies which files should be considered python files.  It is
    # useful when you have scripts inside your project.  Only files
    # ending with ``.py`` are considered to be python files by
    # default.
    # prefs['python_files'] = ['*.py']

    # Custom source folders:  By default rope searches the project
    # for finding source folders (folders that should be searched
    # for finding modules).  You can add paths to that list.  Note
    # that rope guesses project source folders correctly most of the
    # time; use this if you have any problems.
    # The folders should be relative to project root and use '/' for
    # separating folders regardless of the platform rope is running on.
    # 'src/my_source_folder' for instance.
    # prefs.add('source_folders', 'src')

    # You can extend python path for looking up modules
    # prefs.add('python_path', '~/python/')

    # Should rope save object information or not.
    prefs['save_objectdb'] = True
    prefs['compress_objectdb'] = False

    # If `True`, rope analyzes each module when it is being saved.
    prefs['automatic_soa'] = True
    # The depth of calls to follow in static object analysis
    prefs['soa_followed_calls'] = 0

    # If `False` when running modules or unit tests "dynamic object
    # analysis" is turned off.  This makes them much faster.
    prefs['perform_doa'] = True

    # Rope can check the validity of its object DB when running.
    prefs['validate_objectdb'] = True

    # How many undos to hold?
    prefs['max_history_items'] = 32

    # Shows whether to save history across sessions.
    prefs['save_history'] = True
    prefs['compress_history'] = False

    # Set the number spaces used for indenting.  According to
    # :PEP:`8`, it is best to use 4 spaces.  Since most of rope's
    # unit-tests use 4 spaces it is more reliable, too.
    prefs['indent_size'] = 4

    # Builtin and c-extension modules that are allowed to be imported
    # and inspected by rope.
    prefs['extension_modules'] = []

    # Add all standard c-extensions to extension_modules list.
    prefs['import_dynload_stdmods'] = True

    # If `True` modules with syntax errors are considered to be empty.
    # The default value is `False`; When `False` syntax errors raise
    # `rope.base.exceptions.ModuleSyntaxError` exception.
    prefs['ignore_syntax_errors'] = False

    # If `True`, rope ignores unresolvable imports.  Otherwise, they
    # appear in the importing namespace.
    prefs['ignore_bad_imports'] = False

    # If `True`, rope will insert new module imports as
    # `from <package> import <module>` by default.
    prefs['prefer_module_from_imports'] = False

    # If `True`, rope will transform a comma list of imports into
    # multiple separate import statements when organizing
    # imports.
    prefs['split_imports'] = False

    # If `True`, rope will remove all top-level import statements and
    # reinsert them at the top of the module when making changes.
    prefs['pull_imports_to_top'] = True

    # If `True`, rope will sort imports alphabetically by module name instead
    # of alphabetically by import statement, with from imports after normal
    # imports.
    prefs['sort_imports_alphabetically'] = False

    # Location of implementation of
    # rope.base.oi.type_hinting.interfaces.ITypeHintingFactory In general
    # case, you don't have to change this value, unless you're an rope expert.
    # Change this value to inject you own implementations of interfaces
    # listed in module rope.base.oi.type_hinting.providers.interfaces
    # For example, you can add you own providers for Django Models, or disable
    # the search type-hinting in a class hierarchy, etc.
    prefs['type_hinting_factory'] = (
        'rope.base.oi.type_hinting.factory.default_type_hinting_factory')
1370477
def get_importable_files(folder):
    
    for fname in os.listdir(folder):
        if fname.endswith('.py') and not fname.startswith('_'):
            fullname = os.path.join(folder, fname)
            if check_writable_by_others(fullname):
                print("ERROR: refuse to load module from world writable file %r" % fullname)
            else:
                yield fname
127776
def generate_search_space(code_dir):
    
    search_space = {}
    
    if code_dir.endswith(slash):
        code_dir = code_dir[:-1]

    for subdir, _, files in os.walk(code_dir):
        # generate module name from path
        if subdir == code_dir:
            package = ''
        else:
            assert subdir.startswith(code_dir + slash), subdir
            prefix_len = len(code_dir) + 1
            package = subdir[prefix_len:].replace(slash, '.') + '.'

        for file_name in files:
            if file_name.endswith('.py'):
                path = os.path.join(subdir, file_name)
                module = package + file_name[:-3]
                search_space.update(_generate_file_search_space(path, module))

    return search_space
561168
def find_resource_in_modules(resource_name, ancestors)
      if namespace = ancestors.detect { |a| a.constants.include?(resource_name.to_sym) }
        return namespace.const_get(resource_name)
      else
        raise NameError, "Namespace for #{namespace} not found"
      end
    end
174398
private void writeResources(Project project)
   {
      Project.Resources resources = m_factory.createProjectResources();
      project.setResources(resources);
      List<Project.Resources.Resource> list = resources.getResource();

      for (Resource resource : m_projectFile.getResources())
      {
         list.add(writeResource(resource));
      }
   }
1367821
def list_files(self, project_name):
        
        project = self._get_project_for_name(project_name)
        file_path_dict = self._get_file_path_dict_for_project(project)
        return list(file_path_dict)
900925
def set_project_filenames(self, recent_files):
        """"""
        if (self.current_active_project
                and self.is_valid_project(
                        self.current_active_project.root_path)):
            self.current_active_project.set_recent_files(recent_files)
930866
@SuppressWarnings("unchecked")
	@Override
	public Set<String> getResourceNames(String path) {
		Set<String> paths = context.getResourcePaths(path);
		Set<String> names = new HashSet<>();
		int length = path.length();
		if (null != paths) {
			for (String resourcePath : paths) {
				names.add(resourcePath.substring(length, resourcePath.length()));
			}
		}
		return names;
	}
182829
def update_resources_from_datafile(self, srcpath, type_, names=None, 
                                       languages=None):
        
        UpdateResourcesFromDataFile(self.filename, srcpath, type_, names, 
                                    languages)
1108395
def getFilesForName(name):
    
    if not os.path.exists(name):
        # check for glob chars
        if containsAny(name, "*?[]"):
            files = glob.glob(name)
            list = []
            for file in files:
                list.extend(getFilesForName(file))
            return list

        # try to find module or package
        name = _get_modpkg_path(name)
        if not name:
            return []

    if os.path.isdir(name):
        # find all python files in directory
        list = []
        os.path.walk(name, _visit_pyfiles, list)
        return list
    elif os.path.exists(name):
        # a single file
        return [name]

    return []