<s> from __future__ import division , absolute_import , print_function <EOL> import os <EOL> import sys <EOL> import requests <EOL> import test_lyrics <EOL> def mkdir_p ( path ) : <EOL> try : <EOL> os . makedirs ( path ) <EOL> except OSError : <EOL> if os . path . isdir ( path ) : <EOL> pass <EOL> else : <EOL> raise <EOL> def safe_open_w ( path ) : <EOL> """<STR_LIT>""" <EOL> mkdir_p ( os . path . dirname ( path ) ) <EOL> return open ( path , '<STR_LIT:w>' ) <EOL> def main ( argv = None ) : <EOL> """<STR_LIT>""" <EOL> if argv is None : <EOL> argv = sys . argv <EOL> print ( u'<STR_LIT>' ) <EOL> for s in test_lyrics . GOOGLE_SOURCES + test_lyrics . DEFAULT_SOURCES : <EOL> print ( s [ '<STR_LIT:url>' ] ) <EOL> url = s [ '<STR_LIT:url>' ] + s [ '<STR_LIT:path>' ] <EOL> fn = test_lyrics . url_to_filename ( url ) <EOL> if not os . path . isfile ( fn ) : <EOL> html = requests . get ( url , verify = False ) . text <EOL> with safe_open_w ( fn ) as f : <EOL> f . write ( html . encode ( '<STR_LIT:utf8>' ) ) <EOL> if __name__ == b'<STR_LIT:__main__>' : <EOL> sys . exit ( main ( ) ) </s>
