<s> """<STR_LIT>""" <EOL> __docformat__ = '<STR_LIT>' <EOL> from os import curdir <EOL> from os . path import exists , join as opj <EOL> from . base import Interface <EOL> from . . support . param import Parameter <EOL> from . . support . constraints import EnsureStr , EnsureBool , EnsureNone <EOL> from . . support . collectionrepo import CollectionRepo <EOL> from datalad . support . collection_backends import CollectionRepoBackend <EOL> from datalad . support . handle_backends import CollectionRepoHandleBackend <EOL> from . . support . handlerepo import HandleRepo <EOL> from . . cmdline . helpers import get_repo_instance <EOL> from . . log import lgr <EOL> from datalad . cmdline . helpers import get_datalad_master <EOL> class Update ( Interface ) : <EOL> """<STR_LIT>""" <EOL> _params_ = dict ( <EOL> key = Parameter ( <EOL> args = ( '<STR_LIT:key>' , ) , <EOL> nargs = '<STR_LIT:?>' , <EOL> doc = "<STR_LIT>" , <EOL> constraints = EnsureStr ( ) | EnsureNone ( ) ) ) <EOL> def __call__ ( self , key = curdir ) : <EOL> local_master = get_datalad_master ( ) <EOL> if key == curdir : <EOL> try : <EOL> repo = get_repo_instance ( ) <EOL> except RuntimeError as e : <EOL> repo = local_master <EOL> elif exists ( key ) : <EOL> try : <EOL> repo = get_repo_instance ( path = key ) <EOL> except RuntimeError as e : <EOL> lgr . error ( str ( e ) ) <EOL> return - <NUM_LIT:1> <EOL> else : <EOL> if key in local_master . git_get_remotes ( ) : <EOL> path = CollectionRepoBackend ( local_master , key ) . url <EOL> if exists ( path ) : <EOL> try : <EOL> repo = CollectionRepo ( path ) <EOL> except RuntimeError as e : <EOL> lgr . error ( "<STR_LIT>" % ( key , str ( e ) ) ) <EOL> return - <NUM_LIT:1> <EOL> else : <EOL> lgr . error ( "<STR_LIT>" % <EOL> ( key , path ) ) <EOL> return - <NUM_LIT:1> <EOL> elif key in local_master . get_handle_list ( ) : <EOL> path = CollectionRepoHandleBackend ( local_master , key ) . url <EOL> if exists ( path ) : <EOL> try : <EOL> repo = HandleRepo ( path ) <EOL> except RuntimeError as e : <EOL> lgr . error ( "<STR_LIT>" % ( key , str ( e ) ) ) <EOL> return - <NUM_LIT:1> <EOL> else : <EOL> lgr . error ( "<STR_LIT>" % <EOL> ( key , path ) ) <EOL> return - <NUM_LIT:1> <EOL> else : <EOL> lgr . error ( "<STR_LIT>" <EOL> "<STR_LIT>" % key ) <EOL> return - <NUM_LIT:1> <EOL> for remote in repo . git_get_remotes ( ) : <EOL> repo . git_fetch ( remote ) </s>
