<s> """<STR_LIT>""" <EOL> import logging <EOL> import re , os , urllib <EOL> logger = logging . getLogger ( __name__ ) <EOL> class dataset_resolver : <EOL> class package_info : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , cf , name , ts , rs , src , whr ) : <EOL> self . configuration_file = cf <EOL> self . name = name <EOL> self . timestamp = int ( ts ) <EOL> self . readable_size = rs <EOL> self . source = src <EOL> self . where = whr <EOL> installed_packages_list = { } <EOL> def read_installed_packages_list ( self , from_location ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> installed_list_file = open ( from_location + "<STR_LIT>" ) <EOL> except IOError : <EOL> pass <EOL> else : <EOL> for line in installed_list_file : <EOL> l = line . rstrip ( ) . split ( '<STR_LIT:U+0020>' ) <EOL> if l : <EOL> self . installed_packages_list [ l [ <NUM_LIT:0> ] ] = this_package = self . package_info ( <EOL> from_location , <EOL> l [ <NUM_LIT:0> ] , <EOL> l [ <NUM_LIT:1> ] , <EOL> l [ <NUM_LIT:2> ] , <EOL> urllib . unquote ( l [ <NUM_LIT:3> ] ) , <EOL> urllib . unquote ( l [ <NUM_LIT:4> ] ) ) <EOL> else : <EOL> pass <EOL> def resolve_dataset ( self , dataset_name ) : <EOL> """<STR_LIT>""" <EOL> if dataset_name in self . installed_packages_list : <EOL> return os . path . join ( self . installed_packages_list [ dataset_name ] . where , <EOL> self . installed_packages_list [ dataset_name ] . name ) <EOL> else : <EOL> return None <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> paths = [ "<STR_LIT>" , os . environ [ "<STR_LIT>" ] + "<STR_LIT>" ] <EOL> try : <EOL> paths += re . split ( "<STR_LIT>" , os . environ [ "<STR_LIT>" ] ) <EOL> except Exception : <EOL> pass <EOL> for path in paths : <EOL> self . read_installed_packages_list ( path ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> x = dataset_resolver ( ) <EOL> logger . info ( x . resolve_dataset ( "<STR_LIT>" ) ) <EOL> logger . info ( x . resolve_dataset ( "<STR_LIT>" ) ) </s>
