File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838
3939start_time = time .time ()
4040
41+ time_separator = "" .join (["-" ] * int (window_width ))
42+
4143def show_time ():
4244 global start_time
43- if args .show_time :
44- print ("%s seconds" % round (time .time () - start_time , 3 ))
45- start_time = time .time ()
46- print ("-------------------------------------------------------" )
47- print ()
45+ delta_time = str (round (time .time () - start_time , 3 ))
46+ print (BOLD + BLUE + (delta_time + " seconds " ).rjust (int (window_width )) + RESET )
47+ reset_time ()
4848
49+ def reset_time ():
50+ global start_time
51+ start_time = time .time ()
52+
53+ def finalize_category (category_is_visible ):
54+ if category_is_visible :
55+ if args .show_time :
56+ show_time ()
57+ print (BOLD + BLUE + time_separator + RESET )
58+ print ()
59+ else :
60+ print ()
61+ else :
62+ reset_time ()
4963
5064try :
5165 if not args .hide_tasks :
52- gitviper .list_tasks ()
53-
54- show_time ()
66+ finalize_category (gitviper .list_tasks ())
5567
5668 # git
5769 gitconnector .connect ()
5870
5971 if connection .is_git_repo :
6072 if not args .hide_branches :
61- gitviper .list_branches ()
62- show_time ()
73+ finalize_category (gitviper .list_branches ())
6374 if not args .hide_logs :
64- gitviper .list_logs (args .log_number )
65- show_time ()
75+ finalize_category (gitviper .list_logs (args .log_number ))
6676 if not args .hide_stash :
67- gitviper .list_stash ()
68- show_time ()
77+ finalize_category (gitviper .list_stash ())
6978 if not args .hide_status :
70- gitviper .list_status ()
71- show_time ()
79+ finalize_category ( gitviper .list_status () )
80+
7281except KeyboardInterrupt :
7382 print ()
7483except BrokenPipeError : # occurs sometimes after quitting less when big git-logs are displayed
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ def list_branches():
2121 else :
2222 _list_all_branches ()
2323
24- print ()
24+ return True
25+ return False
2526
2627def should_show_branches ():
2728 remotes = connection .repo .remotes
Original file line number Diff line number Diff line change 1414def list_logs (num ):
1515 if show_logs ():
1616 log (num )
17- print ()
17+
18+ return True
19+
20+ return False
1821
1922def show_logs ():
2023 try :
Original file line number Diff line number Diff line change 1010def list_stash ():
1111 if stash_exists ():
1212 print_stash ()
13- print ()
13+
14+ return True
15+
16+ return False
1417
1518def stash_exists ():
1619 return len (connection .repo .git .stash ("list" )) > 0
Original file line number Diff line number Diff line change 1111def list_status ():
1212 if connection .repo .is_dirty () or len (connection .repo .untracked_files ) > 0 :
1313 _list_status ()
14- print ()
14+
15+ return True
16+
17+ return False
1518
1619def _list_status ():
1720 gui .print_header ("Status" , BG_GREEN )
Original file line number Diff line number Diff line change @@ -45,8 +45,11 @@ def list_tasks():
4545 print (line1 )
4646 if len (line2 .strip ()) > 0 :
4747 print (line2 )
48+
4849 if len (line1 .strip ()) > 0 or len (line2 .strip ()) > 0 :
49- print ()
50+ return True
51+
52+ return False
5053
5154def count_tasks (filename , counter_dict ):
5255 with open (filename , 'r' ) as myfile :
You can’t perform that action at this time.
0 commit comments