qiuwenbot.filter package

Filter texts.

Submodules

qiuwenbot.filter.clean_refs module

class qiuwenbot.filter.clean_refs.CleanRefsFilter[source]

Bases: Filter

Filter to clean references.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

filter(text: str) str[source]

Filter text.

Parameters:
textstr

Text to filter.

Returns:
str

Filtered text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

qiuwenbot.filter.common module

qiuwenbot.filter.common.get_comment(comment: str) str[source]

Get comment inserted into wikitext.

qiuwenbot.filter.deprecated_tags module

class qiuwenbot.filter.deprecated_tags.RemoveMapframeFilter[source]

Bases: RemoveTagFilter

Filter to remove mapframe tag.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

class qiuwenbot.filter.deprecated_tags.RemoveScoreFilter[source]

Bases: RemoveTagFilter

Filter to remove score tag.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

class qiuwenbot.filter.deprecated_tags.RemoveTagFilter(tag: str)[source]

Bases: TextReplaceFilter

Filter to remove a certain tag.

Parameters:
tagstr

Tag name to remove.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.deprecated_tags.RemoveTimelineFilter[source]

Bases: RemoveTagFilter

Filter to remove timeline tag.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

qiuwenbot.filter.expired_templates module

class qiuwenbot.filter.expired_templates.RemoveExpiredCurrentFilter[source]

Bases: RemoveExpiredTemplateFilter

Filter to remove {{current}}.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

class qiuwenbot.filter.expired_templates.RemoveExpiredDeadFilter[source]

Bases: RemoveExpiredTemplateFilter

Filter to remove {{近期逝世}}.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

class qiuwenbot.filter.expired_templates.RemoveExpiredDeadFilter2[source]

Bases: RemoveExpiredTemplateFilter

Filter to remove {{最近逝世}}.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

class qiuwenbot.filter.expired_templates.RemoveExpiredDeadFilter3[source]

Bases: RemoveExpiredTemplateFilter

Filter to remove {{recent death}}.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

class qiuwenbot.filter.expired_templates.RemoveExpiredTemplateFilter(template: str)[source]

Bases: Filter

Filter to remove a certain tag.

Parameters:
tagstr

Tag name to remove.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

filter(text: str) str[source]

Filter text.

Parameters:
textstr

Text to filter.

Returns:
str

Filtered text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

qiuwenbot.filter.filter module

class qiuwenbot.filter.filter.Filter[source]

Bases: object

Filter texts.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

abstract filter(text: str) str[source]

Filter text.

Parameters:
textstr

Text to filter.

Returns:
str

Filtered text.

property log: str | None

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.filter.FilterChain(filters: List[Filter])[source]

Bases: Filter

Filter chain.

Parameters:
filterslist of Filter

Filters to apply.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

filter(text: str) str[source]

Filter text.

Parameters:
textstr

Text to filter.

Returns:
str

Filtered text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.filter.TextReplaceFilter(pattern: str, repl: str)[source]

Bases: Filter

Filter to replace texts.

Parameters:
patternstr

Pattern to replace.

replstr

Replacement.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

filter(text: str) str[source]

Filter text.

Parameters:
textstr

Text to filter.

Returns:
str

Filtered text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

qiuwenbot.filter.filter.register_filter(cls: Filter) Filter[source]

Return a decorator to register filter.

The filter should not have any parameters in its constructor.

Parameters:
clsFilter

Filter to register.

Returns:
Filter

Registered filter.

Examples

>>> @register_filter()
... class Filter1(Filter):
...     pass

qiuwenbot.filter.gov module

class qiuwenbot.filter.gov.CNGovFilter[source]

Bases: TextReplaceFilter

Filter to fix the Chinese government terms.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

qiuwenbot.filter.history module

class qiuwenbot.filter.history.FakeManchukuoFilter[source]

Bases: TextReplaceFilter

Filter for Fake Manchukuo authorities.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.history.FakeWangFilter[source]

Bases: TextReplaceFilter

Filter for Fake Wang authorities.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

qiuwenbot.filter.hk module

class qiuwenbot.filter.hk.HKReunificationFilter[source]

Bases: TextReplaceFilter

Filter to fix the Hong Kong Reunification terms.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

qiuwenbot.filter.roc_flag module

class qiuwenbot.filter.roc_flag.ReplaceROCyear[source]

Bases: Filter

Filter to replace ROC flag from a string.

Parameters:
patternstr

Pattern to replace.

replstr

Replacement.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

filter(text: str) str[source]

Filter text.

Parameters:
textstr

Text to filter.

Returns:
str

Filtered text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

qiuwenbot.filter.roc_year module

class qiuwenbot.filter.roc_year.ReplaceROCyear[source]

Bases: Filter

Filter to replace ROC year from a string.

Parameters:
patternstr

Pattern to replace.

replstr

Replacement.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

filter(text: str) str[source]

Filter text.

Parameters:
textstr

Text to filter.

Returns:
str

Filtered text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

qiuwenbot.filter.tw module

class qiuwenbot.filter.tw.TWJPFilter[source]

Bases: TextReplaceFilter

Filter to fix the Japanese authorities.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.tw.TWLeaderFilter[source]

Bases: TextReplaceFilter

Filter to fix the leader name in the Taiwan area.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.tw.TWNameFilter1[source]

Bases: TextReplaceFilter

Filter to fix the name of the Taiwan area.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.tw.TWNameFilter2[source]

Bases: TextReplaceFilter

Filter to fix the name of the Taiwan area.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.tw.TWQingFilter[source]

Bases: TextReplaceFilter

Filter to fix the Qing authorities.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.tw.TWUnivFilter1[source]

Bases: TextReplaceFilter

Filter to fix the name of unversities in the Taiwan area.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.tw.TWUnivFilter2[source]

Bases: TextReplaceFilter

Filter to fix the name of unversities in the Taiwan area.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.tw.TWWithOthersFilter1[source]

Bases: TextReplaceFilter

Filter to fix the Taiwan name when it is with other countries.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.tw.TWWithOthersFilter2[source]

Bases: TextReplaceFilter

Filter to fix the Taiwan name when it is with other countries.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

class qiuwenbot.filter.tw.TWWithOthersInTitleFilter[source]

Bases: Filter

Filter to fix the Taiwan name in title when it is with other countries.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

filter(text: str) str[source]

Filter text.

Parameters:
textstr

Text to filter.

Returns:
str

Filtered text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.

qiuwenbot.filter.wg module

class qiuwenbot.filter.wg.WengeFilter[source]

Bases: TextReplaceFilter

Filter to add quote to Wen Ge.

Attributes:
log

Log of the filter.

Methods

filter(text)

Filter text.

property log: str

Log of the filter.

Returns:
str

Log of the filter.