Skip to content

Commit 9027a79

Browse files
committed
Allow bypassing the download mechanism in get_sample_data
svn path=/branches/v1_0_maint/; revision=8776
1 parent 567f97a commit 9027a79

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

CHANGELOG

+4
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-08-21 Change Axis.set_view_interval() so that when updating an
26
existing interval, it respects the orientation of that
37
interval, and can enlarge but not reduce the interval.

lib/matplotlib/cbook.py

+12-1
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

+5-1
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,11 @@ def __call__(self, s):
566566
'keymap.grid' : ['g', validate_stringlist],
567567
'keymap.yscale' : ['l', validate_stringlist],
568568
'keymap.xscale' : [['k', 'L'], validate_stringlist],
569-
'keymap.all_axes' : ['a', validate_stringlist]
569+
'keymap.all_axes' : ['a', validate_stringlist],
570+
571+
# sample data
572+
'examples.download' : [True, validate_bool],
573+
'examples.directory' : ['', str],
570574

571575
}
572576

matplotlibrc.template

+9
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)