<s> """<STR_LIT>""" <EOL> from distutils . version import StrictVersion as V <EOL> import posixpath <EOL> from fabtools . files import is_link <EOL> from fabtools . system import UnsupportedFamily , distrib_family , distrib_id , distrib_release <EOL> from fabtools . utils import run_as_root <EOL> def is_module_enabled ( module ) : <EOL> """<STR_LIT>""" <EOL> return is_link ( '<STR_LIT>' % module ) <EOL> def enable_module ( module ) : <EOL> """<STR_LIT>""" <EOL> if not is_module_enabled ( module ) : <EOL> run_as_root ( '<STR_LIT>' % module ) <EOL> def disable_module ( module ) : <EOL> """<STR_LIT>""" <EOL> if is_module_enabled ( module ) : <EOL> run_as_root ( '<STR_LIT>' % module ) <EOL> def is_site_enabled ( site_name ) : <EOL> """<STR_LIT>""" <EOL> return is_link ( _site_link_path ( site_name ) ) <EOL> def enable_site ( site_name ) : <EOL> """<STR_LIT>""" <EOL> if not is_site_enabled ( site_name ) : <EOL> run_as_root ( '<STR_LIT>' % _site_config_filename ( site_name ) ) <EOL> def disable_site ( site_name ) : <EOL> """<STR_LIT>""" <EOL> if is_site_enabled ( site_name ) : <EOL> run_as_root ( '<STR_LIT>' % _site_config_filename ( site_name ) ) <EOL> def _site_config_path ( site_name ) : <EOL> config_filename = _site_config_filename ( site_name ) <EOL> return posixpath . join ( '<STR_LIT>' , config_filename ) <EOL> def _site_config_filename ( site_name ) : <EOL> if site_name == '<STR_LIT:default>' : <EOL> return _default__site_config_filename ( ) <EOL> else : <EOL> return '<STR_LIT>' . format ( site_name ) <EOL> def _site_link_path ( site_name ) : <EOL> link_filename = _site_link_filename ( site_name ) <EOL> return posixpath . join ( '<STR_LIT>' , link_filename ) <EOL> def _site_link_filename ( site_name ) : <EOL> if site_name == '<STR_LIT:default>' : <EOL> return _default__site_link_filename ( ) <EOL> else : <EOL> return '<STR_LIT>' . format ( site_name ) <EOL> def _default__site_config_filename ( ) : <EOL> return _choose ( old_style = '<STR_LIT:default>' , new_style = '<STR_LIT>' ) <EOL> def _default__site_link_filename ( ) : <EOL> return _choose ( old_style = '<STR_LIT>' , new_style = '<STR_LIT>' ) <EOL> def _choose ( old_style , new_style ) : <EOL> family = distrib_family ( ) <EOL> if family == '<STR_LIT>' : <EOL> distrib = distrib_id ( ) <EOL> at_least_trusty = ( distrib == '<STR_LIT>' and V ( distrib_release ( ) ) >= V ( '<STR_LIT>' ) ) <EOL> at_least_jessie = ( distrib == '<STR_LIT>' and V ( distrib_release ( ) ) >= V ( '<STR_LIT>' ) ) <EOL> if at_least_trusty or at_least_jessie : <EOL> return new_style <EOL> else : <EOL> return old_style <EOL> else : <EOL> raise UnsupportedFamily ( supported = [ '<STR_LIT>' ] ) <EOL> enable = enable_site <EOL> disable = disable_site <EOL> __all__ = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ] </s>
