Changeset - 62659d3824a0
[Not reviewed]
default
0 1 0
Mads Kiilerich - 6 years ago 2019-08-06 21:26:37
mads@kiilerich.com
celerylib: simplify over engineered repo walk
1 file changed with 4 insertions and 6 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/celerylib/tasks.py
Show inline comments
 
@@ -485,18 +485,16 @@ def __get_codes_stats(repo_name):
 
    from kallithea.config.conf import LANGUAGES_EXTENSIONS_MAP
 
    repo = Repository.get_by_repo_name(repo_name).scm_instance
 

	
 
    tip = repo.get_changeset()
 
    code_stats = {}
 

	
 
    def aggregate(cs):
 
        for f in cs[2]:
 
            ext = f.extension.lower()
 
            if ext in LANGUAGES_EXTENSIONS_MAP.keys() and not f.is_binary:
 
    for _topnode, _dirnodes, filenodes in tip.walk('/'):
 
        for filenode in filenodes:
 
            ext = filenode.extension.lower()
 
            if ext in LANGUAGES_EXTENSIONS_MAP.keys() and not filenode.is_binary:
 
                if ext in code_stats:
 
                    code_stats[ext] += 1
 
                else:
 
                    code_stats[ext] = 1
 

	
 
    map(aggregate, tip.walk('/'))
 

	
 
    return code_stats or {}
0 comments (0 inline, 0 general)