3
Tahar is a little program (named after Inspecteur Tahar, a famous algerian movie character) that prints loc (lines of code) statistics of your python code. You can invoke tahar this way :
5
$ python tahar.py /path/to/your/module.py
9
$ python tahar.py /path/to/your/package/
11
It will scan all the python files recursively and print statistics about them :
12
* A hierarchy of you code in a tree-like structure showing modules, functions, classes and methods, each with their total lines of code.
13
* number of modules , with their total loc
14
* number of classes , with their total loc
15
* number of methods , with their loc
16
* number of functions , with their loc
17
* the longest function/method/class/module, along with their loc
18
* the avg loc per function,method,class and module.
20
This is a work in progress (still in alpha) and needs your code reviews.
23
To give you an idea of what it does, this is an example run on the youtube-dl program :
25
chaouche@fictive ~/CODE/PERSO/tahar $ date
26
Thu Dec 27 10:20:02 CET 2012
27
chaouche@fictive ~/CODE/PERSO/tahar $ python tahar.py ~/DOWNLOADS/CODE/youtube-dl-master/youtube_dl/ > youtube_dl_stats.txt
28
chaouche@fictive ~/CODE/PERSO/tahar $ cat youtube_dl_stats.txt
29
added '/home/chaouche/DOWNLOADS/CODE/youtube-dl-master/youtube_dl/' to the path
30
+ Module InfoExtractors => 3082 loc
31
`--+ 0 functions => 0 loc
32
`--+36 classes => 3082 loc
33
| `--+ class CollegeHumorIE => 10 methods, 70 loc
34
| `-- set_downloader : 2
35
| `-- report_manifest : 2
38
| `-- report_extraction : 2
40
| `-- _real_extract : 48
42
| `-- _real_initialize : 2
44
| `--+ class VimeoIE => 10 methods, 88 loc
45
| `-- set_downloader : 2
48
| `-- report_extraction : 2
49
| `-- report_download_webpage : 2
51
| `-- _real_extract : 67
53
| `-- _real_initialize : 2
55
| `--+ class YoutubeSearchIE => 10 methods, 71 loc
56
| `-- set_downloader : 2
60
| `-- report_download_page : 3
61
| `-- _download_n_results : 23
62
| `-- _real_extract : 28
64
| `-- _real_initialize : 2
66
| `--+ class BlipTVIE => 10 methods, 91 loc
67
| `-- set_downloader : 2
68
| `-- report_direct_download : 2
71
| `-- report_extraction : 2
73
| `-- _real_extract : 69
75
| `-- _real_initialize : 2
77
| `--+ class MetacafeIE => 12 methods, 104 loc
78
| `-- set_downloader : 2
79
| `-- report_disclaimer : 2
80
| `-- report_age_confirmation : 2
83
| `-- report_extraction : 2
84
| `-- report_download_webpage : 2
86
| `-- _real_extract : 62
88
| `-- _real_initialize : 19
90
| `--+ class StanfordOpenClassroomIE => 10 methods, 113 loc
91
| `-- set_downloader : 2
94
| `-- report_extraction : 2
95
| `-- report_download_webpage : 2
97
| `-- _real_extract : 91
99
| `-- _real_initialize : 2
101
| `--+ class MixcloudIE => 13 methods, 98 loc
102
| `-- set_downloader : 2
106
| `-- _real_extract : 48
107
| `-- _print_formats : 11
108
| `-- report_extraction : 2
110
| `-- report_download_json : 2
113
| `-- _real_initialize : 2
115
| `--+ class MyVideoIE => 10 methods, 54 loc
116
| `-- set_downloader : 2
119
| `-- report_extraction : 2
120
| `-- report_download_webpage : 2
122
| `-- _real_extract : 33
124
| `-- _real_initialize : 2
126
| `--+ class InfoExtractor => 8 methods, 20 loc
127
| `-- set_downloader : 2
131
| `-- _real_extract : 2
133
| `-- _real_initialize : 2
135
| `--+ class FunnyOrDieIE => 9 methods, 55 loc
136
| `-- set_downloader : 2
139
| `-- report_extraction : 2
141
| `-- _real_extract : 35
143
| `-- _real_initialize : 2
145
| `--+ class DailymotionIE => 10 methods, 83 loc
146
| `-- set_downloader : 2
149
| `-- report_extraction : 2
150
| `-- report_download_webpage : 2
152
| `-- _real_extract : 62
154
| `-- _real_initialize : 2
156
| `--+ class GenericIE => 12 methods, 107 loc
157
| `-- set_downloader : 2
159
| `-- report_following_redirect : 2
161
| `-- report_extraction : 2
162
| `-- _test_redirect : 38
163
| `-- report_download_webpage : 3
165
| `-- _real_extract : 45
167
| `-- _real_initialize : 2
169
| `--+ class PhotobucketIE => 10 methods, 56 loc
170
| `-- set_downloader : 2
173
| `-- report_extraction : 2
174
| `-- report_download_webpage : 2
176
| `-- _real_extract : 35
178
| `-- _real_initialize : 2
180
| `--+ class NBAIE => 9 methods, 54 loc
181
| `-- set_downloader : 2
184
| `-- report_extraction : 2
186
| `-- _real_extract : 34
188
| `-- _real_initialize : 2
190
| `--+ class BlipTVUserIE => 9 methods, 64 loc
191
| `-- set_downloader : 2
194
| `-- report_download_page : 3
196
| `-- _real_extract : 44
198
| `-- _real_initialize : 2
200
| `--+ class EscapistIE => 10 methods, 74 loc
201
| `-- set_downloader : 2
204
| `-- report_config_download : 2
205
| `-- report_extraction : 2
207
| `-- _real_extract : 52
209
| `-- _real_initialize : 2
211
| `--+ class ComedyCentralIE => 13 methods, 150 loc
212
| `-- set_downloader : 2
214
| `-- _print_formats : 4
216
| `-- report_config_download : 2
217
| `-- report_player_url : 2
218
| `-- report_extraction : 2
219
| `-- report_index_download : 2
221
| `-- _real_extract : 120
223
| `-- _real_initialize : 2
225
| `--+ class YoutubePlaylistIE => 9 methods, 67 loc
226
| `-- set_downloader : 2
229
| `-- report_download_page : 2
231
| `-- _real_extract : 48
233
| `-- _real_initialize : 2
235
| `--+ class GooglePlusIE => 13 methods, 93 loc
236
| `-- set_downloader : 2
237
| `-- report_title : 2
238
| `-- report_extract_vid_page : 2
240
| `-- report_uploader : 2
242
| `-- report_date : 2
243
| `-- report_extract_entry : 2
245
| `-- _real_extract : 66
247
| `-- _real_initialize : 2
249
| `--+ class GoogleSearchIE => 10 methods, 73 loc
250
| `-- set_downloader : 2
254
| `-- report_download_page : 3
255
| `-- _download_n_results : 25
256
| `-- _real_extract : 28
258
| `-- _real_initialize : 2
260
| `--+ class YoukuIE => 13 methods, 99 loc
261
| `-- set_downloader : 2
264
| `-- _get_file_ID_mix_string : 10
265
| `-- _real_initialize : 2
266
| `-- report_extraction : 2
267
| `-- report_download_webpage : 2
272
| `-- _real_extract : 55
273
| `-- _get_file_id : 8
274
| `--+ class YoutubeChannelIE => 9 methods, 49 loc
275
| `-- set_downloader : 2
278
| `-- report_download_page : 2
280
| `-- _real_extract : 29
282
| `-- _real_initialize : 2
284
| `--+ class YoutubeUserIE => 9 methods, 56 loc
285
| `-- set_downloader : 2
288
| `-- report_download_page : 3
290
| `-- _real_extract : 36
292
| `-- _real_initialize : 2
294
| `--+ class JustinTVIE => 11 methods, 75 loc
295
| `-- set_downloader : 2
298
| `-- report_extraction : 2
299
| `-- report_download_page : 3
301
| `-- _real_extract : 28
303
| `-- _real_initialize : 2
304
| `-- _parse_page : 24
306
| `--+ class XNXXIE => 10 methods, 60 loc
307
| `-- set_downloader : 2
310
| `-- report_extraction : 2
311
| `-- report_webpage : 2
313
| `-- _real_extract : 38
315
| `-- _real_initialize : 2
317
| `--+ class TweetReelIE => 9 methods, 65 loc
318
| `-- set_downloader : 2
321
| `-- report_extraction : 2
323
| `-- _real_extract : 45
325
| `-- _real_initialize : 2
327
| `--+ class InfoQIE => 10 methods, 62 loc
328
| `-- set_downloader : 2
331
| `-- report_extraction : 2
332
| `-- report_webpage : 2
334
| `-- _real_extract : 40
336
| `-- _real_initialize : 2
338
| `--+ class YoutubeIE => 21 methods, 294 loc
339
| `-- report_login : 2
340
| `-- report_information_extraction : 2
341
| `-- report_video_subtitles_download : 2
342
| `-- report_lang : 2
345
| `-- report_age_confirmation : 2
347
| `-- report_video_webpage_download : 2
348
| `-- _real_initialize : 57
349
| `-- report_video_info_webpage_download : 2
350
| `-- _print_formats : 4
351
| `-- _closed_captions_xml_to_srt : 15
353
| `-- set_downloader : 2
354
| `-- report_rtmp_download : 2
355
| `-- _extract_id : 7
356
| `-- report_unavailable_format : 2
357
| `-- _extract_subtitles : 27
359
| `-- _real_extract : 150
360
| `--+ class YahooIE => 10 methods, 114 loc
361
| `-- set_downloader : 2
364
| `-- report_extraction : 2
365
| `-- report_download_webpage : 2
367
| `-- _real_extract : 93
369
| `-- _real_initialize : 2
371
| `--+ class DepositFilesIE => 10 methods, 56 loc
372
| `-- set_downloader : 2
375
| `-- report_extraction : 2
376
| `-- report_download_webpage : 2
378
| `-- _real_extract : 35
380
| `-- _real_initialize : 2
382
| `--+ class MTVIE => 10 methods, 86 loc
383
| `-- set_downloader : 2
386
| `-- report_extraction : 2
387
| `-- report_webpage : 2
389
| `-- _real_extract : 64
391
| `-- _real_initialize : 2
393
| `--+ class XVideosIE => 10 methods, 63 loc
394
| `-- set_downloader : 2
397
| `-- report_extraction : 2
398
| `-- report_webpage : 2
400
| `-- _real_extract : 41
402
| `-- _real_initialize : 2
404
| `--+ class ArteTvIE => 14 methods, 126 loc
405
| `-- set_downloader : 2
406
| `-- fetch_webpage : 13
408
| `-- extractLiveStream : 25
410
| `-- report_extraction : 2
411
| `-- grep_webpage : 14
412
| `-- extractPlus7Stream : 44
413
| `-- report_download_webpage : 2
415
| `-- _real_extract : 9
417
| `-- _real_initialize : 2
419
| `--+ class SoundcloudIE => 10 methods, 61 loc
420
| `-- set_downloader : 2
423
| `-- report_extraction : 2
425
| `-- _real_extract : 40
427
| `-- _real_initialize : 2
428
| `-- report_resolve : 2
430
| `--+ class FacebookIE => 13 methods, 156 loc
431
| `-- report_login : 2
432
| `-- set_downloader : 2
435
| `-- _real_extract : 78
436
| `-- report_information_extraction : 2
439
| `-- report_video_webpage_download : 2
441
| `-- _real_initialize : 37
442
| `-- _parse_page : 18
444
| `--+ class YahooSearchIE => 10 methods, 75 loc
445
| `-- set_downloader : 2
449
| `-- report_download_page : 3
450
| `-- _download_n_results : 27
451
| `-- _real_extract : 28
453
| `-- _real_initialize : 2
455
+ Module utils => 662 loc
456
`--+ 0 functions => 0 loc
457
`--+8 classes => 662 loc
458
| `--+ class YoutubeDLHandler => 12 methods, 113 loc
459
| `-- set_http_debuglevel : 2
462
| `-- http_request : 10
466
| `-- do_request_ : 24
468
| `-- http_response : 11
469
| `--+ class MaxDownloadsReached => 0 methods, 0 loc
470
| `--+ class AttrParser => 38 methods, 546 loc
472
| `-- _scan_name : 16
473
| `-- handle_startendtag : 3
474
| `-- parse_declaration : 50
476
| `-- _parse_doctype_entity : 33
478
| `-- handle_starttag : 11
481
| `-- set_cdata_mode : 2
482
| `-- parse_comment : 11
483
| `-- get_starttag_text : 2
484
| `-- find_startpos : 1
485
| `-- check_for_whole_start_tag : 23
486
| `-- clear_cdata_mode : 2
487
| `-- _parse_doctype_element : 8
488
| `-- parse_starttag : 43
489
| `-- _parse_doctype_notation : 20
490
| `-- handle_endtag : 6
492
| `-- _parse_doctype_attlist : 49
494
| `-- get_result : 12
495
| `-- parse_marked_section : 18
496
| `-- _parse_doctype_subset : 58
498
| `-- parse_endtag : 14
502
| `--+ class DownloadError => 0 methods, 0 loc
503
| `--+ class UnavailableVideoError => 0 methods, 0 loc
504
| `--+ class PostProcessingError => 0 methods, 0 loc
505
| `--+ class SameFileError => 0 methods, 0 loc
506
| `--+ class ContentTooShortError => 1 methods, 3 loc
508
+ Module FileDownloader => 412 loc
509
`--+ 0 functions => 0 loc
510
`--+1 classes => 412 loc
511
| `--+ class FileDownloader => 31 methods, 412 loc
512
| `-- report_writesubtitles : 2
513
| `-- add_info_extractor : 3
514
| `-- fixed_template : 2
515
| `-- prepare_filename : 15
519
| `-- report_file_already_downloaded : 5
520
| `-- report_retry : 2
522
| `-- _download_with_rtmpdump : 37
523
| `-- _do_download : 110
524
| `-- post_process : 7
525
| `-- process_info : 83
526
| `-- undo_temp_name : 4
527
| `-- report_unable_to_resume : 2
528
| `-- report_writeinfojson : 2
530
| `-- report_destination : 2
531
| `-- to_cons_title : 7
535
| `-- _match_entry : 13
536
| `-- add_post_processor : 3
537
| `-- increment_downloads : 2
538
| `-- report_progress : 7
539
| `-- report_resuming_byte : 2
541
| `-- report_writedescription : 2
542
| `-- report_finish : 5
543
+ Module version => 0 loc
544
`--+ 0 functions => 0 loc
545
`--+0 classes => 0 loc
546
+ Module __main__ => 179 loc
547
`--+ 0 functions => 0 loc
548
`--+1 classes => 179 loc
549
| `--+ class Inspector => 24 methods, 179 loc
550
| `-- get_max_module : 3
551
| `-- print_module_stats : 5
552
| `-- print_avg_stats : 7
553
| `-- print_gl_stats : 5
554
| `-- process_callables : 4
556
| `-- print_modules_stats : 3
557
| `-- print_class_stats : 10
558
| `-- get_max_function : 9
559
| `-- add_functions_loc : 7
560
| `-- get_max_class : 8
561
| `-- print_avg_methods_stats : 5
562
| `-- process_modules : 14
563
| `-- print_avg_classes_stats : 10
564
| `-- init_global_stats : 6
565
| `-- print_avg_functions_stats : 5
566
| `-- print_max_stats : 11
567
| `-- print_avg_modules_stats : 4
568
| `-- init_class_stats : 8
569
| `-- add_methods_loc : 9
570
| `-- print_stats : 5
571
| `-- get_max_method : 11
572
| `-- init_module_stats : 14
573
| `-- print_functions_stats : 9
574
+ Module PostProcessor => 125 loc
575
`--+ 0 functions => 0 loc
576
`--+3 classes => 125 loc
577
| `--+ class FFmpegExtractAudioPP => 5 methods, 117 loc
578
| `-- set_downloader : 2
580
| `-- run_ffmpeg : 15
581
| `-- get_audio_codec : 17
583
| `--+ class AudioConversionError => 1 methods, 2 loc
585
| `--+ class PostProcessor => 3 methods, 6 loc
586
| `-- set_downloader : 2
589
+ Module __init__ => 0 loc
590
`--+ 0 functions => 0 loc
591
`--+0 classes => 0 loc
593
Total : 4460 loc across 7 modules containing 0 functions, 49 classes and 501 methods.
594
avg loc per method : 8.90219560878
595
avg loc per class : 91.0204081633
596
avg loc per module : 637.142857143
597
longest method : InfoExtractors.YoutubeIE._real_extract with 150 loc
598
longest class : utils.AttrParser with 546 loc
599
longest module : InfoExtractors with 3082 loc