def calculate_health(package_name, package_version=None, verbose=False, no_output=False):
total_score = <NUM_LIT:0><EOL>reasons = []<EOL>package_releases = CLIENT.package_releases(package_name)<EOL>if not package_releases:<EOL><INDENT>if not no_output:<EOL><INDENT>print(TERMINAL.red('<STR_LIT>'.format(package_name)))<EOL><DEDENT>return <NUM_LIT:0>, []<EOL><DEDENT>if package_version is None:<EOL><INDENT>package_version = package_releases[<NUM_LIT:0>]<EOL><DEDENT>package_info = CLIENT.release_data(package_name, package_version)<EOL>release_urls = CLIENT.release_urls(package_name, package_version)<EOL>if not package_info or not release_urls:<EOL><INDENT>if not no_output:<EOL><INDENT>print(TERMINAL.red('<STR_LIT>'.format(<EOL>package_version)))<EOL><DEDENT>return <NUM_LIT:0>, []<EOL><DEDENT>if not no_output:<EOL><INDENT>print(TERMINAL.bold('<STR_LIT>'.format(package_name, package_version)))<EOL>print('<STR_LIT>')<EOL><DEDENT>checkers = [<EOL>checks.check_license,<EOL>checks.check_homepage,<EOL>checks.check_summary,<EOL>checks.check_description,<EOL>checks.check_python_classifiers,<EOL>checks.check_author_info,<EOL>checks.check_release_files,<EOL>checks.check_stale<EOL>]<EOL>for checker in checkers:<EOL><INDENT>result, reason, score = checker(package_info, release_urls)<EOL>if result:<EOL><INDENT>total_score += score<EOL><DEDENT>else:<EOL><INDENT>reasons.append(reason)<EOL><DEDENT><DEDENT>if total_score < <NUM_LIT:0>:<EOL><INDENT>total_score = <NUM_LIT:0><EOL><DEDENT>if not no_output:<EOL><INDENT>percentage = int(float(total_score) / float(checks.TOTAL_POSSIBLE) * <NUM_LIT:100>)<EOL>score_string = '<STR_LIT>'.format(total_score, checks.TOTAL_POSSIBLE, percentage)<EOL>print(get_health_color(percentage)(score_string))<EOL><DEDENT>if verbose and not no_output:<EOL><INDENT>for reason in reasons:<EOL><INDENT>print(reason)<EOL><DEDENT><DEDENT>if no_output:<EOL><INDENT>return total_score, reasons<EOL><DEDENT>
Calculates the health of a package, based on several factors

:param package_name: name of package on pypi.python.org
:param package_version: version number of package to check, optional - defaults to latest version
:param verbose: flag to print out reasons
:param no_output: print no output
:param lint: run pylint on the package

:returns: (score: integer, reasons: list of reasons for score)
:rtype: tuple