@@ -448,12 +448,13 @@ def to_filehandle(fname, flag='rU', return_opened=False):
448
448
def is_scalar_or_string (val ):
449
449
return is_string_like (val ) or not iterable (val )
450
450
451
- class ViewVCCachedServer (urllib2 .BaseHandler ):
451
+ class ViewVCCachedServer (urllib2 .HTTPSHandler ):
452
452
"""
453
453
Urllib2 handler that takes care of caching files.
454
454
The file cache.pck holds the directory of files that have been cached.
455
455
"""
456
456
def __init__ (self , cache_dir , baseurl ):
457
+ urllib2 .HTTPSHandler .__init__ (self )
457
458
self .cache_dir = cache_dir
458
459
self .baseurl = baseurl
459
460
self .read_cache ()
@@ -544,7 +545,7 @@ def cache_file(self, url, data, headers):
544
545
# http_error_304 for handling 304 Not Modified responses
545
546
# http_response for postprocessing requests
546
547
547
- def http_request (self , req ):
548
+ def https_request (self , req ):
548
549
"""
549
550
Make the request conditional if we have a cached file.
550
551
"""
@@ -555,20 +556,21 @@ def http_request(self, req):
555
556
req .add_header ("If-Modified-Since" , lastmod )
556
557
return req
557
558
558
- def http_error_304 (self , req , fp , code , msg , hdrs ):
559
+ def https_error_304 (self , req , fp , code , msg , hdrs ):
559
560
"""
560
561
Read the file from the cache since the server has no newer version.
561
562
"""
562
563
url = req .get_full_url ()
563
564
fn , _ , _ = self .cache [url ]
564
- matplotlib .verbose .report ('ViewVCCachedServer: reading data file from cache file "%s"'
565
- % fn , 'debug' )
565
+ matplotlib .verbose .report (
566
+ 'ViewVCCachedServer: reading data file from cache file "%s"' % fn ,
567
+ 'debug' )
566
568
file = open (fn , 'rb' )
567
569
handle = urllib2 .addinfourl (file , hdrs , url )
568
570
handle .code = 304
569
571
return handle
570
572
571
- def http_response (self , req , response ):
573
+ def https_response (self , req , response ):
572
574
"""
573
575
Update the cache with the returned file.
574
576
"""
@@ -589,7 +591,7 @@ def http_response(self, req, response):
589
591
def get_sample_data (self , fname , asfileobj = True ):
590
592
"""
591
593
Check the cachedirectory for a sample_data file. If it does
592
- not exist, fetch it with urllib from the svn repo and
594
+ not exist, fetch it with urllib from the git repo and
593
595
store it in the cachedir.
594
596
595
597
If asfileobj is True, a file object will be returned. Else the
@@ -637,21 +639,21 @@ def get_sample_data(self, fname, asfileobj=True):
637
639
def get_sample_data (fname , asfileobj = True ):
638
640
"""
639
641
Check the cachedirectory ~/.matplotlib/sample_data for a sample_data
640
- file. If it does not exist, fetch it with urllib from the mpl svn repo
642
+ file. If it does not exist, fetch it with urllib from the mpl git repo
641
643
642
- http ://matplotlib.svn.sourceforge.net/svnroot/ matplotlib/trunk/ sample_data/
644
+ https ://github.com/ matplotlib/sample_data/raw/master
643
645
644
646
and store it in the cachedir.
645
647
646
648
If asfileobj is True, a file object will be returned. Else the
647
649
path to the file as a string will be returned
648
650
649
651
To add a datafile to this directory, you need to check out
650
- sample_data from matplotlib svn ::
652
+ sample_data from matplotlib git ::
651
653
652
- svn co https:// matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk /sample_data
654
+ git clone git@github.com: matplotlib/sample_data
653
655
654
- and svn add the data file you want to support. This is primarily
656
+ and git add the data file you want to support. This is primarily
655
657
intended for use in mpl examples that need custom data.
656
658
657
659
To bypass all downloading, set the rc parameter examples.download to False
@@ -670,12 +672,13 @@ def get_sample_data(fname, asfileobj=True):
670
672
if myserver is None :
671
673
configdir = matplotlib .get_configdir ()
672
674
cachedir = os .path .join (configdir , 'sample_data' )
673
- baseurl = 'http ://matplotlib.svn.sourceforge.net/svnroot/ matplotlib/trunk/ sample_data/'
675
+ baseurl = 'https ://github.com/ matplotlib/sample_data/raw/master /'
674
676
myserver = get_sample_data .myserver = ViewVCCachedServer (cachedir , baseurl )
675
677
676
678
return myserver .get_sample_data (fname , asfileobj = asfileobj )
677
679
678
680
get_sample_data .myserver = None
681
+
679
682
def flatten (seq , scalarp = is_scalar_or_string ):
680
683
"""
681
684
this generator flattens nested containers such as
0 commit comments