dirstat.py
Tue Sep 18, 2007 · 285 words

I was preparing a presentation for school about a web project I've recently been working on and thought that it would be kinda cool to give some examples on the file distribution for the build method that I use. To hopefully get a useful comparison between how much “stuff” there is and what the system can do.

I ended up writing a small Python utility (dirstat.py) that does exactly that - give me statistics on any directory with all the different files (based on extension), their count, total filesize, number of lines in all the files of that type and the percentage of code that these files represent of the whole project.

Can't say that it's extremely useful, but it does give some rather interesting information - for example, that with all these Web.2 apps, I'm actually writing more JavaScript than PHP. And even though it seems like I'm writing endless amounts of HTML and CSS, their part is quite small in the bigger picture.

    filipp@flipbook.alajaam.net [Code]  > ./dirstat.py ~/Sites/huolto

     * Gathering information for "/Users/filipp/Sites/huolto"

    Extension       Files   Size    Lines   %
    ---------------------------------------------
    .png            41      172     0       0.00
    .tpl            24      29      1491    0.79
    .php            47      277     8791    4.68
    .gif            3       4       0       0.00
    .map            20      88      4996    2.66
    .afm            1       12      275     0.15
    .css            3       6       391     0.21
    .js             12      251     8303    4.42
    .ttf            1       39      541     0.29
    .z              1       25      84      0.04
    .log            1       5470    152037  80.94
    .txt            6       42      617     0.33
    .html           45      68      3502    1.86
    .xml            4       1       53      0.03
    .pdf            9       574     3770    2.01
    .htm            57      164     2980    1.59

The code is far from robust and/or graceful but it serves a purpose and you're more than welcome to use it and modify it.


back · essays · credits ·