<s> try : <EOL> from cStringIO import StringIO <EOL> import xmlrpclib <EOL> except ImportError : <EOL> from io import StringIO <EOL> import xmlrpc . client as xmlrpclib <EOL> import werckercli <EOL> from werckercli . cli import puts , get_term <EOL> import semantic_version as semver <EOL> def find_current_version ( package , cur_version , index_urls = None ) : <EOL> if index_urls is None : <EOL> index_urls = [ '<STR_LIT>' ] <EOL> for index_url in index_urls : <EOL> pypi = xmlrpclib . ServerProxy ( index_url , xmlrpclib . Transport ( ) ) <EOL> pypi_hits = pypi . package_releases ( package ) <EOL> if len ( pypi_hits ) > <NUM_LIT:0> : <EOL> if semver . Version ( pypi_hits [ <NUM_LIT:0> ] ) > cur_version : <EOL> return semver . Version ( pypi_hits [ <NUM_LIT:0> ] ) <EOL> return False <EOL> def update ( current_version = None ) : <EOL> term = get_term ( ) <EOL> if current_version is None : <EOL> current_version = werckercli . __version__ <EOL> current_version = semver . Version ( current_version ) <EOL> newer_version = find_current_version ( <EOL> "<STR_LIT>" , <EOL> current_version <EOL> ) <EOL> if newer_version : <EOL> puts ( """<STR_LIT>""" . format ( newer_version = newer_version ) + <EOL> term . bold_white ( '<STR_LIT>' ) <EOL> ) <EOL> return True <EOL> else : <EOL> puts ( "<STR_LIT>" . format ( <EOL> version = current_version ) ) <EOL> return False </s>
