<s> """<STR_LIT>""" <EOL> from fabric . api import run <EOL> from fabtools import mercurial <EOL> from fabtools . files import is_dir <EOL> from fabtools . system import UnsupportedFamily , distrib_family <EOL> def command ( ) : <EOL> """<STR_LIT>""" <EOL> from fabtools . require . deb import package as require_deb_package <EOL> from fabtools . require . rpm import package as require_rpm_package <EOL> from fabtools . require . portage import package as require_portage_package <EOL> res = run ( '<STR_LIT>' , quiet = True ) <EOL> if res . failed : <EOL> family = distrib_family ( ) <EOL> if family == '<STR_LIT>' : <EOL> require_deb_package ( '<STR_LIT>' ) <EOL> elif family == '<STR_LIT>' : <EOL> require_portage_package ( '<STR_LIT>' ) <EOL> elif family == '<STR_LIT>' : <EOL> require_rpm_package ( '<STR_LIT>' ) <EOL> else : <EOL> raise UnsupportedFamily ( supported = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def working_copy ( remote_url , path = None , branch = "<STR_LIT:default>" , update = True , <EOL> use_sudo = False , user = None ) : <EOL> """<STR_LIT>""" <EOL> command ( ) <EOL> if path is None : <EOL> path = remote_url . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> if is_dir ( path , use_sudo = use_sudo ) : <EOL> mercurial . pull ( path , use_sudo = use_sudo , user = user ) <EOL> if update : <EOL> mercurial . update ( path = path , branch = branch , use_sudo = use_sudo , <EOL> user = user ) <EOL> elif not is_dir ( path , use_sudo = use_sudo ) : <EOL> mercurial . clone ( remote_url , path = path , use_sudo = use_sudo , user = user ) <EOL> mercurial . update ( path = path , branch = branch , use_sudo = use_sudo , user = user ) <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" ) </s>
