1- #!/usr/bin/env python
2- # -*- coding: utf-8 -*-
1+ #!/usr/bin/env python3
32#
43# Copyright (C) 2013-2020 Sébastien Helleu <[email protected] > 54#
3837 files_type | pie | files by type (extension) | -
3938"""
4039
41- from __future__ import division , print_function
42-
4340import argparse
4441import datetime
4542import os
5148
5249import pygal
5350
54- VERSION = '1.6 .0-dev'
51+ VERSION = '2.0 .0-dev'
5552
5653ISSUES_REGEX_DEFAULT = re .compile (
5754 r'(?:close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)'
@@ -194,12 +191,12 @@ def _chart_authors(self):
194191 (number , name ) = author .strip (' ' ).split ('\t ' , 1 )
195192 count += 1
196193 if self .max_diff <= 0 or count <= self .max_diff :
197- pie_chart .add (name + ' ({0 })' . format ( number ) , int (number ))
194+ pie_chart .add (name + f ' ({ number } )' , int (number ))
198195 else :
199196 count_others += 1
200197 sum_others += int (number )
201198 if count_others :
202- pie_chart .add ('{0 } others ({1 })'. format ( count_others , sum_others ) ,
199+ pie_chart .add (f' { count_others } others ({ sum_others } )' ,
203200 sum_others )
204201 self ._render (pie_chart )
205202 return True
@@ -229,12 +226,12 @@ def _chart_tickets_author(self):
229226 reverse = True ):
230227 count += 1
231228 if self .max_diff <= 0 or count <= self .max_diff :
232- pie_chart .add (name + ' ({0 })' . format ( number ) , number )
229+ pie_chart .add (name + f ' ({ number } )' , number )
233230 else :
234231 count_others += 1
235232 sum_others += int (number )
236233 if count_others :
237- pie_chart .add ('{0 } others ({1 })'. format ( count_others , sum_others ) ,
234+ pie_chart .add (f' { count_others } others ({ sum_others } )' ,
238235 sum_others )
239236 self ._render (pie_chart )
240237 return True
@@ -243,7 +240,7 @@ def _chart_commits_hour_day(self):
243240 """Generate bar chart with commits by hour of day."""
244241 # format of lines in stdout: 2013-03-15 18:27:55 +0100
245242 stdout = self ._git_command_log (['--date=iso' , '--pretty=format:%ad' ])
246- commits = {'{0 :02d}'. format ( hour ) : 0 for hour in range (0 , 24 )}
243+ commits = {f' { hour :02d} ' : 0 for hour in range (0 , 24 )}
247244 for line in stdout :
248245 commits [line .split ()[1 ].split (':' )[0 ]] += 1
249246 self ._generate_bar_chart (commits )
@@ -253,14 +250,14 @@ def _chart_commits_hour_week(self):
253250 """Generate dot chart with commits by hour of week."""
254251 # format of lines in stdout: Fri, 15 Mar 2013 18:27:55 +0100
255252 stdout = self ._git_command_log (['--date=rfc' , '--pretty=format:%ad' ])
256- commits = {day : {'{0 :02d}'. format ( hour ) : 0 for hour in range (0 , 24 )}
253+ commits = {day : {f' { hour :02d} ' : 0 for hour in range (0 , 24 )}
257254 for day in self .weekdays }
258255 for line in stdout :
259256 wday , _ , _ , _ , hour , _ = line .split ()
260257 commits [wday [:- 1 ]][hour .split (':' )[0 ]] += 1
261258 dot_chart = pygal .Dot (style = self .style , js = self .javascript )
262259 dot_chart .title = self .title
263- dot_chart .x_labels = ['{0 :02d}'. format ( hh ) for hh in range (0 , 24 )]
260+ dot_chart .x_labels = [f' { hh :02d} ' for hh in range (0 , 24 )]
264261 for day in self .weekdays :
265262 dot_chart .add (day , commits [day ])
266263 self ._render (dot_chart )
@@ -325,12 +322,12 @@ def _chart_commits_year_month(self):
325322 date = (int (year ) * 100 ) + int (month )
326323 min_date = min (min_date , date )
327324 max_date = max (max_date , date )
328- year_month = '{0 }-{1}' . format ( year , month )
325+ year_month = f' { year } -{ month } '
329326 commits [year_month ] = commits .get (year_month , 0 ) + 1
330327 if min_date != 999999 :
331328 date = min_date
332329 while date < max_date :
333- year_month = '{0:04d}-{1:02d}' . format ( date // 100 , date % 100 )
330+ year_month = f' { date // 100 :04d } - { date % 100 :02d } '
334331 commits [year_month ] = commits .get (year_month , 0 )
335332 if date % 100 == 12 :
336333 # next year, for example: 201312 => 201401 (+89)
@@ -380,13 +377,13 @@ def _chart_files_type(self):
380377 for ext in sorted (extensions , key = extensions .get , reverse = True ):
381378 count += 1
382379 if self .max_diff <= 0 or count <= self .max_diff :
383- pie_chart .add (ext + ' ({0})' . format ( extensions [ext ]) ,
380+ pie_chart .add (ext + f ' ({ extensions [ext ]} )' ,
384381 extensions [ext ])
385382 else :
386383 count_others += 1
387384 sum_others += extensions [ext ]
388385 if count_others :
389- pie_chart .add ('{0 } others ({1 })'. format ( count_others , sum_others ) ,
386+ pie_chart .add (f' { count_others } others ({ sum_others } )' ,
390387 sum_others )
391388 self ._render (pie_chart )
392389 return True
@@ -457,11 +454,11 @@ def main():
457454 '-j' , '--js' ,
458455 default = ',' .join (pygal_config .js ),
459456 help = 'comma-separated list of javascript files/links used in SVG' )
457+ charts = ', ' .join (sorted (GitChart .charts ))
460458 parser .add_argument (
461459 'chart' ,
462460 metavar = 'chart' , choices = sorted (GitChart .charts ),
463- help = '{0}: {1}' .format ('name of chart, one of' ,
464- ', ' .join (sorted (GitChart .charts ))))
461+ help = f'name of chart, one of: { charts } ' )
465462 parser .add_argument (
466463 'output' ,
467464 help = ('output file (svg or png), special value "-" displays SVG '
0 commit comments