mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-05-16 21:50:20 +00:00
Compare commits
2 Commits
9b89c7782c
...
a93e76eaf4
| Author | SHA1 | Date | |
|---|---|---|---|
| a93e76eaf4 | |||
| 3c5bdb2ab2 |
3
.github/workflows/flatpak-build.yml
vendored
3
.github/workflows/flatpak-build.yml
vendored
@@ -25,6 +25,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
|
|
||||||
|
- name: Generate PSL list
|
||||||
|
run: curl -fsSL https://publicsuffix.org/list/public_suffix_list.dat -o src/common/public_suffix_list.dat
|
||||||
|
|
||||||
- name: Build Flatpak
|
- name: Build Flatpak
|
||||||
id: flatpak_builder
|
id: flatpak_builder
|
||||||
uses: flatpak/flatpak-github-actions/flatpak-builder@v6
|
uses: flatpak/flatpak-github-actions/flatpak-builder@v6
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ import sys
|
|||||||
import urllib.request
|
import urllib.request
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
URL = "https://raw.githubusercontent.com/publicsuffix/list/main/public_suffix_list.dat"
|
URLS = (
|
||||||
|
"https://raw.githubusercontent.com/publicsuffix/list/main/public_suffix_list.dat",
|
||||||
|
"https://publicsuffix.org/list/public_suffix_list.dat",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_rules(text: str):
|
def parse_rules(text: str):
|
||||||
@@ -32,19 +35,36 @@ def emit_header(path: str, rules):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) not in (2, 3):
|
||||||
raise SystemExit("usage: gen-public-suffix.py <output>")
|
raise SystemExit("usage: gen-public-suffix.py <output> [source]")
|
||||||
output = Path(sys.argv[1])
|
output = Path(sys.argv[1])
|
||||||
fallback = Path(__file__).with_name("public_suffix_data.h")
|
sources = []
|
||||||
|
if len(sys.argv) == 3:
|
||||||
|
sources.append(Path(sys.argv[2]))
|
||||||
|
sources.extend(
|
||||||
|
[
|
||||||
|
Path(__file__).with_name("public_suffix_list.dat"),
|
||||||
|
Path("/usr/share/publicsuffix/public_suffix_list.dat"),
|
||||||
|
Path("/app/share/publicsuffix/public_suffix_list.dat"),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
data = None
|
||||||
|
for url in URLS:
|
||||||
try:
|
try:
|
||||||
with urllib.request.urlopen(URL, timeout=30) as resp:
|
with urllib.request.urlopen(url, timeout=30) as resp:
|
||||||
data = resp.read().decode("utf-8")
|
data = resp.read().decode("utf-8")
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
if data is None:
|
||||||
|
for source in sources:
|
||||||
|
if source.exists():
|
||||||
|
data = source.read_text(encoding="utf-8")
|
||||||
|
break
|
||||||
|
if data is None:
|
||||||
|
raise SystemExit("unable to load public suffix list")
|
||||||
rules = parse_rules(data)
|
rules = parse_rules(data)
|
||||||
emit_header(str(output), rules)
|
emit_header(str(output), rules)
|
||||||
except Exception:
|
|
||||||
if not fallback.exists():
|
|
||||||
raise
|
|
||||||
output.write_bytes(fallback.read_bytes())
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user