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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 Returns | 88 Returns |
89 ------- | 89 ------- |
90 dict | 90 dict |
91 With the parsing results and all strings converted to utf8 byte | 91 With the parsing results and all strings converted to utf8 byte |
92 strings. | 92 strings. |
93 | 93 |
94 """ | 94 """ |
95 return strings2utf8(tuple2dict(parse_line(text, mode))) | 95 return strings2utf8(tuple2dict(parse_line(text, mode))) |
96 | 96 |
97 | 97 |
98 def lines2dict(string_list, mode='start'): | 98 def lines2dicts(string_list, mode='body'): |
99 """Convert a list of filterlist strings to a dictionary. | 99 """Convert a list of filterlist strings to a dictionary. |
100 | 100 |
101 All strings in the output dictionary will be UTF8 byte strings. This is | 101 All strings in the output dictionary will be UTF8 byte strings. This is |
102 necessary to prevent unicode encoding errors in rPython conversion layer. | 102 necessary to prevent unicode encoding errors in rPython conversion layer. |
103 | 103 |
104 Parameters | 104 Parameters |
105 ---------- | 105 ---------- |
106 string_list: iterable of str | 106 string_list: iterable of str |
107 Each string in the list can be a header, metadata, empty line, | 107 Each string in the list can be an empty line, include instruction, or |
108 include instruction, or filter. | 108 filter. If the mode is 'start', headers and metadata can also be |
109 parsed. | |
109 mode: str | 110 mode: str |
110 Parsing mode. Note: The default is 'start' in case any of the filters | 111 Parsing mode (see `abp.filters.parser.parse_line`). |
Vasily Kuznetsov
2019/01/24 13:27:59
I think the default should be 'body'. The data tea
rhowell
2019/01/25 00:30:07
Done.
| |
111 are a header or metadata. For more information, see | |
112 `abp.filters.parser.parse_line` | |
113 | 112 |
114 Returns | 113 Returns |
115 ------- | 114 ------- |
116 dict | 115 list of dict |
Vasily Kuznetsov
2019/01/24 13:27:59
If I understand it right, the output should be a l
rhowell
2019/01/25 00:30:07
Done.
| |
117 With the parsing results and all strings converted to utf8 byte | 116 With the parsing results and all strings converted to utf8 byte |
118 strings. | 117 strings. |
119 | 118 |
120 """ | 119 """ |
121 result = {} | 120 result = [] |
122 for string in string_list: | 121 for string in string_list: |
123 result[string] = line2dict(string, mode) | 122 result.append(line2dict(string, mode)) |
124 return result | 123 return result |
LEFT | RIGHT |