Skip to content

Replace pkg_resources.resource_string with pkgutil.get_data #1201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plotly/graph_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import os
import re
from pkg_resources import resource_string
import pkgutil

import six
from requests.compat import json as _json
Expand Down Expand Up @@ -69,7 +69,7 @@ def get_graph_reference():

"""
path = os.path.join('package_data', 'plot-schema.json')
s = resource_string('plotly', path).decode('utf-8')
s = pkgutil.get_data('plotly', path).decode('utf-8')
graph_reference = utils.decode_unicode(_json.loads(s))

# TODO: Patch in frames info until it hits streambed. See #659
Expand Down
4 changes: 2 additions & 2 deletions plotly/offline/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import uuid
import warnings
from pkg_resources import resource_string
import pkgutil
import time
import webbrowser

Expand Down Expand Up @@ -38,7 +38,7 @@ def download_plotlyjs(download_url):

def get_plotlyjs():
path = os.path.join('package_data', 'plotly.min.js')
plotlyjs = resource_string('plotly', path).decode('utf-8')
plotlyjs = pkgutil.get_data('plotly', path).decode('utf-8')
return plotlyjs

def get_image_download_script(caller):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from __future__ import absolute_import

import os
from pkg_resources import resource_string
from unittest import TestCase

from nose.plugins.attrib import attr
Expand Down
7 changes: 4 additions & 3 deletions plotly/widgets/graph_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
import uuid
from collections import deque
from pkg_resources import resource_string
import pkgutil

from requests.compat import json as _json

Expand All @@ -20,8 +20,9 @@
# Load JS widget code
# No officially recommended way to do this in any other way
# http://mail.scipy.org/pipermail/ipython-dev/2014-April/013835.html
js_widget_code = resource_string('plotly',
'package_data/graphWidget.js').decode('utf-8')
js_widget_code = pkgutil.get_data('plotly',
'package_data/graphWidget.js'
).decode('utf-8')

display(Javascript(js_widget_code))

Expand Down