rope.contrib.autoimport.sqlite ============================== .. py:module:: rope.contrib.autoimport.sqlite .. autoapi-nested-parse:: AutoImport module for rope. Classes ------- .. autoapisummary:: rope.contrib.autoimport.sqlite.AutoImport Functions --------- .. autoapisummary:: rope.contrib.autoimport.sqlite.get_future_names rope.contrib.autoimport.sqlite.filter_packages Module Contents --------------- .. py:function:: get_future_names(packages: List[rope.contrib.autoimport.defs.Package], underlined: bool, job_set: rope.base.taskhandle.BaseJobSet) -> Generator[concurrent.futures.Future[collections.abc.Collection[rope.contrib.autoimport.defs.Name]], None, None] Get all names as futures. .. py:function:: filter_packages(packages: Iterable[rope.contrib.autoimport.defs.Package], underlined: bool, existing: List[str]) -> Iterable[rope.contrib.autoimport.defs.Package] Filter list of packages to parse. .. py:class:: AutoImport(project: rope.base.project.Project, observe: bool = True, underlined: bool = False, memory: bool = _deprecated_default) A class for finding the module that provides a name. This class maintains a cache of global names in python modules. Note that this cache is not accurate and might be out of date. .. py:attribute:: memory :type: bool .. py:attribute:: project :type: rope.base.project.Project .. py:attribute:: project_package :type: rope.contrib.autoimport.defs.Package .. py:attribute:: underlined :type: bool .. py:attribute:: thread_local .. py:property:: connection :type: sqlite3.Connection Creates a new connection if called from a new thread. This makes sure AutoImport can be shared across threads. .. py:method:: create_database_connection(*, project: Optional[rope.base.project.Project] = None, memory: bool = False) -> sqlite3.Connection :classmethod: Create an sqlite3 connection project : rope.base.project.Project the project to use for project imports memory : bool if true, don't persist to disk .. py:method:: import_assist(starting: str) Find modules that have a global name that starts with `starting`. For a more complete list, use the search or search_full methods. :param starting: what all the names should start with :type starting: str :rtype: Return a list of ``(name, module)`` tuples .. py:method:: search(name: str, exact_match: bool = False) -> List[Tuple[str, str]] Search both modules and names for an import string. This is a simple wrapper around search_full with basic sorting based on Source. Returns a sorted list of import statement, modname pairs .. py:method:: search_full(name: str, exact_match: bool = False, ignored_names: Optional[Set[str]] = None) -> Generator[rope.contrib.autoimport.defs.SearchResult, None, None] Search both modules and names for an import string. :param name: Name to search for :type name: str :param exact_match: If using exact_match, only search for that name. Otherwise, search for any name starting with that name. :type exact_match: bool :param ignored_names: Will ignore any names in this set :type ignored_names: Set[str] :rtype: Unsorted Generator of SearchResults. Each is guaranteed to be unique. .. py:method:: get_modules(name) -> List[str] Get the list of modules that have global `name`. .. py:method:: get_all_names() -> List[str] Get the list of all cached global names. .. py:method:: generate_cache(resources: Optional[List[rope.base.resources.Resource]] = None, underlined: bool = False, task_handle: rope.base.taskhandle.BaseTaskHandle = taskhandle.DEFAULT_TASK_HANDLE) Generate global name cache for project files. If `resources` is a list of `rope.base.resource.File`, only those files are searched; otherwise all python modules in the project are cached. .. py:method:: generate_modules_cache(modules: Optional[List[str]] = None, task_handle: rope.base.taskhandle.BaseTaskHandle = taskhandle.DEFAULT_TASK_HANDLE, single_thread: bool = False, underlined: Optional[bool] = None) Generate global name cache for external modules listed in `modules`. If no modules are provided, it will generate a cache for every module available. This method searches in your sys.path and configured python folders. Do not use this for generating your own project's internal names, use generate_resource_cache for that instead. .. py:method:: update_module(module: str) Update a module in the cache, or add it if it doesn't exist. .. py:method:: close() Close the autoimport database. .. py:method:: get_name_locations(name) Return a list of ``(resource, lineno)`` tuples. .. py:method:: clear_cache() Clear all entries in global-name cache. It might be a good idea to use this function before regenerating global names. .. py:method:: find_insertion_line(code) Guess at what line the new import should be inserted. .. py:method:: update_resource(resource: rope.base.resources.Resource, underlined: bool = False, commit: bool = True) Update the cache for global names in `resource`. .. py:method:: add_aliases(aliases: collections.abc.Collection[rope.contrib.autoimport.defs.Alias])