Last active
December 25, 2023 03:45
-
-
Save Delphier/f293af24da4d3e8dc052d4d4ba55f6a3 to your computer and use it in GitHub Desktop.
Download and extract latest Delphi JCL daily: https://github.com/project-jedi/jcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
import subprocess | |
import urllib.request | |
import xml.etree.ElementTree as ET | |
from pathlib import Path | |
DAILY_URL = "https://jcl.sourceforge.net/daily/" | |
DAILY_URL_XML = f"{DAILY_URL}?xml=yes" | |
def download(url): | |
with urllib.request.urlopen(url) as resp: | |
return resp.read() | |
def rmtree(dir): | |
if os.path.isdir(dir): | |
#shutil.rmtree(dir) | |
os.system(f"rmdir /s/q {dir}") | |
### Download and parse manifest xml | |
root = ET.fromstring(download(DAILY_URL_XML)) | |
filename = root[0][0][0].text | |
filesize = root[0][0][1].text | |
filedate = root[0][0][2].text | |
print(f"File: {filename}") | |
print(f"Size: {filesize}") | |
print(f"Date: {filedate}") | |
yes = input("Do you want to download it [Y/N] ? ") | |
if not yes or yes[0].lower() != 'y': | |
exit(0) | |
### Download jcl package | |
print("Downloading...") | |
with open(filename, "wb") as file: | |
file.write(download(f"{DAILY_URL}{filename}")) | |
### Unpack | |
print("Unpacking...") | |
JCL = Path("JCL") | |
tempdir = Path(filename).stem | |
rmtree(JCL) | |
rmtree(tempdir) | |
subprocess.run(["C:/Program Files/7-Zip/7z.exe", "x", filename]) | |
os.rename(tempdir, JCL) | |
### Clone jedi inc files | |
jedi = JCL / "source/include/jedi" | |
subprocess.run(["git", "clone", "https://github.com/project-jedi/jedi.git", jedi]) | |
### Convert JclSysUtils.pas encoding | |
file = JCL / "source/common/JclSysUtils.pas" | |
file.write_text(file.read_text(encoding="iso8859-1"), encoding="utf8") | |
print("Done!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment