diff --git a/MANIFEST.in b/MANIFEST.in index 8949635..cf8130d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ recursive-exclude tests * include *.txt include *.rst -include serpextract/search_engines.pickle* \ No newline at end of file +include serpextract/search_engines.* \ No newline at end of file diff --git a/serpextract/search_engines.pickle2 b/serpextract/search_engines.py2.pickle similarity index 100% rename from serpextract/search_engines.pickle2 rename to serpextract/search_engines.py2.pickle diff --git a/serpextract/search_engines.pickle3 b/serpextract/search_engines.py3.pickle similarity index 100% rename from serpextract/search_engines.pickle3 rename to serpextract/search_engines.py3.pickle diff --git a/serpextract/serpextract.py b/serpextract/serpextract.py index 05cab0b..4df95a4 100644 --- a/serpextract/serpextract.py +++ b/serpextract/serpextract.py @@ -2,8 +2,9 @@ referrers.""" from __future__ import absolute_import, division, print_function -import re import logging +import re +import sys from itertools import groupby import pylru @@ -210,7 +211,7 @@ def _get_piwik_engines(): cache this result since it's only supposed to be called once. """ stream = pkg_resources.resource_stream - pickle_path = 'search_engines.pickle' + ('3' if PY3 else '2') + pickle_path = 'search_engines.py{}.pickle'.format(sys.version_info[0]) with stream(__name__, pickle_path) as picklestream: _piwik_engines = pickle.load(picklestream) diff --git a/update_list.py b/update_list.py index cb86d3b..dc30c32 100644 --- a/update_list.py +++ b/update_list.py @@ -3,6 +3,7 @@ from __future__ import absolute_import, division, print_function import os +import sys from collections import OrderedDict from subprocess import Popen, PIPE @@ -14,7 +15,6 @@ import simplejson as json except ImportError: import json -from six import PY2 from six.moves.urllib.request import urlopen @@ -23,7 +23,8 @@ def main(): - filename = _here('serpextract', 'search_engines.pickle') + py_version = sys.version_info[0] + filename = _here('serpextract', 'search_engines.py{}.pickle'.format(py_version)) print('Updating search engine parser definitions (requires PHP).') url = urlopen('https://raw.githubusercontent.com/piwik/piwik/2.14.3/core/DataFiles/SearchEngines.php') @@ -35,7 +36,6 @@ def main(): # Ordering of the dictionary from PHP matters so we keep it in an # OrderedDict piwik_engines = json.loads(json_string, object_pairs_hook=OrderedDict) - filename += '2' if PY2 else '3' with open(filename, 'wb') as pickle_file: pickle.dump(piwik_engines, pickle_file)