Skip to content

Instantly share code, notes, and snippets.

@J08nY
Last active November 27, 2020 20:19
Show Gist options
  • Save J08nY/af7513469e8316dec600bab3e6896235 to your computer and use it in GitHub Desktop.
Save J08nY/af7513469e8316dec600bab3e6896235 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from bs4 import BeautifulSoup
from matplotlib import pyplot as plt
from datetime import datetime
import click
@click.command()
@click.argument("is_folder_info", type=click.File("r"))
@click.option("-d", "--deadline", type=click.DateTime(), default=None)
@click.option("-s", "--start", type=click.DateTime(), default=None)
def main(is_folder_info, deadline, start):
folder_info = BeautifulSoup(is_folder_info.read(), "xml")
dates = []
for obj in folder_info.find_all("objekt"):
inserted = obj.find("vlozeno")
text = inserted.string
year = int(text[:4])
month = int(text[4:6])
day = int(text[6:8])
hour = int(text[8:10])
minute = int(text[10:12])
second = int(text[12:14])
d = datetime(year, month, day, hour, minute, second)
dates.append(d)
dates.sort()
y = list(range(1, len(dates)+1))
plt.step(dates, y, where="post")
if deadline is not None:
plt.axvline(deadline, color="black", alpha=0.7, linestyle="--", label="Deadline")
if start is not None:
plt.xlim(left=start)
plt.ylabel("Number of submissions")
plt.xlabel("Time")
plt.legend()
plt.show()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment