| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 # This file is part of Adblock Plus <https://adblockplus.org/>, | 1 # This file is part of Adblock Plus <https://adblockplus.org/>, |
| 2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
| 3 # | 3 # |
| 4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
| 5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
| 6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
| 7 # | 7 # |
| 8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 from abp.filters import parse_line | 24 from abp.filters import parse_line |
| 25 | 25 |
| 26 __all__ = ['line2dict'] | 26 __all__ = ['line2dict'] |
| 27 | 27 |
| 28 | 28 |
| 29 def tuple2dict(data): | 29 def tuple2dict(data): |
| 30 """Convert a parsed filter from a namedtuple to a dict. | 30 """Convert a parsed filter from a namedtuple to a dict. |
| 31 | 31 |
| 32 Parameters | 32 Parameters |
| 33 ---------- | 33 ---------- |
| 34 filter: namedtuple | 34 data: namedtuple |
|
Vasily Kuznetsov
2018/08/08 14:32:50
Nit: parameter name mismatch :)
Tudor Avram
2018/08/09 12:55:02
Done.
| |
| 35 The parsed filter. | 35 The parsed filter. |
| 36 | 36 |
| 37 Returns | 37 Returns |
| 38 ------- | 38 ------- |
| 39 dict | 39 dict |
| 40 The resulting dictionary | 40 The resulting dictionary |
| 41 | 41 |
| 42 """ | 42 """ |
| 43 result = dict(data._asdict()) | 43 result = dict(data._asdict()) |
| 44 result['type'] = data.__class__.__name__ | 44 result['type'] = data.__class__.__name__ |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 The filter text we want to parse | 84 The filter text we want to parse |
| 85 | 85 |
| 86 Returns | 86 Returns |
| 87 ------- | 87 ------- |
| 88 dict | 88 dict |
| 89 With the parsing results and all strings converted to utf8 byte | 89 With the parsing results and all strings converted to utf8 byte |
| 90 strings. | 90 strings. |
| 91 | 91 |
| 92 """ | 92 """ |
| 93 return strings2utf8(tuple2dict(parse_line(text))) | 93 return strings2utf8(tuple2dict(parse_line(text))) |
| LEFT | RIGHT |