@@ -70,6 +70,13 @@ def parse_args():
70
70
"\" month\" , \" year\" , \" no\" , \" raw\" and pandas offset aliases ("
71
71
"http://pandas.pydata.org/pandas-docs/stable/timeseries.html"
72
72
"#offset-aliases)." )
73
+ dateutil_url = "https://dateutil.readthedocs.io/en/stable/parser.html#dateutil.parser.parse"
74
+ parser .add_argument ("--start-date" ,
75
+ help = "Start date of time-based plots. Any format is accepted which is "
76
+ "supported by %s" % dateutil_url )
77
+ parser .add_argument ("--end-date" ,
78
+ help = "End date of time-based plots. Any format is accepted which is "
79
+ "supported by %s" % dateutil_url )
73
80
parser .add_argument ("--disable-projector" , action = "store_true" ,
74
81
help = "Do not run Tensorflow Projector on couples." )
75
82
parser .add_argument ("--max-people" , default = 20 , type = int ,
@@ -385,7 +392,15 @@ def read_input(args):
385
392
sys .stdout .flush ()
386
393
if args .input != "-" :
387
394
if args .input_format == "auto" :
388
- args .input_format = args .input .rsplit ("." , 1 )[1 ]
395
+ try :
396
+ args .input_format = args .input .rsplit ("." , 1 )[1 ]
397
+ except IndexError :
398
+ try :
399
+ with open (args .input ) as f :
400
+ f .read (1 << 16 )
401
+ args .input_format = "yaml"
402
+ except UnicodeDecodeError :
403
+ args .input_format = "pb"
389
404
elif args .input_format == "auto" :
390
405
args .input_format = "yaml"
391
406
reader = READERS [args .input_format ]()
@@ -745,6 +760,13 @@ def default_json(x):
745
760
return x
746
761
747
762
763
+ def parse_date (text , default ):
764
+ if not text :
765
+ return default
766
+ from dateutil .parser import parse
767
+ return parse (text )
768
+
769
+
748
770
def plot_burndown (args , target , name , matrix , date_range_sampling , labels , granularity ,
749
771
sampling , resample ):
750
772
if args .output and args .output .endswith (".json" ):
@@ -776,7 +798,8 @@ def plot_burndown(args, target, name, matrix, date_range_sampling, labels, granu
776
798
pyplot .xlabel ("Time" )
777
799
apply_plot_style (pyplot .gcf (), pyplot .gca (), legend , args .background ,
778
800
args .font_size , args .size )
779
- pyplot .xlim (date_range_sampling [0 ], date_range_sampling [- 1 ])
801
+ pyplot .xlim (parse_date (args .start_date , date_range_sampling [0 ]),
802
+ parse_date (args .end_date , date_range_sampling [- 1 ]))
780
803
locator = pyplot .gca ().xaxis .get_major_locator ()
781
804
# set the optimal xticks locator
782
805
if "M" not in resample :
@@ -898,7 +921,8 @@ def plot_ownership(args, repo, names, people, date_range, last):
898
921
matplotlib , pyplot = import_pyplot (args .backend , args .style )
899
922
900
923
pyplot .stackplot (date_range , people , labels = names )
901
- pyplot .xlim (date_range [0 ], last )
924
+ pyplot .xlim (parse_date (args .start_date , date_range [0 ]), parse_date (args .end_date , last ))
925
+
902
926
if args .relative :
903
927
for i in range (people .shape [1 ]):
904
928
people [:, i ] /= people [:, i ].sum ()
@@ -1165,7 +1189,7 @@ def show_sentiment_stats(args, name, resample, start_date, data):
1165
1189
pyplot .xlabel ("Time" )
1166
1190
apply_plot_style (pyplot .gcf (), pyplot .gca (), legend , args .background ,
1167
1191
args .font_size , args .size )
1168
- pyplot .xlim (xdates [0 ], xdates [- 1 ])
1192
+ pyplot .xlim (parse_date ( args . start_date , xdates [0 ]), parse_date ( args . end_date , xdates [- 1 ]) )
1169
1193
locator = pyplot .gca ().xaxis .get_major_locator ()
1170
1194
# set the optimal xticks locator
1171
1195
if "M" not in resample :
0 commit comments