Opened 14 months ago

Closed 14 months ago

Last modified 14 months ago

#7471 closed change (fixed)

[python-abp] Parsing filter blocks

Reported by: kvas Assignee:
Priority: P3 Milestone:
Module: Sitescripts Keywords:
Cc: esanchez, greiner Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

Description (last modified by kvas)


Our exception list contains blocks like this:

! Text/image ads on

There are several contexts, in which we would like to work with these blocks directly (one of these is Edmundo's work on a streamlined whitelisting process that lead to the original formulation of this ticket). It would be good if python-abp could provide a standardized and convenient way to work with such blocks.

What to change

Provide an API that takes a sequence of parsed filters (and other filter list lines) and returns a sequence of FiltersBlock objects that contain the properties defined via !:<name>=<value> syntax as well as filters that is a list of filter objects and description, which is all normal comments (separated by line breaks).

Filter blocks should also support _asdict() API that converts them to nested Python dicts for further JSON-ization (filters already support it by virtue of being named tuples). Example:

  “partner_token”: “”,
  “partner_id”: ”ee1f510910c7063c”,
  “type”: "partner",
  “forum”: ””,
  “description”: ”Text/image ads on”
  “filters”: [
       "text": "@@||$image,",
       "selector": {
         "type": "url-pattern",
         "value": "||"
       "action": "allow",
       "options": [

Change History (6)

comment:1 Changed 14 months ago by kvas

  • Description modified (diff)
  • Summary changed from [python-abp] Variables inside filter list comments to [python-abp] Parsing filter blocks

I updated the ticket based on further discussion with Edmundo and clarified use case.

comment:2 Changed 14 months ago by esanchez

  • Cc esanchez added

comment:3 Changed 14 months ago by kvas

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:4 Changed 14 months ago by abpbot

A commit referencing this issue has landed:
Issue 7471 - Add an API for working with blocks of filters

comment:5 Changed 14 months ago by kvas

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:6 Changed 14 months ago by greiner

  • Cc greiner added
Note: See TracTickets for help on using tickets.