1
0

Upload files to "/"

This commit is contained in:
Sateallia 2024-06-14 20:53:40 +03:00
parent efaf4e5dea
commit b0a23cd1bd
2 changed files with 63 additions and 0 deletions

57
recurmaid Normal file
View File

@ -0,0 +1,57 @@
#!/usr/bin/python
import sys
import os
from datetime import datetime
from datetime import timedelta
from dateutil.relativedelta import relativedelta
from operator import itemgetter
import csv
file_db = os.path.realpath(__file__) + ".csv"
if not os.path.exists(file_db):
print("Couldn't find '" + file_db + "', exiting.")
sys.exit(0)
data = list(csv.reader(open(file_db))) #NAME,PRICE[USD/EUR/ETC],DATE_START,PERIOD_RECUR[Y/M/D],CODE_COLOR
today = datetime.today().date()
temp = []
for x in data:
name = x[0]
price = "%0.2f" % float(x[1][:-3])
currency = x[1][-3:]
color = x[4]
date_start = datetime.strptime(x[2], "%Y-%m-%d").date()
date_next = date_start
delta = (today - date_start).days
period_recur = int(x[3][:-1])
unit_recur = x[3][-1:]
if unit_recur == "D":
while True:
date_next = date_next + timedelta(days=period_recur)
if date_next >= today: break
elif unit_recur == "M":
while True:
date_next = date_next + relativedelta(months=1)
if date_next >= today: break
elif unit_recur == "Y":
while True:
date_next = date_next + relativedelta(years=1)
if date_next >= today: break
temp.append([str(name), str(price), str(currency), str(color), str((date_next - today).days), str(date_next)])
dates = []
for x in temp:
dates.append(int(x[-2]))
while True:
smallest = min(dates)
res = min(list(enumerate(dates))[0:], key=itemgetter(1))[0]
print(str(temp[res][0]).ljust(16, " ") + " " + str(temp[res][1]).rjust(8, " ") + " " + str(temp[res][2])
+ "\t#" + str(temp[res][3]) + " NEXT: " + str(temp[res][4]).rjust(4, " ") + " days at " + str(temp[res][5]))
temp.pop(res)
dates.pop(res)
if len(temp) == 0:
break

6
recurmaid.csv Normal file
View File

@ -0,0 +1,6 @@
Stream Service 1,17.99EUR,2023-03-21,1M,EE9911
VPS,5USD,2023-01-16,1M,44BB66
Domain,10.72USD,2023-08-24,1Y,FF7777
Cell Phone,10.00EUR,2022-10-13,1M,33CCDD
Stream Service 2,10.00USD,2023-03-22,1M,11BB55
Bus,30.99USD,2023-04-25,31D,55DDFF
1 Stream Service 1 17.99EUR 2023-03-21 1M EE9911
2 VPS 5USD 2023-01-16 1M 44BB66
3 Domain 10.72USD 2023-08-24 1Y FF7777
4 Cell Phone 10.00EUR 2022-10-13 1M 33CCDD
5 Stream Service 2 10.00USD 2023-03-22 1M 11BB55
6 Bus 30.99USD 2023-04-25 31D 55DDFF