示例#1
0
def generate_bar_charts(perl_exe, count_dirs, scratch_dir, output_dir):
    """Generate lines-of-code bar charts.

    :param perl_exe:
       the perl executable
    :param count_dirs:
       a list of directories where to count lines of code
    :param scratch_dir:
       where intermediate files (JSON, matplotlib scripts) are to be saved
    :param output_dir:
       where the bar charts are to be saved
    """
    # Create directory to save bar charts SVG
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    # Generate per-directory and total charts
    for count_dir in count_dirs:
        script = cloc_tools.bar_chart(perl_exe, count_dir, scratch_dir,
                                      output_dir)
        exec(compile(open(script).read(), script, 'exec'))
        os.remove(script)
    # Generate total charts
    script = cloc_tools.bar_chart(perl_exe,
                                  project_root_dir,
                                  scratch_dir,
                                  output_dir,
                                  is_total=True)
    exec(compile(open(script).read(), script, 'exec'))
    os.remove(script)
示例#2
0
def generate_bar_charts(mod_dir, dir_lang, savedir):
    r'''Generate lines-of-code bar charts.

    :param mod_dir:
       location of the cloc_tools module
    :param dir_lang:
       a (directory : language) dictionary
    :param savedir:
       location of the YAML files
    '''
    import sys
    sys.path.append(mod_dir)
    from cloc_tools import bar_chart
    # Generate scripts and list of scripts (absolute paths)
    list_of_scripts = [bar_chart(root_dir, language, savedir) for root_dir, language in dir_lang.iteritems()]
    # Generate charts
    [execfile(fname) for fname in list_of_scripts]