Class | NoSourceFile |
exception raised when we are not able to get a python source file for a precompiled file |
Function | check_modpath_has_init |
check there are some __init__.py all along the way |
Function | file_from_modpath |
Undocumented |
Function | file_info_from_modpath |
given a mod path (i.e. split module / package name), return the corresponding file, giving priority to source file over precompiled file if it exists |
Function | get_module_files |
given a package directory return a list of all available python module's files in the package and its subpackages |
Function | get_module_part |
given a dotted name return the module part of the name : |
Function | get_source_file |
given a python module's file name return the matching source file name (the filename will be returned identically if it's already an absolute path to a python source file...) |
Function | is_directory |
Undocumented |
Function | is_module_name_part_of_extension_package_whitelist |
Returns True if one part of the module name is in the package whitelist |
Function | is_namespace |
Undocumented |
Function | is_python_source |
rtype: bool return: True if the filename is a python source file |
Function | is_relative |
return true if the given module name is relative to the given file name |
Function | is_standard_module |
try to guess if a module is a standard python module (by default, see std_path parameter's description) |
Function | load_module_from_file |
Load a Python module from it's path. |
Function | load_module_from_modpath |
Load a python module from its split name. |
Function | load_module_from_name |
Load a Python module from its name. |
Function | modpath_from_file |
Get the corresponding split module's name from a filename |
Function | modpath_from_file_with_callback |
Undocumented |
Constant | BUILTIN_MODULES |
dictionary with builtin module names has key |
Constant | EXT_LIB_DIRS |
Undocumented |
Constant | IS_JYTHON |
Undocumented |
Constant | PY_COMPILED_EXTS |
Undocumented |
Constant | PY_SOURCE_EXTS |
list of possible python source file extension |
Constant | STD_LIB_DIRS |
directories where standard modules are located |
Function | _cache_normalize_path |
Normalize path with caching. |
Function | _get_relative_base_path |
Extracts the relative mod path of the file to import from |
Function | _handle_blacklist |
remove files/directories in the black list |
Function | _has_init |
if the given directory has a valid __init__ file, return its path, else return None |
Function | _is_python_file |
return true if the given filename should be considered as a python file |
Function | _normalize_path |
Resolve symlinks in path and convert to absolute path. |
Function | _path_from_filename |
Undocumented |
Function | _posix_path |
Undocumented |
Function | _spec_from_modpath |
given a mod path (i.e. split module / package name), return the corresponding spec |
Constant | _NORM_PATH_CACHE |
Undocumented |
Variable | _root |
Undocumented |
Parameters | |
modpath:list or tuple | split module's name (i.e name of a module or package split on '.') (this means explicit relative imports that start with dots have empty strings in this list!) |
path:list or None | optional list of path where the module or package should be searched (use sys.path if nothing or None is given) |
context_file:str or None | context file to consider, necessary if the identifier has been introduced using a relative import unresolvable in the actual context (i.e. modutils) |
Returns | |
(str or None, import type) | the path to the module's file or None if it's an integrated builtin module such as 'sys' |
Raises | |
ImportError | if there is no such module in the directory |
Parameters | |
src_directory:str | path of the directory corresponding to the package |
blacklist:list or tuple | iterable list of files or directories to ignore. |
list_all:bool | get files from all paths, including ones without __init__.py |
Returns | |
list | the list of all available python module's files in the package and its subpackages |
given a dotted name return the module part of the name :
>>> get_module_part('astroid.as_string.dump') 'astroid.as_string'
XXX: deprecated, since it doesn't handle package precedence over module (see #10066)
Parameters | |
dotted_name:str | full name of the identifier we are interested in |
context_file:str or None | context file to consider, necessary if the identifier has been introduced using a relative import unresolvable in the actual context (i.e. modutils) |
Returns | |
str or None | the module part of the name or None if we have not been able at all to import the given name |
Raises | |
ImportError | if there is no such module in the directory |
Parameters | |
filename:str | python module's file name |
include_no_ext | Undocumented |
Returns | |
str | the absolute path of the source file if it exists |
Raises | |
NoSourceFile | if no source file exists on the file system |
Returns True if one part of the module name is in the package whitelist
>>> is_module_name_part_of_extension_package_whitelist('numpy.core.umath', {'numpy'}) True
Parameters | |
module_name:str | Undocumented |
package_whitelist:Set[ | Undocumented |
Returns | |
bool | Undocumented |
Parameters | |
modname:str | name of the module we are interested in |
from_file:str | path of the module from which modname has been imported |
Returns | |
bool | true if the module has been imported relatively to from_file |
std_path
parameter's description)Parameters | |
modname:str | name of the module we are interested in |
std_path:list(str) or tuple(str) | list of path considered has standard |
Returns | |
bool | true if the module:
- is located on the path listed in one of the directory in std_path
- is a built-in module |
Parameters | |
filepath:str | path to the python module or package |
Returns | |
module | the loaded module |
Raises | |
ImportError | if the module or package is not found |
Parameters | |
parts:list(str) or tuple(str) | python name of a module or package split on '.' |
Returns | |
module | the loaded module |
Raises | |
ImportError | if the module or package is not found |
Parameters | |
dotted_name:str | python name of a module or package |
Returns | |
module | the loaded module |
Raises | |
ImportError | if the module or package is not found |
Get the corresponding split module's name from a filename
This function will return the name of a module or package split on .
.
Parameters | |
filename:str | file's path for which we want the module's name |
path | Undocumented |
Optional[List[str]] path:Optional list of path where the module or package should be searched (use sys.path if nothing or None is given) | Undocumented |
Returns | |
list(str) | the corresponding split module's name |
Raises | |
ImportError | if the corresponding module's name has not been found |
Value |
|
Value |
|
Extracts the relative mod path of the file to import from
Check if a file is within the passed in path and if so, returns the relative mod path from the one passed in.
If the filename is no in path_to_check, returns None
Note this function will look for both abs and realpath of the file, this allows to find the relative base path even if the file is a symlink of a file in the passed in path
Resolve symlinks in path and convert to absolute path.
Note that environment variables and ~ in the path need to be expanded in advance.
This can be cached by using _cache_normalize_path.
Parameters | |
path:str | Undocumented |
Returns | |
str | Undocumented |
given a mod path (i.e. split module / package name), return the corresponding spec
this function is used internally, see file_from_modpath
's
documentation for more information