2
0
Fork 0

Compare commits

..

No commits in common. "949c0b9c9b9925b2527ba81b665c2824666b53f6" and "0c0822b9b9560bf1c36edca541e2e70ad703fb94" have entirely different histories.

2 changed files with 5 additions and 29 deletions

View file

@ -76,8 +76,6 @@ FEED_READERS = [
PIPYReader(name = "python3-snakes", package = "snakes",
target = GITLAB_SNAKES_CARGAJI),
################################ Software that I package (Forgejo) ################################
# pdfbooklet GHReleases Averell7/PdfBooklet archpkgs/pdfbooklet
NCAppReader(app = "pdfbooklet", project = "Averell7/PdfBooklet"),
# meshcentral GHReleases Ylianst/MeshCentral archpkgs/meshcentral
GithubReader(name = "meshcentral", project = "Ylianst/MeshCentral",
target = CGJForgejoPoster("archpkgs/meshcentral")),

View file

@ -162,40 +162,18 @@ class FeedReader:
self.name = name
self.url = url
self.target = target
self.version_file = CONFIG_DIR + self.name
self.etag_file = CONFIG_DIR + self.name + ".etag"
self.beta_strings = [ "nightly", "beta", "alpha", "rc" ]
def first_item(self) -> dict[str, Any] | None | int:
def first_item(self) -> dict[str, Any] | None:
'''Get the first item of the feed (newest)'''
if os.path.isfile(self.etag_file):
with open(self.etag_file, encoding="UTF-8") as file:
etag = file.readline()
else: etag = None
feed = feedparser.parse(self.url, etag=etag)
if feed.etag and feed.etag != etag:
with open(self.etag_file, mode='w', encoding="UTF-8") as file:
file.write(feed.etag)
if feed.status == 304:
return 304
feed = feedparser.parse(self.url)
if len(feed.entries) == 0:
return None
for entry in feed.entries:
skip = False
for beta in self.beta_strings:
if beta in self.entry_get_version(entry)[0]:
skip = True
break
if not skip:
return entry
return None
return feed.entries[0]
def read_feed(self) -> bool | None:
'''Read a feed and post an issue if a new item is found'''
entry = self.first_item()
if entry == 304:
return False
if not entry:
return None
version, _id = self.entry_get_version(entry)
@ -214,7 +192,7 @@ class FeedReader:
If the version is not new, or the posting fails, the method stops and returns False.'''
# Match 1: with local file
try:
with open(self.version_file, encoding="utf-8") as file:
with open(CONFIG_DIR + self.name, encoding="utf-8") as file:
match = file.readline().strip("\n") == str(_id)
except FileNotFoundError:
match = False
@ -228,7 +206,7 @@ class FeedReader:
# Save to disk
if not os.path.isdir(CONFIG_DIR):
os.makedirs(CONFIG_DIR)
with open(self.version_file, mode="w", encoding="utf-8") as file:
with open(CONFIG_DIR + self.name, mode="w", encoding="utf-8") as file:
file.write(str(_id))
return True