sassutils.builder — Build the whole directory

class sassutils.builder.Manifest(sass_path, css_path=None, wsgi_path=None, strip_extension=None)

Building manifest of Sass/SCSS.

Parameters:
  • sass_path (str, basestring) – the path of the directory that contains Sass/SCSS source files

  • css_path (str, basestring) – the path of the directory to store compiled CSS files

  • strip_extension (bool) – whether to remove the original file extension

build(package_dir, output_style='nested')

Builds the Sass/SCSS files in the specified sass_path. It finds sass_path and locates css_path as relative to the given package_dir.

Parameters:
  • package_dir (str, basestring) – the path of package directory

  • output_style (str) – an optional coding style of the compiled result. choose one of: 'nested' (default), 'expanded', 'compact', 'compressed'

Returns:

the set of compiled CSS filenames

Return type:

frozenset

New in version 0.6.0: The output_style parameter.

build_one(package_dir, filename, source_map=False)

Builds one Sass/SCSS file.

Parameters:
  • package_dir (str, basestring) – the path of package directory

  • filename (str, basestring) – the filename of Sass/SCSS source to compile

  • source_map (bool) – whether to use source maps. if True it also write a source map to a filename followed by .map suffix. default is False

Returns:

the filename of compiled CSS

Return type:

str, basestring

New in version 0.4.0: Added optional source_map parameter.

resolve_filename(package_dir, filename)

Gets a proper full relative path of Sass source and CSS source that will be generated, according to package_dir and filename.

Parameters:
  • package_dir (str, basestring) – the path of package directory

  • filename (str, basestring) – the filename of Sass/SCSS source to compile

Returns:

a pair of (sass, css) path

Return type:

tuple

unresolve_filename(package_dir, filename)

Retrieves the probable source path from the output filename. Pass in a .css path to get out a .scss path.

Parameters:
  • package_dir (str) – the path of the package directory

  • filename (str) – the css filename

Returns:

the scss filename

Return type:

str

sassutils.builder.SUFFIXES = frozenset({'sass', 'scss'})

(frozenset) The set of supported filename suffixes.

sassutils.builder.SUFFIX_PATTERN = re.compile('[.](sass|scss)$')

(re.RegexObject) The regular expression pattern which matches to filenames of supported SUFFIXES.

sassutils.builder.build_directory(sass_path, css_path, output_style='nested', _root_sass=None, _root_css=None, strip_extension=False)

Compiles all Sass/SCSS files in path to CSS.

Parameters:
  • sass_path (str, basestring) – the path of the directory which contains source files to compile

  • css_path (str, basestring) – the path of the directory compiled CSS files will go

  • output_style (str) – an optional coding style of the compiled result. choose one of: 'nested' (default), 'expanded', 'compact', 'compressed'

Returns:

a dictionary of source filenames to compiled CSS filenames

Return type:

collections.abc.Mapping

New in version 0.6.0: The output_style parameter.