예제 #1
0
def get_top_words(dirs, top_size=10, format_data='list', lang_category='verb'):
    if not type(dirs) == list:
        project_dirs = [dirs]
    else:
        project_dirs = dirs
    words = get_ungrouped_list_words(project_dirs, lang_category)
    data = collections.Counter(make_list_flat(words)).most_common(top_size)
    if format_data == 'json':
        data = convert_list_of_tuples_to_json_dict(data)
    return data
예제 #2
0
def main():
    if DEBUG:
        colored_print('Start script in debug mode', mode='warning')

    args = parse_args()
    dirs = args.dirs

    if args.extension != 'py':
        text = f'Is mode in develop. Analysis files with extension {args.extension} is not yet.'
        colored_print(text, mode='warning')
        return

    if args.repo:
        tmp_dir = tempfile.mkdtemp()
        clone_to_dir(args.repo, tmp_dir)
        dirs = [tmp_dir]

    words = get_ungrouped_list_words(dirs, args.lang_category, args.code_element, args.extension)
    if args.output == 'file':
        create_report_file(
            make_list_flat(words),
            args.top_size,
            args.report_path,
            args.lang_category,
            args.code_element,
            args.format_file
        )
    else:
        print_top_words_in_console(
            make_list_flat(words),
            args.top_size,
            args.lang_category,
            args.code_element
        )

    if args.repo:
        delete_created_repo_dir(dirs[0])
예제 #3
0
def test_get_top_verbs_send_list_dir(fixtures_path):
    list_dirs = [fixtures_path]
    verbs = get_top_words(list_dirs)
    assert 'get' in make_list_flat(verbs)
    assert 'say' in make_list_flat(verbs)
    assert len(verbs) == 2
예제 #4
0
def test_get_top_verbs(fixtures_path):
    verbs = get_top_words(fixtures_path)
    assert 'get' in make_list_flat(verbs)
    assert 'say' in make_list_flat(verbs)
    assert len(verbs) == 2
예제 #5
0
def test_make_list_flat():
    assert make_list_flat([(1, 2)]) == [1, 2]
    assert make_list_flat([[1, 2, 3]]) == [1, 2, 3]
    assert make_list_flat([(1, 2), (3, 4)]) == [1, 2, 3, 4]
예제 #6
0
파일: syntax.py 프로젝트: mitrofun/topverbs
def get_nouns(function_name_list):
    nouns = [get_nouns_from_function_name(function_name) for function_name in function_name_list]
    return make_list_flat(nouns)
예제 #7
0
파일: syntax.py 프로젝트: mitrofun/topverbs
def get_verbs(function_name_list):
    verbs = [get_verbs_from_function_name(function_name) for function_name in function_name_list]
    return make_list_flat(verbs)
예제 #8
0
파일: syntax.py 프로젝트: mitrofun/topverbs
def get_all_variables_names(trees):
    name_lists = [get_variables_names_from_tree(tree) for tree in trees]
    return make_list_flat(name_lists)
예제 #9
0
파일: syntax.py 프로젝트: mitrofun/topverbs
def get_all_function_names(trees):
    name_lists = [get_functions_from_tree(tree) for tree in trees]
    return make_list_flat(name_lists)