Parser

Parser is in charge to find every @import rules in given SASS content.

It has been builded following SASS Reference about @import rule.

class boussole.parser.ScssImportsParser[source]

SCSS parser to find import rules.

This does not support the old SASS syntax (also known as “indented syntax”).

It’s a mixin, meaning without own __init__ method so it’s should be safe enough to inherit it from another class.

REGEX_IMPORT_RULE

Compiled regex used to find import rules.

REGEX_COMMENTS

Compiled regex used to find and remove comments.

filter_rules(path)[source]

Lambda to filter items that: * Starts with http:// or https:// (this for external load only) * Ends with ”.css” (they are not intended to be compiled)

flatten_rules(declarations)[source]

Flatten returned import rules from regex.

Because import rules can contains multiple items in the same rule (called multiline import rule), the regex REGEX_IMPORT_RULE return a list of unquoted items for each rule.

Parameters:declarations (list) – A SCSS source.
Returns:Given SCSS source with all comments removed.
Return type:list
parse(content)[source]

Parse a stylesheet document with a regex (REGEX_IMPORT_RULE) to extract all import rules and return them.

Parameters:content (str) – A SCSS source.
Returns:Finded paths in import rules.
Return type:list
remove_comments(content)[source]

Remove all comment kind (inline and multiline) from given content.

Parameters:content (str) – A SCSS source.
Returns:Given SCSS source with all comments removed.
Return type:string
strip_quotes(content)[source]

Unquote given rule.

Parameters:

content (str) – An import rule.

Raises:
  • InvalidImportRule – Raise exception if the rule is badly quoted
  • (not started or not ended quotes).
Returns:

The given rule unquoted.

Return type:

string