2021-12-14 22:21:42 +00:00
from argparse import ArgumentParser
2021-12-15 23:06:20 +00:00
from pathlib import Path
import logging
2021-12-07 22:00:56 +00:00
2021-12-15 23:06:20 +00:00
from . import compare
2021-12-07 22:00:56 +00:00
from . import config
2021-12-14 23:07:10 +00:00
from . import parsing
2021-12-24 00:06:18 +00:00
from . import tamriel_trade_centre
2021-12-14 22:55:04 +00:00
2021-12-07 22:00:56 +00:00
def periodical_script ( ) :
2021-12-07 23:33:22 +00:00
parser = ArgumentParser (
description = " Visit https://www.esoui.com/ to search for addons and their dependencies URLs. Edit addons.yaml in the ESO live path and add the URL for each addon for installation. "
)
2021-12-07 22:00:56 +00:00
parser . add_argument ( " -v " , " --verbose " , action = " count " , help = " verbose logging " )
parser . add_argument (
2021-12-07 23:33:22 +00:00
" -p " ,
" --eso_live_path " ,
2022-01-05 20:40:58 +00:00
default = Path . home ( ) . joinpath ( " ESO/live/ " ) ,
2021-12-07 23:33:22 +00:00
help = ' default: " ~/.steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/ " ' ,
2021-12-07 22:00:56 +00:00
)
args = parser . parse_args ( )
if args . verbose :
logging . basicConfig (
level = logging . DEBUG ,
format = " %(asctime)s %(filename)s : %(lineno)d %(message)s " ,
)
else :
logging . basicConfig (
level = logging . INFO ,
format = " %(message)s " ,
)
logging . info ( args )
2021-12-07 23:35:52 +00:00
if isinstance ( args . eso_live_path , str ) :
if args . eso_live_path [ : 2 ] == " ~/ " :
args . eso_live_path = Path . home ( ) . joinpath ( args . eso_live_path [ 2 : ] )
2021-12-07 23:33:22 +00:00
config_path = Path ( args . eso_live_path ) . joinpath ( " addons.yaml " )
2021-12-07 22:00:56 +00:00
config_path . touch ( exist_ok = True )
config_current = config . load ( config_path )
try :
config . valid ( config_current )
2021-12-14 22:21:42 +00:00
except ( AssertionError , AttributeError ) :
2021-12-07 22:00:56 +00:00
config . new ( config_path )
config_current = config . load ( config_path )
2021-12-07 23:33:22 +00:00
logging . info ( f ' addons list created at " { config_path } " ' )
2021-12-14 22:21:42 +00:00
2021-12-15 00:01:38 +00:00
live_path = Path ( args . eso_live_path ) . joinpath ( " AddOns " )
if not live_path . is_dir ( ) :
logging . error ( f " eso_live_path_invalid_dir { live_path } " )
return
2021-12-15 23:06:20 +00:00
addon_urls = config_current . get ( " addons " )
esoui_uris = list ( )
for url in addon_urls :
esoui = parsing . esoui ( url )
esoui_uris . append ( esoui )
2021-12-15 00:01:38 +00:00
for child in live_path . iterdir ( ) :
2021-12-15 23:06:20 +00:00
compare . live_to_esoui ( path = child , esoui_uris = esoui_uris )
2021-12-22 23:11:29 +00:00
compare . esoui_to_live ( esoui_uris = esoui_uris , live_path = live_path )
2021-12-24 00:06:18 +00:00
tamriel_trade_centre . update ( live_path = live_path )
2022-01-05 20:40:58 +00:00
def ttc ( ) :
parser = ArgumentParser (
description = " Visit https://www.esoui.com/ to search for addons and their dependencies URLs. Edit addons.yaml in the ESO live path and add the URL for each addon for installation. "
)
parser . add_argument ( " -v " , " --verbose " , action = " count " , help = " verbose logging " )
parser . add_argument (
" -p " ,
" --eso_live_path " ,
default = Path . home ( ) . joinpath (
" .steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/ "
) ,
help = ' default: " ~/.steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/ " ' ,
)
args = parser . parse_args ( )
if args . verbose :
logging . basicConfig (
level = logging . DEBUG ,
format = " %(asctime)s %(filename)s : %(lineno)d %(message)s " ,
)
else :
logging . basicConfig (
level = logging . INFO ,
format = " %(message)s " ,
)
logging . info ( args )
if isinstance ( args . eso_live_path , str ) :
if args . eso_live_path [ : 2 ] == " ~/ " :
args . eso_live_path = Path . home ( ) . joinpath ( args . eso_live_path [ 2 : ] )
live_path = Path ( args . eso_live_path ) . joinpath ( " AddOns " )
if not live_path . is_dir ( ) :
logging . error ( f " eso_live_path_invalid_dir { live_path } " )
return
tamriel_trade_centre . update ( live_path = live_path )