Resolver¶
Resolver is in charge to resolve path in import rules. Resolving is done using given source directory and libraries directories paths.
-
class
boussole.resolver.
ImportPathsResolver
[source]¶ Import paths resolver.
Resolve given paths from SCSS source to absolute paths.
It’s a mixin, meaning without own
__init__
method so it’s should be safe enough to inherit it from another class.-
CANDIDATE_EXTENSIONS
¶ list
List of extensions available to build candidate paths. Beware, order does matter, the first extension will be the top candidate.
-
STRICT_PATH_VALIDATION
¶ bool
A switch to enabled (
True
) or disable (False
) exception raising when a path can not be resolved.
-
candidate_paths
(filepath)[source]¶ Return candidates path for given path
- If Filename does not starts with
_
, will build a candidate for both with and without_
prefix; - Will build For each available extensions if filename does not have an explicit extension;
- Leading path directory is preserved;
Parameters: filepath (str) – Relative path as finded in an import rule from a SCSS source. Returns: Builded candidate paths (as relative paths). Return type: list - If Filename does not starts with
-
check_candidate_exists
(basepath, candidates)[source]¶ Check that at least one candidate exist into a directory.
Parameters: - basepath (str) – Directory path where to search for candidate.
- candidates (list) – List of candidate file paths.
Returns: List of existing candidates.
Return type: list
-
resolve
(sourcepath, paths, library_paths=None)[source]¶ Resolve given paths from given base paths
Return resolved path list.
Note
Resolving strategy is made like libsass do, meaning paths in import rules are resolved from the source file where the import rules have been finded.
If import rule is not explicit enough and two file are candidates for the same rule, it will raises an error. But contrary to libsass, this happen also for files from given libraries in
library_paths
(oposed to libsass just silently taking the first candidate).Parameters: - sourcepath (str) – Source file path, its directory is used to resolve given paths. The path must be an absolute path to avoid errors on resolving.
- paths (list) – Relative paths (from
sourcepath
) to resolve. - library_paths (list) – List of directory paths for libraries to resolve paths if resolving fails on the base source path. Default to None.
Raises: UnresolvablePath
– If a path does not exist andSTRICT_PATH_VALIDATION
attribute isTrue
.Returns: List of resolved path.
Return type: list
-