def _coverage(html=1):
    """Runs coverage with html output or returns percentage of coverage::

        fab coverage:1      # will create html output (default)
        fab coverage:0      # will return percentage

    """
    not_html = not int(html)
    settings_file = (not_html and 'settings.coverage_nohtml_settings'
                     or 'myprojcet.settings.coverage_settings')
    try:
        results = local('./manage.py test_coverage --settings={0} {1}'.format(
             settings_file, ' '.join(TEST_APPS)), capture=not_html)
    except:
        raise CoverageException(
            RED_BG("You have failing tests, run 'fab test' for more details"))

    if not_html:
        global_percentage = int(results.split("\n")[-3].split()[-1][:-1])
        files_percents = dict((
                line.split()[0],  # filename
                int(line.split()[3][:-1]),  # file percentage
            ) for line in results.split("-" * 45)[1].split("\n")[1:-1])

        errors = []
        for name, percentage in files_percents.iteritems():
            if 80 < percentage:
                errors.append(RED_BG(
                    'The file {0} is only covered to {1}%'.format(
                        name, percentage)))
        if errors:
            raise CoverageException(
                "\nThere isn't enought coverage:\n{0}".format(
                    "\n\t".join(errors)))
        else:
            print(GREEN_BG('{0}% of the code is covered'.format(
                global_percentage)))
    else:
        local('{0} coverage_html/index.html'.format(fab_settings.WWW_OPEN))
dataset/ETHPy150Open bitmazk/webfaction-django-boilerplate/website/webapps/django/project/fabfile/local.py/_coverage/swapped operands of `<`