self.versions = []
self.emerge_time = "infinity"
+ self.plotData = []
+
def add_version(self, version, emerge_time, emerge_date):
"""Add version to the class version list"""
if len(give_time(p[1], True)) > time_length:
time_length = len(give_time(p[1], True))
+ # Create the data for plotting in the format (emerge time, emerge date)
+ self.plotData.append((p[1], p[2]))
+
dots = (version_length + time_length + len(self.name)
+ len(give_date(self.versions[0][2])) + 14)
"\nIn total spent:\t" + give_time(total) +
"emerging " + GREEN(self.name))
+ def plotToScreen(self):
+ dates = []
+ times = []
+
+ for i in self.plotData:
+ dates.append(datetime.date.fromtimestamp(i[1]))
+ times.append(i[0])
+
+ fig = plt.figure()
+
+ plt.plot_date(dates, times, xdate=True, ydate=False)
+
+ plt.ylabel("Emerge time [s]")
+ fig.autofmt_xdate()
+ plt.show()
+
def give_time(time, nocolor=False):
pack.print_versions()
pack.print_min_max_ave()
+ if matplotWorking:
+ pack.plotToScreen()
+
else:
print("Package " + GREEN(pack.name)
+ " has never been emerged.")
\t-h, --help \t Show this helpscreen
\t-q, --quiet \t Be less verbose
\t--no-color \t Use colorless output
+\--plot \t Plot emerge times into a 2D scatter plot
\t--simulate \t Do a simulation run"""
print usage
mode = "package"
input_packages = None
simulation = False
+ matplotWorking = False
for arg in sys.argv[1:]:
sys.argv.pop(sys.argv.index(arg))
+ if arg == "--plot":
+ try:
+ import matplotlib.pyplot as plt
+ matplotWorking = True
+ except Exception:
+ print "Cannot initialize matplotlib!"
+ print "Check that you have properly installet matplotlib."
+ matplotWorking = False
+
if arg == "--no-color":
green_start = ""
color_stop = ""