live version parsing fixes
parent
435230aa6e
commit
432f4128c9
|
@ -0,0 +1 @@
|
||||||
|
from .scripts import periodical_script
|
|
@ -17,9 +17,13 @@ def live_to_esoui(*, path: Path, esoui_uris: list):
|
||||||
|
|
||||||
esoui_name, esoui_version, esoui_uri = None, None, None
|
esoui_name, esoui_version, esoui_uri = None, None, None
|
||||||
|
|
||||||
for name, version, uri in esoui_uris:
|
for _name, _version, _uri in esoui_uris:
|
||||||
if name in live_name:
|
if _name in live_name:
|
||||||
esoui_name, esoui_version, esoui_uri = name, version, uri
|
esoui_name, esoui_version, esoui_uri = _name, _version, _uri
|
||||||
|
break
|
||||||
|
|
||||||
|
if live_name in _name:
|
||||||
|
esoui_name, esoui_version, esoui_uri = _name, _version, _uri
|
||||||
break
|
break
|
||||||
|
|
||||||
if not esoui_name:
|
if not esoui_name:
|
||||||
|
@ -51,9 +55,20 @@ def live_to_esoui(*, path: Path, esoui_uris: list):
|
||||||
|
|
||||||
|
|
||||||
def esoui_to_live(*, esoui_uris: list, live_path: Path):
|
def esoui_to_live(*, esoui_uris: list, live_path: Path):
|
||||||
for addon_name, version, esoui_dowload_uri in esoui_uris:
|
for addon_name, addon_version, esoui_dowload_uri in esoui_uris:
|
||||||
if addon_name in list(live_path.iterdir()):
|
match = None
|
||||||
logging.info(f"{addon_name} already installed.")
|
|
||||||
|
for each in live_path.iterdir():
|
||||||
|
if addon_name in each.name:
|
||||||
|
match = each
|
||||||
|
break
|
||||||
|
|
||||||
|
if each.name in addon_name:
|
||||||
|
match = each
|
||||||
|
break
|
||||||
|
|
||||||
|
if match:
|
||||||
|
logging.debug(f"{addon_name} already installed.")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
response = requests.get(esoui_dowload_uri)
|
response = requests.get(esoui_dowload_uri)
|
||||||
|
@ -65,9 +80,12 @@ def esoui_to_live(*, esoui_uris: list, live_path: Path):
|
||||||
zip_file = ZipFile(BytesIO(response.content))
|
zip_file = ZipFile(BytesIO(response.content))
|
||||||
zip_file.extractall(temp_path)
|
zip_file.extractall(temp_path)
|
||||||
|
|
||||||
live_dest = live_path.joinpath(each.name)
|
|
||||||
|
|
||||||
for each in temp_path.iterdir():
|
for each in temp_path.iterdir():
|
||||||
|
live_dest = live_path.joinpath(each.name)
|
||||||
|
|
||||||
|
if live_dest.exists():
|
||||||
|
continue
|
||||||
|
|
||||||
copytree(each, live_dest)
|
copytree(each, live_dest)
|
||||||
|
|
||||||
logging.info(f"{addon_name} installed {version} at {live_dest}")
|
logging.info(f"{addon_name} installed {addon_version} at {live_dest}")
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from packaging import version
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
@ -7,8 +8,6 @@ esoui_prefix = re.compile("https://www.esoui.com/downloads/info[0-9]+\-")
|
||||||
esoui_version_html = re.compile('<div\s+id="version">Version:\s+[^<]+')
|
esoui_version_html = re.compile('<div\s+id="version">Version:\s+[^<]+')
|
||||||
esoui_version_split = re.compile('<div\s+id="version">Version:\s+')
|
esoui_version_split = re.compile('<div\s+id="version">Version:\s+')
|
||||||
esoui_download = re.compile('https://cdn.esoui.com/downloads/file[^"]*')
|
esoui_download = re.compile('https://cdn.esoui.com/downloads/file[^"]*')
|
||||||
live_title = re.compile("##\s+Title:\s+.*")
|
|
||||||
live_title_split = re.compile("##\s+Title:\s+")
|
|
||||||
live_version = re.compile("##\s+Version:\s+.*")
|
live_version = re.compile("##\s+Version:\s+.*")
|
||||||
live_version_split = re.compile("##\s+Version:\s+")
|
live_version_split = re.compile("##\s+Version:\s+")
|
||||||
|
|
||||||
|
@ -21,7 +20,8 @@ def esoui(url: str):
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
version_line = esoui_version_html.search(response.text).group(0)
|
version_line = esoui_version_html.search(response.text).group(0)
|
||||||
version = esoui_version_split.split(version_line)[1]
|
_version = esoui_version_split.split(version_line)[1]
|
||||||
|
_version = version.parse(_version)
|
||||||
|
|
||||||
esoui_page_url = url.replace("info", "download").replace(".html", "")
|
esoui_page_url = url.replace("info", "download").replace(".html", "")
|
||||||
|
|
||||||
|
@ -32,24 +32,32 @@ def esoui(url: str):
|
||||||
response = requests.head(esoui_dowload_uri)
|
response = requests.head(esoui_dowload_uri)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
return addon_name, version, esoui_dowload_uri
|
return addon_name, _version, esoui_dowload_uri
|
||||||
|
|
||||||
|
|
||||||
def live(path: Path):
|
def live(path: Path):
|
||||||
for meta in path.glob("*.txt"):
|
meta_file = path.joinpath(f"{path.stem}.txt")
|
||||||
|
|
||||||
try:
|
if not meta_file.is_file():
|
||||||
with meta.open("r") as file_open:
|
for meta_file in path.glob("*.txt"):
|
||||||
meta_data = file_open.read()
|
if not meta_file.stem in path.stem:
|
||||||
except UnicodeDecodeError:
|
continue
|
||||||
with meta.open("r", encoding="latin-1") as file_open:
|
|
||||||
meta_data = file_open.read()
|
|
||||||
|
|
||||||
addon_name = live_title.search(meta_data).group(0)
|
try:
|
||||||
addon_name = live_title_split.split(addon_name)[1]
|
with meta_file.open("r") as file_open:
|
||||||
version = live_version.search(meta_data).group(0)
|
meta_data = file_open.read()
|
||||||
version = live_version_split.split(version)[1]
|
except UnicodeDecodeError:
|
||||||
|
with meta_file.open("r", encoding="latin-1") as file_open:
|
||||||
|
meta_data = file_open.read()
|
||||||
|
|
||||||
return addon_name, version, path
|
addon_name = meta_file.stem
|
||||||
|
result = live_version.search(meta_data)
|
||||||
|
|
||||||
return None, None, None
|
if result:
|
||||||
|
_version = result.group(0)
|
||||||
|
_version = live_version_split.split(_version)[1]
|
||||||
|
_version = version.parse(_version)
|
||||||
|
else:
|
||||||
|
_version = version.parse("0")
|
||||||
|
|
||||||
|
return addon_name, _version, path
|
||||||
|
|
Loading…
Reference in New Issue