Compare commits

..

5 Commits

Author SHA1 Message Date
39407286b3 Fix tarfile 2023-12-25 22:59:57 -08:00
6e56872121 Fix running dmgbuild again 2023-12-25 22:50:11 -08:00
888c50d72a Fix running dmgbuild 2023-12-25 22:41:57 -08:00
231b600a0e Switch to tar.gz and dmg archives to reduce space 2023-12-25 22:16:18 -08:00
db00736f58 Fix filename parsing not respecting user settings 2023-12-25 21:57:31 -08:00
10 changed files with 116 additions and 45 deletions

View File

@ -88,6 +88,8 @@ jobs:
name: "${{ format('ComicTagger-{0}', runner.os) }}"
path: |
dist/*.zip
dist/*.tar.gz
dist/*.dmg
dist/*.AppImage
- name: PyTest

View File

@ -70,5 +70,7 @@ jobs:
# upload the single application zip file for each OS and include the wheel built on linux
files: |
dist/*.zip
dist/*.tar.gz
dist/*.dmg
dist/*${{ fromJSON('["never", ""]')[runner.os == 'Linux'] }}.whl
dist/*.AppImage

24
build-tools/dmgbuild.conf Normal file
View File

@ -0,0 +1,24 @@
import pathlib
import platform
from comictaggerlib.ctversion import __version__
app = "ComicTagger"
exe = app.casefold()
ver = platform.mac_ver()
os_version = f"osx-{ver[0]}-{ver[2]}"
app_name = f"{app}.app"
final_name = f"{app}-{__version__}-{os_version}"
path = pathlib.Path(f"dist/{app_name}")
zip_file = pathlib.Path(f"dist/{final_name}.zip")
format = 'ULMO'
files = (str(path),)
symlinks = {'Applications': '/Applications'}
icon = pathlib.Path().cwd() / 'build-tools' / 'mac' / 'volume.icns'
icon_locations = {
app_name: (100, 100),
'Applications': (300, 100)
}

View File

@ -3,28 +3,12 @@ from __future__ import annotations
import os
import pathlib
import platform
import sys
import tarfile
import zipfile
from comictaggerlib.ctversion import __version__
app = "ComicTagger"
exe = app.casefold()
if platform.system() == "Windows":
os_version = f"win-{platform.machine()}"
app_name = f"{exe}.exe"
final_name = f"{app}-{__version__}-{os_version}.exe"
elif platform.system() == "Darwin":
ver = platform.mac_ver()
os_version = f"osx-{ver[0]}-{ver[2]}"
app_name = f"{app}.app"
final_name = f"{app}-{__version__}-{os_version}.app"
else:
app_name = exe
final_name = f"ComicTagger-{__version__}-{platform.system()}"
path = f"dist/{app_name}"
zip_file = pathlib.Path(f"dist/{final_name}.zip")
def addToZip(zf: zipfile.ZipFile, path: str, zippath: str) -> None:
if os.path.isfile(path):
@ -34,14 +18,71 @@ def addToZip(zf: zipfile.ZipFile, path: str, zippath: str) -> None:
zf.write(path, zippath)
for nm in sorted(os.listdir(path)):
addToZip(zf, os.path.join(path, nm), os.path.join(zippath, nm))
# else: ignore
zip_file.unlink(missing_ok=True)
with zipfile.ZipFile(zip_file, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=8) as zf:
zippath = os.path.basename(path)
if not zippath:
zippath = os.path.basename(os.path.dirname(path))
if zippath in ("", os.curdir, os.pardir):
zippath = ""
addToZip(zf, path, zippath)
def Zip(zip_file: pathlib.Path, path: pathlib.Path) -> None:
zip_file.unlink(missing_ok=True)
with zipfile.ZipFile(f"{zip_file}.zip", "w", compression=zipfile.ZIP_DEFLATED, compresslevel=8) as zf:
zippath = os.path.basename(path)
if not zippath:
zippath = os.path.basename(os.path.dirname(path))
if zippath in ("", os.curdir, os.pardir):
zippath = ""
addToZip(zf, str(path), zippath)
def addToTar(tf: tarfile.TarFile, path: str, zippath: str) -> None:
if os.path.isfile(path):
tf.add(path, zippath)
elif os.path.isdir(path):
if zippath:
tf.add(path, zippath, recursive=False)
for nm in sorted(os.listdir(path)):
addToTar(tf, os.path.join(path, nm), os.path.join(zippath, nm))
def Tar(tar_file: pathlib.Path, path: pathlib.Path) -> None:
tar_file.unlink(missing_ok=True)
with tarfile.open(f"{tar_file}.tar.gz", "w:gz") as tf:
zippath = os.path.basename(path)
if not zippath:
zippath = os.path.basename(os.path.dirname(path))
if zippath in ("", os.curdir, os.pardir):
zippath = ""
addToTar(tf, str(path), zippath)
if __name__ == "__main__":
app = "ComicTagger"
exe = app.casefold()
if platform.system() == "Windows":
os_version = f"win-{platform.machine()}"
app_name = f"{exe}.exe"
final_name = f"{app}-{__version__}-{os_version}.exe"
elif platform.system() == "Darwin":
ver = platform.mac_ver()
os_version = f"osx-{ver[0]}-{ver[2]}"
app_name = f"{app}.app"
final_name = f"{app}-{__version__}-{os_version}"
else:
app_name = exe
final_name = f"ComicTagger-{__version__}-{platform.system()}"
path = pathlib.Path(f"dist/{app_name}")
zip_file = pathlib.Path(f"dist/{final_name}")
if platform.system() == "Darwin":
from dmgbuild.__main__ import main as dmg_main
sys.argv = [
"zip_artifacts",
"-s",
str(pathlib.Path(__file__).parent / "dmgbuild.conf"),
f"{app} {__version__}",
f"dist/{final_name}.dmg",
]
dmg_main()
elif platform.system() == "Windows":
Zip(zip_file, path)
else:
Tar(zip_file, path)

View File

@ -254,7 +254,9 @@ class CLI:
self.config.Filename_Parsing__remove_c2c,
self.config.Filename_Parsing__remove_fcbd,
self.config.Filename_Parsing__remove_publisher,
self.config.Runtime_Options__split_words,
self.config.Filename_Parsing__split_words,
self.config.Filename_Parsing__allow_issue_start_with_letter,
self.config.Filename_Parsing__protofolius_issue_number_scheme,
)
md.overlay(f_md)

View File

@ -145,12 +145,6 @@ def register_runtime(parser: settngs.Manager) -> None:
help="Recursively include files in sub-folders.",
file=False,
)
parser.add_setting(
"--split-words",
action="store_true",
help="""Splits words before parsing the filename.\ne.g. 'judgedredd' to 'judge dredd'\n\n""",
file=False,
)
parser.add_setting(
"-n",
"--dryrun",

View File

@ -119,6 +119,12 @@ def filename(parser: settngs.Manager) -> None:
action=argparse.BooleanOptionalAction,
help="Attempts to remove publisher names from filenames, currently limited to Marvel and DC. Requires --complicated-parser",
)
parser.add_setting(
"--split-words",
action="store_true",
help="""Splits words before parsing the filename.\ne.g. 'judgedredd' to 'judge dredd'\n\n""",
file=False,
)
parser.add_setting(
"--protofolius-issue-number-scheme",
default=False,

View File

@ -26,7 +26,6 @@ class settngs_namespace(settngs.TypedNS):
Runtime_Options__summary: bool
Runtime_Options__raw: bool
Runtime_Options__recursive: bool
Runtime_Options__split_words: bool
Runtime_Options__dryrun: bool
Runtime_Options__darkmode: bool
Runtime_Options__glob: bool
@ -64,6 +63,7 @@ class settngs_namespace(settngs.TypedNS):
Filename_Parsing__remove_c2c: bool
Filename_Parsing__remove_fcbd: bool
Filename_Parsing__remove_publisher: bool
Filename_Parsing__split_words: bool
Filename_Parsing__protofolius_issue_number_scheme: bool
Filename_Parsing__allow_issue_start_with_letter: bool

View File

@ -682,12 +682,7 @@ class TaggerWindow(QtWidgets.QMainWindow):
def update_ui_for_archive(self, parse_filename: bool = True) -> None:
if self.comic_archive is not None:
if self.metadata.is_empty and parse_filename:
self.metadata = self.comic_archive.metadata_from_filename(
self.config[0].Filename_Parsing__complicated_parser,
self.config[0].Filename_Parsing__remove_c2c,
self.config[0].Filename_Parsing__remove_fcbd,
self.config[0].Filename_Parsing__remove_publisher,
)
self.use_filename()
self.metadata.apply_default_page_list(self.comic_archive.get_page_name_list())
@ -1012,10 +1007,11 @@ class TaggerWindow(QtWidgets.QMainWindow):
self.config[0].Filename_Parsing__remove_fcbd,
self.config[0].Filename_Parsing__remove_publisher,
split_words,
self.config[0].Filename_Parsing__allow_issue_start_with_letter,
self.config[0].Filename_Parsing__protofolius_issue_number_scheme,
)
if new_metadata is not None:
self.metadata.overlay(new_metadata)
self.metadata_to_form()
self.metadata.overlay(new_metadata)
self.metadata_to_form()
def use_filename_split(self) -> None:
self._use_filename(True)
@ -1666,6 +1662,8 @@ class TaggerWindow(QtWidgets.QMainWindow):
self.config[0].Filename_Parsing__remove_fcbd,
self.config[0].Filename_Parsing__remove_publisher,
dlg.split_words,
self.config[0].Filename_Parsing__allow_issue_start_with_letter,
self.config[0].Filename_Parsing__protofolius_issue_number_scheme,
)
if dlg.ignore_leading_digits_in_filename and md.series is not None:
# remove all leading numbers

View File

@ -237,8 +237,8 @@ deps =
extras =
all
commands =
python -c 'import importlib,platform; importlib.import_module("icu") if platform.system() != "Windows" else ...' # Sanity check for icu
pyinstaller -y build-tools/comictagger.spec
python -c 'import importlib,platform; importlib.import_module("icu") if platform.system() != "Windows" else ...' # Sanity check for icu
[testenv:appimage]
description = Generate appimage executable
@ -279,6 +279,8 @@ depends =
wheel
pyinstaller
appimage
deps =
dmgbuild
commands =
python ./build-tools/zip_artifacts.py