Example #1
0
def hook_preconvert_external_linecount():
    global python_export_file_contents, total_lines
    with open('input/external_lines_of_code.json') as f:
        rjson = json.load(f)
        for project, lines in rjson.items():
            if len(project) > 0 and len(lines) > 0:
                project_lines[project] = int(lines)
    sorted_pl = sorted(project_lines.items(), key=lambda x : x[1])#Sort by lines of code
    total_lines = sum(project_lines.values())
    set_latex_value('TotalExternalLines', num2word(total_lines))
    set_latex_value('NumExternalProjects', len(sorted_pl))
    big_total_lines = sum(map(lambda x : x[1], sorted_pl[40:]))#TODO factor this 40 out
    set_latex_value('NumBigExternalLinesOfCode', num2word(big_total_lines))
    set_latex_value('BigExternalLinesOfCodePerc', big_total_lines/total_lines, t='perc')
    python_export_file_contents += '\ntotal_external_lines = ' + str(total_lines) + '\n'
    python_export_file_contents += '\nexternal_project_lines = ' + str(sorted_pl) + '\n'
Example #2
0
def hook_preconvert_tag_versions():
    global python_export_file_contents
    #upstreams = ['openssl', 'bouncycastle', 'libogg', 'libxml2', 'openssh']
    upstreams = [
        'aac', 'kernel-headers', 'bouncycastle', 'sonivox', 'tcpdump', 'freetype', 'libnfc-nxp', 'srec', 'elfutils', 'apache-xml', 'openssh', 'stlport', 'linux-tools-perf', 'e2fsprogs', 'apache-harmony', 'eigen', 'jmonkeyengine',
        'protobuf', 'opencv', 'guava', 'libxml2', 'bluetooth', 'sqlite', 'antlr', 'bison', 'libvpx', 'wpa_supplicant_8', 'compiler-rt', 'libcxx', 'skia', 'openssl', 'qemu', 'vixl', 'icu', 'valgrind', 'mesa3d', 'llvm', 'clang', 'chromium', 'chromium_org']
    set_latex_value('NumBigExternalProjects',len(upstreams))
    existing_upstreams = upstreams[
        :]  # May need to remove ones for which we lack data
    data = dict()
    for upstream in upstreams:
        tag_versions(upstream, existing_upstreams, data)
    set_latex_value('NumAnalysedExternalProjects', len(existing_upstreams))
    analysed_lines_of_code = 0
    for upstream in existing_upstreams:
        analysed_lines_of_code += project_lines[upstream]
    set_latex_value('NumAnalysedExternalLinesOfCode', num2word(analysed_lines_of_code))
    set_latex_value('AnalysedExternalLinesOfCodePerc', analysed_lines_of_code/total_lines, t='perc')
    count_versions(data)
    python_export_file_contents += '\nupstreams = ' + str(existing_upstreams) + '\n'
    python_export_file_contents += '\nos_to_project = ' + str(data) + '\n'
Example #3
0
 def test(self):
     cases = [(12.3, "12.3"), (123, "123"), (1230, r"1\,230"), (12300, "12.3 thousand"), (123000, "123 thousand"), (1230000, "1.23 million"), (12300000, "12.3 million"), (123000000, "123 million"), (1230000000, "1.23 billion"), (-1230000000, "-1.23 billion")]
     for test_case, result in cases:
         self.assertEqual(num2word(test_case), result)