Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: abp/stats/filterhits.py

Issue 30037555: NoIssue - Added filterhit statistics loading capability
Left Patch Set: Removed .DS_Store files Created April 3, 2019, 4:16 p.m.
Right Patch Set: Addressed final comments (for real now) Created April 3, 2019, 5:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « abp/stats/__init__.py ('k') | setup.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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']
Vasily Kuznetsov 2019/04/03 16:36:28 What about domains and rootdomains? They seem usef
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
LEFTRIGHT

Powered by Google App Engine
This is Rietveld