<s> """<STR_LIT>""" <EOL> __docformat__ = '<STR_LIT>' <EOL> from os . path import join as opj , abspath <EOL> from . base import Interface <EOL> from datalad . support . param import Parameter <EOL> from datalad . support . constraints import EnsureStr <EOL> from datalad . support . collectionrepo import CollectionRepo <EOL> from datalad . support . collection_backends import CollectionRepoBackend <EOL> from datalad . support . handle_backends import CollectionRepoHandleBackend <EOL> from datalad . support . handle import Handle <EOL> from datalad . cmdline . helpers import get_datalad_master <EOL> class ListHandles ( Interface ) : <EOL> """<STR_LIT>""" <EOL> _params_ = dict ( <EOL> remote = Parameter ( <EOL> args = ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> action = "<STR_LIT:store_true>" , <EOL> doc = """<STR_LIT>""" ) , <EOL> ) <EOL> def __call__ ( self , remote = False ) : <EOL> """<STR_LIT>""" <EOL> local_master = get_datalad_master ( ) <EOL> handle_list = list ( ) <EOL> if remote : <EOL> for remote_branch in local_master . git_get_remote_branches ( ) : <EOL> if not remote_branch . endswith ( '<STR_LIT>' ) : <EOL> continue <EOL> for h in CollectionRepoBackend ( local_master , <EOL> branch = remote_branch ) : <EOL> handle_list . append ( <EOL> CollectionRepoHandleBackend ( local_master , key = h , <EOL> branch = remote_branch ) ) <EOL> remote_name = '<STR_LIT:/>' . join ( remote_branch . split ( '<STR_LIT:/>' ) [ : - <NUM_LIT:1> ] ) <EOL> print ( "<STR_LIT>" % ( remote_name , h ) ) <EOL> else : <EOL> for handle in local_master . get_handle_list ( ) : <EOL> handle_list . append ( <EOL> CollectionRepoHandleBackend ( local_master , handle ) ) <EOL> print ( handle ) <EOL> if not self . cmdline : <EOL> return handle_list </s>
