Update Updater.py to actually work, as well as gate font and templates behind flags to save some space on my drive

This commit is contained in:
DUOLabs333
2023-04-13 14:47:37 -04:00
parent f748ef091e
commit 81f4797b6b
10 changed files with 25619 additions and 21093 deletions
+28 -25
View File
@@ -42,8 +42,9 @@ urls = [
def download_file(remote,local): def download_file(remote,local):
if os.path.exists(local): if os.path.exists(local):
return #return --- Maybe make some flag for this
with tqdm(desc=path, unit="B", unit_scale=True) as progress_bar: pass
with tqdm(desc=local, unit="B", unit_scale=True) as progress_bar:
r = requests.get(remote, stream=True) r = requests.get(remote, stream=True)
progress_bar.total = int(r.headers.get("Content-Length", 0)) progress_bar.total = int(r.headers.get("Content-Length", 0))
@@ -53,7 +54,7 @@ def download_file(remote,local):
os.makedirs(os.path.dirname(local), exist_ok=True) os.makedirs(os.path.dirname(local), exist_ok=True)
with open(outfn, "wb") as outf: with open(local, "wb") as outf:
for chunk in r.iter_content(chunk_size=1024): for chunk in r.iter_content(chunk_size=1024):
progress_bar.update(len(chunk)) progress_bar.update(len(chunk))
outf.write(chunk) outf.write(chunk)
@@ -119,35 +120,37 @@ def decompress_font_list(flist):
prev_ff, prev_fsf, prev_flg, prev_cat = ff, fsf, flg, cat prev_ff, prev_fsf, prev_flg, prev_cat = ff, fsf, flg, cat
for font in decompress_font_list(db["FNTS"]["list"]): if '--fonts' in sys.argv:
path = "rsrc/fonts/" + font.url for font in decompress_font_list(db["FNTS"]["list"]):
if not os.path.isfile(root + path): path = "rsrc/fonts/" + font.url
print("Downloading " + font.url) if not os.path.isfile(root + path):
dl_file(path) print("Downloading " + font.url)
print("\n") dl_file(path)
print("\n")
#Delete any unused fonts #Delete any unused fonts
fonts_db=[root+'rsrc/fonts/'+font.url for font in decompress_font_list(db["FNTS"]["list"])] fonts_db=[root+'rsrc/fonts/'+font.url for font in decompress_font_list(db["FNTS"]["list"])]
fonts_local=[_ for _ in glob.glob(root + 'rsrc/fonts/**/*', recursive=True) if re.match(root+r'rsrc/fonts/(.*)/*.(otf|ttc|ttf)',_)] fonts_local=[_ for _ in glob.glob(root + 'rsrc/fonts/**/*', recursive=True) if re.match(root+r'rsrc/fonts/(.*)/*.(otf|ttc|ttf)',_)]
for font_file in list(set(fonts_local)-set(fonts_db)): for font_file in list(set(fonts_local)-set(fonts_db)):
print('Removing ' + font_file) print('Removing ' + font_file)
os.remove(font_file) os.remove(font_file)
templates_db=['file/' + ('psdshared' if _[4].startswith("https://i.imgur.com/") or _[4].startswith("https://imgur.com/") else 'pp-resources') +'/' + _[3] for _ in json.load(open(root+"papi/tpls.json"))['list']] if '--templates' in sys.argv:
for template in templates_db: templates_db=['file/' + ('psdshared' if _[4].startswith("https://i.imgur.com/") or _[4].startswith("https://imgur.com/") else 'pp-resources') +'/' + _[3] for _ in json.load(open(root+"papi/tpls.json"))['list']]
path="https://f000.backblazeb2.com/" + template for template in templates_db:
outfn=root+"templates/"+template path="https://f000.backblazeb2.com/" + template
download_file(path,outfn) outfn=root+"templates/"+template
download_file(path,outfn)
templates_local=[_ for _ in glob.glob(root + 'templates/file/**/*', recursive=True) if _.endswith(".psd")] templates_local=[_ for _ in glob.glob(root + 'templates/file/**/*', recursive=True) if _.endswith(".psd")]
templates_db=[root+"templates/"+_ for _ in templates_db] templates_db=[root+"templates/"+_ for _ in templates_db]
for tpl in list(set(templates_local)-set(templates_db)): for tpl in list(set(templates_local)-set(templates_db)):
print('Removing ' + tpl) print('Removing ' + tpl)
os.remove(tpl) os.remove(tpl)
def find_and_replace(file,find,replace): def find_and_replace(file,find,replace):
with open(os.path.join(root,file),'r') as pp: with open(os.path.join(root,file),'r') as pp:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
+15295 -14585
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

+7
View File
@@ -333,6 +333,8 @@
border-top-left-radius:4px; border-top-left-radius:4px;
border-top-right-radius:4px; border-top-right-radius:4px;
opacity: 0.7;
margin-right:4px; margin-right:4px;
transition: background 0.25s ease-in-out; transition: background 0.25s ease-in-out;
@@ -351,6 +353,11 @@
.block .panelhead .active .block .panelhead .active
{ {
background-color: var(--base); background-color: var(--base);
opacity:1;
}
.block .panelhead .active div
{
} }
.block .panelhead div .cross .block .panelhead div .cross
+2 -1
View File
@@ -130,7 +130,8 @@
function updateView() { function updateView() {
var w = window.innerWidth, h=window.innerHeight; var w = window.innerWidth, h=window.innerHeight;
itms.style.height=(h-90)+"px"; var sh = 90; if(w<1000) sh=130; if(w<800) sh=160;
itms.style.height=(h-sh)+"px";
cats.style.height=(h- 1)+"px"; cats.style.height=(h- 1)+"px";
add_link.style.display=(false?"none":"inline-block"); add_link.style.display=(false?"none":"inline-block");