@@ -84,33 +84,34 @@ def timeline(
84
84
transient = True ,
85
85
console = console ,
86
86
) as progress :
87
- module = name # module is the name of the integration or the dependency
88
- if (
89
- initial_commit
90
- and final_commit
91
- and len (initial_commit ) < MINIMUM_LENGTH_COMMIT
92
- and len (final_commit ) < MINIMUM_LENGTH_COMMIT
93
- ):
94
- raise click .BadParameter (f"Commit hashes must be at least { MINIMUM_LENGTH_COMMIT } characters long" )
95
- elif initial_commit and len (initial_commit ) < MINIMUM_LENGTH_COMMIT :
96
- raise click .BadParameter (
97
- f"Initial commit hash must be at least { MINIMUM_LENGTH_COMMIT } characters long." , param_hint = "initial"
98
- )
99
- elif final_commit and len (final_commit ) < MINIMUM_LENGTH_COMMIT :
100
- raise click .BadParameter (
101
- f"Final commit hash must be at least { MINIMUM_LENGTH_COMMIT } characters long." , param_hint = "final"
102
- )
103
- elif final_commit and initial_commit and final_commit == initial_commit :
104
- raise click .BadParameter ("Commit hashes must be different" )
105
- if format :
106
- for fmt in format :
107
- if fmt not in ["png" , "csv" , "markdown" , "json" ]:
108
- raise ValueError (f"Invalid format: { fmt } . Only png, csv, markdown, and json are supported." )
109
- task = progress .add_task ("[cyan]Calculating timeline..." , total = None )
110
- url = app .repo .path
111
-
112
- with GitRepo (url ) as gitRepo :
113
- try :
87
+ try :
88
+ module = name # module is the name of the integration or the dependency
89
+ if (
90
+ initial_commit
91
+ and final_commit
92
+ and len (initial_commit ) < MINIMUM_LENGTH_COMMIT
93
+ and len (final_commit ) < MINIMUM_LENGTH_COMMIT
94
+ ):
95
+ raise click .BadParameter (f"Commit hashes must be at least { MINIMUM_LENGTH_COMMIT } characters long" )
96
+ elif initial_commit and len (initial_commit ) < MINIMUM_LENGTH_COMMIT :
97
+ raise click .BadParameter (
98
+ f"Initial commit hash must be at least { MINIMUM_LENGTH_COMMIT } characters long." ,
99
+ param_hint = "initial" ,
100
+ )
101
+ elif final_commit and len (final_commit ) < MINIMUM_LENGTH_COMMIT :
102
+ raise click .BadParameter (
103
+ f"Final commit hash must be at least { MINIMUM_LENGTH_COMMIT } characters long." , param_hint = "final"
104
+ )
105
+ elif final_commit and initial_commit and final_commit == initial_commit :
106
+ raise click .BadParameter ("Commit hashes must be different" )
107
+ if format :
108
+ for fmt in format :
109
+ if fmt not in ["png" , "csv" , "markdown" , "json" ]:
110
+ raise ValueError (f"Invalid format: { fmt } . Only png, csv, markdown, and json are supported." )
111
+ task = progress .add_task ("[cyan]Calculating timeline..." , total = None )
112
+ url = app .repo .path
113
+
114
+ with GitRepo (url ) as gitRepo :
114
115
if final_commit and type == "dependency" :
115
116
date_str , _ , _ = gitRepo .get_commit_metadata (final_commit )
116
117
date = datetime .strptime (date_str , "%b %d %Y" ).date ()
@@ -232,9 +233,9 @@ def timeline(
232
233
if format :
233
234
export_format (app , format , modules , None , module , compressed )
234
235
235
- except Exception as e :
236
- progress .stop ()
237
- app .abort (str (e ))
236
+ except Exception as e :
237
+ progress .stop ()
238
+ app .abort (str (e ))
238
239
239
240
240
241
@overload
@@ -281,10 +282,14 @@ def timeline_mode(
281
282
if not params ["format" ] or params ["format" ] == ["png" ]: # if no format is provided for the data print the table
282
283
print_table (params ["app" ], "Status" , formatted_modules )
283
284
284
- treemap_path = f"treemap_{ params ['platform' ]} .png" if params ["format" ] and "png" in params ["format" ] else None
285
+ timeline_path = (
286
+ f"timeline_{ params ['module' ]} _{ params ['platform' ]} .png"
287
+ if params ["platform" ] and params ["format" ] and "png" in params ["format" ]
288
+ else f"timeline_{ params ['module' ]} .png" if params ["format" ] and "png" in params ["format" ] else None
289
+ )
285
290
286
- if params ["show_gui" ] or treemap_path :
287
- plot_linegraph (formatted_modules , params ["module" ], params ["platform" ], params ["show_gui" ], treemap_path )
291
+ if params ["show_gui" ] or timeline_path :
292
+ plot_linegraph (formatted_modules , params ["module" ], params ["platform" ], params ["show_gui" ], timeline_path )
288
293
289
294
return formatted_modules
290
295
@@ -627,44 +632,14 @@ def format_modules(
627
632
"""
628
633
Formats the modules list, adding platform and Python version information if needed.
629
634
630
- If the modules list is empty, returns a default empty entry (with or without platform information).
631
-
632
635
Args:
633
636
modules: List of modules to format.
634
637
platform: Platform string to add to each entry if needed.
635
- version: Python version string to add to each entry if needed.
636
- i: Index of the current platform, version) combination being processed.
637
- If None, it means the data is being processed for only one platform.
638
638
639
639
Returns:
640
640
A list of formatted entries.
641
641
"""
642
- if modules == [] and platform :
643
- empty_module_platform : CommitEntryPlatformWithDelta = {
644
- "Size_Bytes" : 0 ,
645
- "Version" : "" ,
646
- "Date" : datetime .min .date (),
647
- "Author" : "" ,
648
- "Commit_Message" : "" ,
649
- "Commit_SHA" : "" ,
650
- "Delta_Bytes" : 0 ,
651
- "Delta" : " " ,
652
- "Platform" : "" ,
653
- }
654
- return [empty_module_platform ]
655
- elif modules == []:
656
- empty_module : CommitEntryWithDelta = {
657
- "Size_Bytes" : 0 ,
658
- "Version" : "" ,
659
- "Date" : datetime .min .date (),
660
- "Author" : "" ,
661
- "Commit_Message" : "" ,
662
- "Commit_SHA" : "" ,
663
- "Delta_Bytes" : 0 ,
664
- "Delta" : " " ,
665
- }
666
- return [empty_module ]
667
- elif platform :
642
+ if platform :
668
643
new_modules : list [CommitEntryPlatformWithDelta ] = [{** entry , "Platform" : platform } for entry in modules ]
669
644
return new_modules
670
645
else :
@@ -829,7 +804,7 @@ def plot_linegraph(
829
804
show: If True, displays the plot interactively.
830
805
path: If provided, saves the plot to this file path.
831
806
"""
832
- if not any ( str ( value ). strip () not in ( "" , "0" , "0001-01-01" ) for value in modules [ 0 ]. values ()): # table is empty
807
+ if modules == []:
833
808
return
834
809
835
810
dates = [entry ["Date" ] for entry in modules ]
0 commit comments