Skip to content

Commit

Permalink
Rename pickle files to include py2 and py3 instead of version suffixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-blanchard committed Jan 8, 2016
1 parent 51430b5 commit df458eb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
recursive-exclude tests *
include *.txt
include *.rst
include serpextract/search_engines.pickle*
include serpextract/search_engines.*
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions serpextract/serpextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions update_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -14,7 +15,6 @@
import simplejson as json
except ImportError:
import json
from six import PY2
from six.moves.urllib.request import urlopen


Expand All @@ -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')
Expand All @@ -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)

Expand Down

0 comments on commit df458eb

Please sign in to comment.