LEFT | RIGHT |
1 # python-abp | 1 # python-abp |
2 | 2 |
3 This repository contains a library for working with Adblock Plus filter lists | 3 This repository contains a library for working with Adblock Plus filter lists |
4 and the script that is used for building Adblock Plus filter lists from the | 4 and the script that is used for building Adblock Plus filter lists from the |
5 form in which they are authored into the format suitable for consumption by the | 5 form in which they are authored into the format suitable for consumption by the |
6 adblocking software. | 6 adblocking software. |
7 | 7 |
8 ## Installation | 8 ## Installation |
9 | 9 |
10 Prerequisites: | 10 Prerequisites: |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 The filter lists are originally authored in relatively smaller parts focused | 22 The filter lists are originally authored in relatively smaller parts focused |
23 on a particular type of filters, related to a specific topic or relevant | 23 on a particular type of filters, related to a specific topic or relevant |
24 for particular geographical area. | 24 for particular geographical area. |
25 We call these parts _filter list fragments_ (or just _fragments_) | 25 We call these parts _filter list fragments_ (or just _fragments_) |
26 to distinguish them from full filter lists that are | 26 to distinguish them from full filter lists that are |
27 consumed by the adblocking software such as Adblock Plus. | 27 consumed by the adblocking software such as Adblock Plus. |
28 | 28 |
29 Rendering is a process that combines filter list fragments into a filter list. | 29 Rendering is a process that combines filter list fragments into a filter list. |
30 It starts with one fragment that can include other ones and so forth. | 30 It starts with one fragment that can include other ones and so forth. |
31 The produced filter list is marked with a version and a timestamp. | 31 The produced filter list is marked with a [version and a timestamp][1]. |
32 | 32 |
33 Python-abp contains a script that can do this called `flrender`: | 33 Python-abp contains a script that can do this called `flrender`: |
34 | 34 |
35 $ flrender fragment.txt filterlist.txt | 35 $ flrender fragment.txt filterlist.txt |
36 | 36 |
37 This will take the top level fragment in `fragment.txt`, render it and save into | 37 This will take the top level fragment in `fragment.txt`, render it and save into |
38 `filterlist.txt`. | 38 `filterlist.txt`. |
39 | 39 |
40 The `flrender` script can also be used by only specifying `fragment.txt`: | 40 The `flrender` script can also be used by only specifying `fragment.txt`: |
41 | 41 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 lines of a filter list: `parse_line`. It returns a parsed line object just like | 121 lines of a filter list: `parse_line`. It returns a parsed line object just like |
122 the items in the iterator returned by `parse_filterlist`. | 122 the items in the iterator returned by `parse_filterlist`. |
123 | 123 |
124 For further information on the library API use `help()` on `abp.filters` and | 124 For further information on the library API use `help()` on `abp.filters` and |
125 its contents in interactive Python session, read the docstrings or look at the | 125 its contents in interactive Python session, read the docstrings or look at the |
126 tests for some usage examples. | 126 tests for some usage examples. |
127 | 127 |
128 ## Testing | 128 ## Testing |
129 | 129 |
130 Unit tests for `python-abp` are located in the `/tests` directory. | 130 Unit tests for `python-abp` are located in the `/tests` directory. |
131 [Pytest][3] is used for quickly running the tests | 131 [Pytest][2] is used for quickly running the tests |
132 during development. | 132 during development. |
133 [Tox][4] is used for testing in different | 133 [Tox][3] is used for testing in different |
134 environments (Python 2.7, Python 3.5+ and PyPy) and code quality | 134 environments (Python 2.7, Python 3.5+ and PyPy) and code quality |
135 reporting. | 135 reporting. |
136 | 136 |
137 In order to execute the tests, first create and activate development | 137 In order to execute the tests, first create and activate development |
138 virtualenv: | 138 virtualenv: |
139 | 139 |
140 $ python setup.py devenv | 140 $ python setup.py devenv |
141 $ . devenv/bin/activate | 141 $ . devenv/bin/activate |
142 | 142 |
143 With the development virtualenv activated use pytest for a quick test run: | 143 With the development virtualenv activated use pytest for a quick test run: |
144 | 144 |
145 (devenv) $ pytest tests | 145 (devenv) $ pytest tests |
146 | 146 |
147 and tox for a comprehensive report: | 147 and tox for a comprehensive report: |
148 | 148 |
149 (devenv) $ tox | 149 (devenv) $ tox |
150 | 150 |
151 ## Development | 151 ## Development |
152 | 152 |
153 When adding new functionality, add tests for it (preferably first). Code | 153 When adding new functionality, add tests for it (preferably first). Code |
154 coverage (as measured by `tox -e qa`) should not decrease and the tests | 154 coverage (as measured by `tox -e qa`) should not decrease and the tests |
155 should pass in all Tox environments. | 155 should pass in all Tox environments. |
156 | 156 |
157 All public functions, classes and methods should have docstrings compliant with | 157 All public functions, classes and methods should have docstrings compliant with |
158 [NumPy/SciPy documentation guide][5]. One exception is the constructors of | 158 [NumPy/SciPy documentation guide][4]. One exception is the constructors of |
159 classes that the user is not expected to instantiate (such as exceptions). | 159 classes that the user is not expected to instantiate (such as exceptions). |
160 | 160 |
161 [1]: https://adblockplus.org/filters#special-comments | 161 [1]: https://adblockplus.org/filters#special-comments |
162 [2]: https://adblockplus.org/filters#options | 162 [2]: http://pytest.org/ |
163 [3]: http://pytest.org/ | 163 [3]: https://tox.readthedocs.org/ |
164 [4]: https://tox.readthedocs.org/ | 164 [4]: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt |
165 [5]: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt | |
LEFT | RIGHT |