From 11c3103e3ba19b641a95744db4a565425fa83550 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Sun, 31 May 2026 00:51:47 +0200 Subject: [PATCH] FeedReader: now able to post multiple issues on a new version --- config.py | 29 ++++++++++++++--------------- issue_generator.py | 28 ++++++++++++++++------------ 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/config.py b/config.py index b02de05..e1cd8c1 100644 --- a/config.py +++ b/config.py @@ -18,15 +18,16 @@ import _secrets class UDSClientReader(FeedReader): '''Custom feed reader for UDSClient, whose version number appears in a .js file.''' - def __init__(self, target: IssuePoster): + def __init__(self, targets: IssuePoster): '''Creates a new UDSClient Reader.''' - super().__init__("udsclient", "https://polilabs.upv.es/uds/utility/uds.js", target) + super().__init__("udsclient", "https://polilabs.upv.es/uds/utility/uds.js", targets) def read_feed(self) -> bool | None: '''Checks for a new version of udsclient, by checking a .js file.''' get = requests.get(self.url, timeout = TIMEOUT) - if not self.target.check_req(get, self.name): - return None + for target in self.targets: + if not target.check_req(get, self.name): + return None match = re.search(r"[/a-zA-Z_-]+udsclient\d+-(\d+\.\d+\.\d+)\.tar\.gz", get.text) if not match: return None @@ -55,7 +56,7 @@ class NCAppReader(GithubReader): '''All GitHub releases readers that must alert Forgejo's `archpkgs`.''' def __init__(self, app, project): super().__init__(name = app, project = project, - target = CGJForgejoPoster("archpkgs/" + app)) + targets = CGJForgejoPoster("archpkgs/" + app)) # Issue Posters @@ -70,20 +71,18 @@ FEED_READERS = [ # Name FeedType Project TargetProject ################################ Software used in MIST (Gitlab) ################################### # LanguageTool GHTags languagetool-org/languagetool 36 (sysadmin/boira) - GithubTagReader(name = "LanguageTool", project = "languagetool-org/languagetool", - target = GITLAB_BOIRA_CARGAJI), + GithubTagReader(name = "LanguageTool", project = "languagetool-org/languagetool", + targets = GITLAB_BOIRA_CARGAJI), # meshcentral GHReleases Ylianst/MeshCentral 36 (sysadmin/boira) - GithubReader(name = "meshcentral", project = "Ylianst/MeshCentral", - target = GITLAB_BOIRA_CARGAJI), +# meshcentral GHReleases Ylianst/MeshCentral archpkgs/meshcentral + GithubReader(name = "meshcentral", project = "Ylianst/MeshCentral", + targets = [GITLAB_BOIRA_CARGAJI, CGJForgejoPoster("archpkgs/meshcentral")]), # python3-snakes PIPY snakes 37 (packages/python3-snakes) - PIPYReader(name = "python3-snakes", package = "snakes", - target = GITLAB_SNAKES_CARGAJI), + PIPYReader(name = "python3-snakes", package = "snakes", + targets = 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")), # nc-cospend GHReleases eneiluj/cospend-nc archpkgs/nextcloud-app-cospend NCAppReader(app = "nextcloud-app-cospend", project = "eneiluj/cospend-nc"), # nc-f_autotagging GHReleases @@ -103,7 +102,7 @@ FEED_READERS = [ # nc-socialsharing GHReleases nextcloud/socialsharing archpkgs/nextcloud-app-socialsharing NCAppReader(app = "nextcloud-app-socialsharing", project = "nextcloud/socialsharing"), # udsclient Custom --- archpkgs/udsclient - UDSClientReader(target = CGJForgejoPoster(project="archpkgs/udsclient")), + UDSClientReader(targets = CGJForgejoPoster(project="archpkgs/udsclient")), # vigil GHReleases valeriansaliou/vigil archpkgs/vigil NCAppReader(app = "vigil", project = "valeriansaliou/vigil"), # vigil-local GHReleases valeriansaliou/vigil-local archpkgs/vigil-local diff --git a/issue_generator.py b/issue_generator.py index 0a82720..6982bd6 100644 --- a/issue_generator.py +++ b/issue_generator.py @@ -157,11 +157,11 @@ class ForgejoPoster(IssuePoster): class FeedReader: '''Class to read an RSS/Atom feed and post an issue if a new version is found.''' - def __init__(self, name: str, url: str, target: IssuePoster): + def __init__(self, name: str, url: str, targets: list[IssuePoster]): '''Create a new feed reader''' self.name = name self.url = url - self.target = target + self.targets = targets if type(targets) == list else [targets] self.version_file = CONFIG_DIR + self.name self.etag_file = CONFIG_DIR + self.name + ".etag" self.beta_strings = [ "nightly", "beta", "alpha", "rc", "pr" ] @@ -223,10 +223,14 @@ class FeedReader: if match: return False # Match 2: with repository issues - if not self.target.issue_exists(self.name, version): - # Post the issue - if not self.target.post_issue(self.name, version, link): - return False + issues_posted = True + for target in self.targets: + if not target.issue_exists(self.name, version): + # Post the issue + if not target.post_issue(self.name, version, link): + issues_posted = False + if not issues_posted: + return False # Save to disk if not os.path.isdir(CONFIG_DIR): os.makedirs(CONFIG_DIR) @@ -238,9 +242,9 @@ class FeedReader: class PIPYReader(FeedReader): '''Reader specialized in the PIPY repository.''' - def __init__(self, name: str, package: str, target: IssuePoster): + def __init__(self, name: str, package: str, targets: IssuePoster): '''Create a new PIPY reader for the given package.''' - super().__init__(name, f"https://pypi.org/rss/project/{package}/releases.xml", target) + super().__init__(name, f"https://pypi.org/rss/project/{package}/releases.xml", targets) def entry_get_version(self, entry: dict[str, Any]) -> tuple[str, str]: return entry.title, entry.title @@ -252,9 +256,9 @@ class PIPYReader(FeedReader): class GithubTagReader(FeedReader): '''Reader specialized in GitHub Tags Atom feed.''' - def __init__(self, name: str, project: str, target: IssuePoster): + def __init__(self, name: str, project: str, targets: IssuePoster): '''Create a new GitHub Tags reader for the given project.''' - super().__init__(name, f"https://github.com/{project}/tags.atom", target) + super().__init__(name, f"https://github.com/{project}/tags.atom", targets) def entry_get_version(self, entry: dict[str, Any]) -> tuple[str, str]: return entry.title, str(entry.id) @@ -266,8 +270,8 @@ class GithubTagReader(FeedReader): class GithubReader(GithubTagReader): '''Reader specialized in GitHub releases' Atom feed.''' - def __init__(self, name: str, project: str, target: IssuePoster): - super().__init__(name, project, target) + def __init__(self, name: str, project: str, targets: IssuePoster): + super().__init__(name, project, targets) self.url = f"https://github.com/{project}/releases.atom"