diff --git a/project.py b/project.py index 90664ad..e3da361 100644 --- a/project.py +++ b/project.py @@ -3,6 +3,7 @@ Contains abstract class for a mirrored project """ from abc import ABC +import re import requests @@ -17,4 +18,18 @@ class Project(ABC): """Check if project packages are up-to-date""" csc_url = CSC_MIRROR + data[project]["csc"] + data[project]["file"] upstream_url = data[project]["upstream"] + data[project]["file"] - return requests.get(csc_url).text == requests.get(upstream_url).text + CSC = requests.get(csc_url).text + upstream = requests.get(upstream_url).text + if upstream == CSC: + return True + + # Parse number differences + bad_re = '[a-zA-Z \-\n]+' + if re.search(bad_re, CSC): + # print(re.search(bad_re, CSC).group().strip()) + CSC = re.sub(bad_re, '', CSC) + upstream = re.sub(bad_re, '', upstream) + try: + return int(upstream) - int(CSC) < data[project]["out_of_sync_interval"] + except ValueError: + return False