<s> """<STR_LIT>""" <EOL> try : <EOL> import urllib <EOL> import sys <EOL> import os <EOL> import datetime <EOL> import json <EOL> except : <EOL> raise "<STR_LIT>" <EOL> def create_dir ( prefix ) : <EOL> dir_c = os . path . join ( os . getcwd ( ) , prefix , datetime . datetime . now ( ) . strftime ( '<STR_LIT>' ) ) <EOL> try : <EOL> os . makedirs ( dir_c ) <EOL> except OSError , e : <EOL> if e . errno != <NUM_LIT> : <EOL> pass <EOL> else : <EOL> print "<STR_LIT>" <EOL> exit <EOL> return dir_c <EOL> def gen_url ( name ) : <EOL> return "<STR_LIT>" + name + "<STR_LIT>" <EOL> def get_profile ( photo_url , save_url ) : <EOL> print "<STR_LIT>" + photo_url + "<STR_LIT>" <EOL> urllib . urlretrieve ( photo_url , save_url ) <EOL> return [ photo_url , save_url ] <EOL> def get_profile_of_id ( id1 , id2 ) : <EOL> photo_data = { } <EOL> photo_count = <NUM_LIT:1> <EOL> folder = create_dir ( '<STR_LIT>' ) <EOL> for i in xrange ( int ( id1 ) , int ( id2 ) + <NUM_LIT:1> ) : <EOL> photo_data [ photo_count ] = get_profile ( gen_url ( str ( i ) ) , folder + "<STR_LIT:/>" + str ( i ) + "<STR_LIT>" ) <EOL> photo_count += <NUM_LIT:1> <EOL> json . dump ( photo_data , open ( folder + "<STR_LIT>" , '<STR_LIT:wb>' ) ) <EOL> print "<STR_LIT>" + str ( photo_count - <NUM_LIT:1> ) <EOL> return <NUM_LIT:0> <EOL> def get_profile_of_file ( filename ) : <EOL> names = [ ] <EOL> with open ( filename ) as f : <EOL> content = f . readlines ( ) <EOL> for i in content : <EOL> names . append ( i . rstrip ( '<STR_LIT:\n>' ) . lstrip ( '<STR_LIT:U+0020>' ) ) <EOL> photo_data = { } <EOL> photo_count = <NUM_LIT:1> <EOL> folder = create_dir ( '<STR_LIT>' ) <EOL> for i in names : <EOL> photo_data [ photo_count ] = get_profile ( gen_url ( i ) , folder + "<STR_LIT:/>" + str ( i ) + "<STR_LIT>" ) <EOL> photo_count += <NUM_LIT:1> <EOL> json . dump ( photo_data , open ( folder + "<STR_LIT>" , '<STR_LIT:wb>' ) ) <EOL> print "<STR_LIT>" + str ( photo_count - <NUM_LIT:1> ) <EOL> return <NUM_LIT:0> <EOL> def main ( ) : <EOL> in_name = list ( sys . argv [ <NUM_LIT:1> : ] ) <EOL> if len ( in_name ) == <NUM_LIT:1> : print "<STR_LIT>" ; get_profile_of_file ( in_name [ <NUM_LIT:0> ] ) <EOL> elif len ( in_name ) == <NUM_LIT:2> : get_profile_of_id ( in_name [ <NUM_LIT:0> ] , in_name [ <NUM_LIT:1> ] ) <EOL> else : print "<STR_LIT>" <EOL> return <NUM_LIT:0> <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
