CodeAwareFilter#

class scikitplot.corpus.CodeAwareFilter(prose=None)[source]#

Keep code that is not blank; filter everything else as prose.

The default filter of every reader. A document whose section_type is SectionType.CODE (a block of source code, a notebook code cell or its output) is kept when it holds a non-whitespace character: in code a short block is content. Any other document is judged by prose. The rule follows the document, not the reader, so code read from inside an archive is treated as code.

Parameters:
proseFilterBase or None, optional

The filter for documents that are not code. None (default): DefaultFilter with its defaults.

Parameters:

prose (FilterBase)

Examples

>>> f = CodeAwareFilter()
>>> f.include(CorpusDocument.create("f.py", 0, "}", section_type=SectionType.CODE))
True
>>> f.include(CorpusDocument.create("f.txt", 0, "}"))
False
include(doc)[source]#

Return True when doc is non-blank code, or prose prose keeps.

Parameters:

doc (CorpusDocument)

Return type:

bool

prose: FilterBase#