<commit_before>from pythoscope.inspector import static, dynamic
from pythoscope.store import ModuleNotFound
from pythoscope.util import python_modules_below


def inspect_project(project):
    for modpath in python_modules_below(project.path):
        try:
            module = project.find_module_by_full_path(modpath)
            if module.is_up_to_date():
                print "Info: %s hasn't changed since last inspection, skipping." % module.subpath
                continue
        except ModuleNotFound:
            pass
        static.inspect_module(project, modpath)

    for poe in project.points_of_entry.values():
        try:
            dynamic.inspect_point_of_entry(poe)
        except SyntaxError, err:
            print "Warning: Point of entry contains a syntax error:", err
        except (Exception, KeyboardInterrupt, SystemExit), err:
            print "Warning: Point of entry exited with error:", repr(err)<commit_msg>  Don't run points of entry if the source code wasn't modified.<commit_after>from pythoscope.inspector import static, dynamic
from pythoscope.store import ModuleNotFound
from pythoscope.util import python_modules_below


def inspect_project(project):
    # If nothing new was discovered statically, it's also no use to run
    # dynamic inspection.
    if inspect_project_statically(project) > 0:
        inspect_project_dynamically(project)
    else:
        print "Info: No changes discovered in the source code, skipping dynamic inspection."

def inspect_project_statically(project):
    count = 0
    for modpath in python_modules_below(project.path):
        try:
            module = project.find_module_by_full_path(modpath)
            if module.is_up_to_date():
                print "Info: %s hasn't changed since last inspection, skipping." % module.subpath
                continue
        except ModuleNotFound:
            pass
        static.inspect_module(project, modpath)
        count += 1
    return count

def inspect_project_dynamically(project):
    for poe in project.points_of_entry.values():
        try:
            dynamic.inspect_point_of_entry(poe)
        except SyntaxError, err:
            print "Warning: Point of entry contains a syntax error:", err
        except (Exception, KeyboardInterrupt, SystemExit), err:
            print "Warning: Point of entry exited with error:", repr(err)
{'fraction_non_alphanumeric': 0.06798986486486487, 'fraction_numerical': 0.001266891891891892, 'mean_word_length': 2.889983579638752, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7637631', 'n_tokens_mistral': 648, 'n_tokens_neox': 613, 'n_words': 197}