Opened on 05/08/2019 at 12:09:29 PM

Closed on 05/10/2019 at 08:33:52 AM

Last modified on 05/14/2019 at 05:16:35 PM

#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": [

Attachments (0)

Change History (6)

comment:1 Changed on 05/08/2019 at 03:26:28 PM 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 on 05/08/2019 at 07:23:08 PM by esanchez

  • Cc esanchez added

comment:3 Changed on 05/09/2019 at 11:19:22 AM by kvas

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

comment:4 Changed on 05/10/2019 at 08:33:31 AM by abpbot

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

comment:5 Changed on 05/10/2019 at 08:33:52 AM by kvas

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

comment:6 Changed on 05/14/2019 at 05:16:35 PM by greiner

  • Cc greiner added

Add Comment

Modify Ticket

Change Properties
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none).
Note: See TracTickets for help on using tickets.