Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d522db

Browse files
committed
Merged revisions 8776 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v1_0_maint ........ r8776 | jouni | 2010-11-07 10:06:41 +0200 (Sun, 07 Nov 2010) | 2 lines Allow bypassing the download mechanism in get_sample_data ........ svn path=/trunk/matplotlib/; revision=8777
1 parent f589dee commit 5d522db

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2010-11-07 New rc parameters examples.download and examples.directory
2+
allow bypassing the download mechanism in get_sample_data.
3+
- JKS
4+
15
2010-10-04 Fix JPEG saving bug: only accept the kwargs documented
26
by PIL for JPEG files. - JKS
37

lib/matplotlib/cbook.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,20 @@ def get_sample_data(fname, asfileobj=True):
649649
svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/sample_data
650650
651651
and svn add the data file you want to support. This is primarily
652-
intended for use in mpl examples that need custom data
652+
intended for use in mpl examples that need custom data.
653+
654+
To bypass all downloading, set the rc parameter examples.download to False
655+
and examples.directory to the directory where we should look.
653656
"""
654657

658+
if not matplotlib.rcParams['examples.download']:
659+
directory = matplotlib.rcParams['examples.directory']
660+
f = os.path.join(directory, fname)
661+
if asfileobj:
662+
return open(f, 'rb')
663+
else:
664+
return f
665+
655666
myserver = get_sample_data.myserver
656667
if myserver is None:
657668
configdir = matplotlib.get_configdir()

lib/matplotlib/rcsetup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,11 @@ def __call__(self, s):
553553
'keymap.grid' : ['g', validate_stringlist],
554554
'keymap.yscale' : ['l', validate_stringlist],
555555
'keymap.xscale' : [['k', 'L'], validate_stringlist],
556-
'keymap.all_axes' : ['a', validate_stringlist]
556+
'keymap.all_axes' : ['a', validate_stringlist],
557+
558+
# sample data
559+
'examples.download' : [True, validate_bool],
560+
'examples.directory' : ['', str],
557561

558562
}
559563

matplotlibrc.template

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,12 @@ backend : %(backend)s
370370
#keymap.xscale : L, k # toggle scaling of x-axes ('log'/'linear')
371371
#keymap.all_axes : a # enable all axes
372372

373+
# Control downloading of example data. Various examples download some
374+
# data from the Matplotlib svn repository to avoid distributing extra
375+
# files, but sometimes you want to avoid that. In that case set
376+
# examples.download to False and examples.directory to the directory
377+
# where you have a checkout of
378+
# https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/sample_data
379+
380+
#examples.download : True # False to bypass downloading mechanism
381+
#examples.directory : '' # absolute directory to look in if download is false

0 commit comments

Comments
 (0)