| 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 17 matching lines...) Expand all Loading... |
| 28 sources: iterable of str | 28 sources: iterable of str |
| 29 With the filter sources we're interested in. If not None, only filters | 29 With the filter sources we're interested in. If not None, only filters |
| 30 from these sources will be included in the result. | 30 from these sources will be included in the result. |
| 31 | 31 |
| 32 Returns | 32 Returns |
| 33 ------- | 33 ------- |
| 34 generator of dict | 34 generator of dict |
| 35 With the csv entries. | 35 With the csv entries. |
| 36 | 36 |
| 37 """ | 37 """ |
| 38 integer_cols = ['onehour_sessions', 'hits'] | 38 integer_cols = ['onehour_sessions', 'hits', 'domains', 'rootdomains'] |
| 39 | 39 |
| 40 with open(path) as csvstream: | 40 with open(path) as csvstream: |
| 41 reader = csv.DictReader(csvstream) | 41 reader = csv.DictReader(csvstream) |
| 42 | 42 |
| 43 for entry in reader: | 43 for entry in reader: |
| 44 if sources and entry['source'] not in sources: | 44 if sources and entry['source'] not in sources: |
| 45 continue | 45 continue |
| 46 for col in integer_cols: | 46 for col in integer_cols: |
| 47 entry[col] = int(entry[col]) | 47 try: |
| 48 entry[col] = int(entry[col]) |
| 49 except KeyError: |
| 50 continue |
| 48 | 51 |
| 49 yield entry | 52 yield entry |
| LEFT | RIGHT |