Skip to content

Commit

Permalink
Fix is_current for new TeX Live webpage
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Mar 19, 2024
1 parent 0125025 commit 68b4d31
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions install_texlive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,42 @@
from io import BytesIO
import tarfile
from functools import lru_cache
from io import StringIO
from html.parser import HTMLParser

__version__ = '0.3.3'

__version__ = '0.3.4'

log = logging.getLogger(__name__)

URL = 'https://mirror.ctan.org/systems/texlive/tlnet/'
OLDURL = 'https://ftp.tu-chemnitz.de/pub/tug/historic/systems/texlive/{v}/tlnet-final/'


class GetText(HTMLParser):
"""Only extract text of html page"""

def __init__(self):
super().__init__()
self._text = StringIO()

def handle_data(self, d):
self._text.write(d)

@property
def text(self):
return self._text.getvalue()


@lru_cache
def is_current(version):
r = requests.get('https://tug.org/texlive/')
r.raise_for_status()

m = re.search(r'Current release: TeX Live ([0-9]{4})', r.text)
parser = GetText()
parser.feed(r.text)

m = re.search(r'Current release: TeX Live ([0-9]{4})', parser.text)
if not m:
raise ValueError('Could not determine current TeX Live version')

Expand Down

0 comments on commit 68b4d31

Please sign in to comment.