OLD | NEW |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-2016 Eyeo GmbH | 2 # Copyright (C) 2006-2016 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 |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License |
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
| 16 """ |
| 17 This script produces the list of top correct domain names currently in the |
| 18 database. |
| 19 """ |
| 20 |
16 import sys | 21 import sys |
17 import os | 22 import os |
18 import re | 23 import re |
19 import math | 24 import math |
20 import MySQLdb | 25 import MySQLdb |
21 from sitescripts.utils import get_config, setupStderr | 26 from sitescripts.utils import get_config, setupStderr |
22 | 27 |
23 ''' | |
24 This script produces the list of top correct domain names currently in the | |
25 database. | |
26 ''' | |
27 | |
28 STATUS_TYPED = 1 | 28 STATUS_TYPED = 1 |
29 STATUS_TYPO = 2 | 29 STATUS_TYPO = 2 |
30 STATUS_CORRECTION = 3 | 30 STATUS_CORRECTION = 3 |
31 STATUS_FALSE_POSITIVE = 4 | 31 STATUS_FALSE_POSITIVE = 4 |
32 | 32 |
33 | 33 |
34 def getTopDomains(count=5000): | 34 def getTopDomains(count=5000): |
35 db = _get_db() | 35 db = _get_db() |
36 cursor = db.cursor(MySQLdb.cursors.DictCursor) | 36 cursor = db.cursor(MySQLdb.cursors.DictCursor) |
37 cursor.execute('SELECT id, domain, forceinclusion FROM domains') | 37 cursor.execute('SELECT id, domain, forceinclusion FROM domains') |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 else: | 93 else: |
94 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, | 94 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, |
95 use_unicode=True, charset='utf8') | 95 use_unicode=True, charset='utf8') |
96 | 96 |
97 if __name__ == '__main__': | 97 if __name__ == '__main__': |
98 setupStderr() | 98 setupStderr() |
99 | 99 |
100 domains = getTopDomains() | 100 domains = getTopDomains() |
101 for domain in domains: | 101 for domain in domains: |
102 print domain.encode('utf-8') | 102 print domain.encode('utf-8') |
OLD | NEW |