@@ -28,11 +28,12 @@ class ReadmeAssetManager(object):
28
28
29
29
Set cache_path to None to disable caching.
30
30
"""
31
- def __init__ (self , cache_path , style_urls = None ):
31
+ def __init__ (self , cache_path , style_urls = None , quiet = None ):
32
32
super (ReadmeAssetManager , self ).__init__ ()
33
33
self .cache_path = cache_path
34
34
self .style_urls = list (style_urls ) if style_urls else []
35
35
self .styles = []
36
+ self .quiet = quiet
36
37
37
38
def _stip_url_params (self , url ):
38
39
return url .rsplit ('?' , 1 )[0 ].rsplit ('#' , 1 )[0 ]
@@ -67,8 +68,8 @@ class GitHubAssetManager(ReadmeAssetManager):
67
68
68
69
Set cache_path to None to disable caching.
69
70
"""
70
- def __init__ (self , cache_path , style_urls = None ):
71
- super (GitHubAssetManager , self ).__init__ (cache_path , style_urls )
71
+ def __init__ (self , cache_path , style_urls = None , quiet = None ):
72
+ super (GitHubAssetManager , self ).__init__ (cache_path , style_urls , quiet )
72
73
73
74
def _get_style_urls (self , asset_url_path ):
74
75
"""
@@ -122,7 +123,8 @@ def _cache_contents(self, style_urls, asset_url_path):
122
123
123
124
asset_urls = []
124
125
for style_url in style_urls :
125
- print (' * Downloading style' , style_url , file = sys .stderr )
126
+ if not self .quiet :
127
+ print (' * Downloading style' , style_url , file = sys .stderr )
126
128
r = requests .get (style_url )
127
129
if not 200 <= r .status_code < 300 :
128
130
print (' -> Warning: Style request responded with' ,
@@ -143,7 +145,8 @@ def _cache_contents(self, style_urls, asset_url_path):
143
145
files [filename ] = contents .encode ('utf-8' )
144
146
145
147
for asset_url in asset_urls :
146
- print (' * Downloading asset' , asset_url , file = sys .stderr )
148
+ if not self .quiet :
149
+ print (' * Downloading asset' , asset_url , file = sys .stderr )
147
150
# Retrieve binary file and show message
148
151
r = requests .get (asset_url , stream = True )
149
152
if not 200 <= r .status_code < 300 :
@@ -169,7 +172,8 @@ def _cache_contents(self, style_urls, asset_url_path):
169
172
for filename in cache :
170
173
with open (filename , 'wb' ) as f :
171
174
f .write (cache [filename ])
172
- print (' * Cached all downloads in' , self .cache_path , file = sys .stderr )
175
+ if not self .quiet :
176
+ print (' * Cached all downloads in' , self .cache_path , file = sys .stderr )
173
177
return True
174
178
175
179
def retrieve_styles (self , asset_url_path ):
0 commit comments