scrubadub.filth

Filth objects are responsible for marking particular sections of text as containing that type of filth. It is also responsible for knowing how it should be cleaned. Every type of Filth inherits from scrubadub.filth.base.Filth.

class scrubadub.filth.Filth(beg: Optional[int] = None, end: Optional[int] = None, text: Optional[str] = None, match: Optional[Match] = None, detector_name: Optional[str] = None, document_name: Optional[str] = None, replacement_string: Optional[str] = None, locale: Optional[str] = None, **kwargs)[source]

Bases: object

This is the base class for all Filth that is detected in dirty dirty text.

prefix: ClassVar[str] = '{{'
suffix: ClassVar[str] = '}}'
type: ClassVar[str] = 'unknown'
lookup = <scrubadub.utils.Lookup object>
regex: Optional[Pattern[str]] = None
__init__(beg: Optional[int] = None, end: Optional[int] = None, text: Optional[str] = None, match: Optional[Match] = None, detector_name: Optional[str] = None, document_name: Optional[str] = None, replacement_string: Optional[str] = None, locale: Optional[str] = None, **kwargs)[source]
property placeholder: str
property identifier: str
replace_with(replace_with: str = 'placeholder', **kwargs) str[source]
merge(other_filth: scrubadub.filth.base.Filth) scrubadub.filth.base.MergedFilth[source]
static generate(faker: faker.proxy.Faker) str[source]

Generates an example of this Filth type, usually using the faker python library.

Parameters

faker (Faker) – The Faker class from the faker library

Returns

An example of this Filth

Return type

str

is_valid() bool[source]