Compare commits
No commits in common. "949c0b9c9b9925b2527ba81b665c2824666b53f6" and "0c0822b9b9560bf1c36edca541e2e70ad703fb94" have entirely different histories.
949c0b9c9b
...
0c0822b9b9
2 changed files with 5 additions and 29 deletions
|
@ -76,8 +76,6 @@ FEED_READERS = [
|
||||||
PIPYReader(name = "python3-snakes", package = "snakes",
|
PIPYReader(name = "python3-snakes", package = "snakes",
|
||||||
target = GITLAB_SNAKES_CARGAJI),
|
target = GITLAB_SNAKES_CARGAJI),
|
||||||
################################ Software that I package (Forgejo) ################################
|
################################ Software that I package (Forgejo) ################################
|
||||||
# pdfbooklet GHReleases Averell7/PdfBooklet archpkgs/pdfbooklet
|
|
||||||
NCAppReader(app = "pdfbooklet", project = "Averell7/PdfBooklet"),
|
|
||||||
# meshcentral GHReleases Ylianst/MeshCentral archpkgs/meshcentral
|
# meshcentral GHReleases Ylianst/MeshCentral archpkgs/meshcentral
|
||||||
GithubReader(name = "meshcentral", project = "Ylianst/MeshCentral",
|
GithubReader(name = "meshcentral", project = "Ylianst/MeshCentral",
|
||||||
target = CGJForgejoPoster("archpkgs/meshcentral")),
|
target = CGJForgejoPoster("archpkgs/meshcentral")),
|
||||||
|
|
|
@ -162,40 +162,18 @@ class FeedReader:
|
||||||
self.name = name
|
self.name = name
|
||||||
self.url = url
|
self.url = url
|
||||||
self.target = target
|
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)'''
|
'''Get the first item of the feed (newest)'''
|
||||||
if os.path.isfile(self.etag_file):
|
feed = feedparser.parse(self.url)
|
||||||
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
|
|
||||||
if len(feed.entries) == 0:
|
if len(feed.entries) == 0:
|
||||||
return None
|
return None
|
||||||
for entry in feed.entries:
|
return feed.entries[0]
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
def read_feed(self) -> bool | None:
|
def read_feed(self) -> bool | None:
|
||||||
'''Read a feed and post an issue if a new item is found'''
|
'''Read a feed and post an issue if a new item is found'''
|
||||||
entry = self.first_item()
|
entry = self.first_item()
|
||||||
if entry == 304:
|
|
||||||
return False
|
|
||||||
if not entry:
|
if not entry:
|
||||||
return None
|
return None
|
||||||
version, _id = self.entry_get_version(entry)
|
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.'''
|
If the version is not new, or the posting fails, the method stops and returns False.'''
|
||||||
# Match 1: with local file
|
# Match 1: with local file
|
||||||
try:
|
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)
|
match = file.readline().strip("\n") == str(_id)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
match = False
|
match = False
|
||||||
|
@ -228,7 +206,7 @@ class FeedReader:
|
||||||
# Save to disk
|
# Save to disk
|
||||||
if not os.path.isdir(CONFIG_DIR):
|
if not os.path.isdir(CONFIG_DIR):
|
||||||
os.makedirs(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))
|
file.write(str(_id))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue