Skip to content

Commit 8075b8c

Browse files
authored
## v0.9 - July 06, 2022
- changed: now flushes the output of job message without buffering, useful for live monitoring and reading stdout the moment it is written - new: added a "PKGBUILD" for use with `pacman`, can be used to generate an Archlinux package
1 parent bb8a118 commit 8075b8c

File tree

4 files changed

+86
-22
lines changed

4 files changed

+86
-22
lines changed

CHANGES.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
Update history for **tochd**.
44

5+
## v.0.9 - July 06, 2022
6+
7+
- changed: now flushes the output of job message without buffering, useful for
8+
live monitoring and reading stdout the moment it is written
9+
- new: added a "PKGBUILD" for use with `pacman`, can be used to generate an
10+
Archlinux package
11+
512
## v0.8 - March 30, 2022
613

714
- new: pseudo compiled bundle of the script with pyinstaller to build a

PKGBUILD

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Maintainer: Tuncay <mamehiscore@aol.com>
2+
pkgname=tochd
3+
pkgver=0.9
4+
pkgrel=1
5+
pkgdesc="Convert game ISO and archives to CD CHD for emulation."
6+
arch=('any')
7+
url="https://github.com/thingsiplay/tochd"
8+
license=('MIT')
9+
depends=('python3' 'p7zip' 'mame-tools')
10+
source=("$pkgname-$pkgver.tar.gz::https://github.com/thingsiplay/$pkgname/archive/refs/tags/v$pkgver.tar.gz")
11+
noextract=('Makefile' 'install.sh' 'uninstall.sh')
12+
13+
sha256sums=('3ea72f97182c6696c52503814cc16c61f33027b4534bc2d1bed39d688e57163c')
14+
15+
check() {
16+
cd "$pkgname-$pkgver"
17+
python3 "$pkgname.py" --version
18+
}
19+
20+
package() {
21+
cd "$pkgname-$pkgver"
22+
mkdir -p "$pkgdir/usr/local/bin"
23+
install -m 755 -T "$pkgname.py" "$pkgdir/usr/local/bin/${pkgname%%.*}"
24+
}

README.md

+35-6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ If you have an older Python version, then you might want to check the binary
4949
[release](https://github.com/thingsiplay/tochd/releases) package, which bundles
5050
up the script and Python interpreter to create a standalone executable.
5151

52+
### Optional: Install on Archlinux using PKGBUILD package
53+
54+
If you are using an Archlinux based system, then you can instead build an
55+
Archlinux package and install with `pacman`. Use `makepkg` to generate a .zst
56+
package or download from the
57+
[https://github.com/thingsiplay/tochd/releases](releases) page.
58+
Then use `sudo pacman -U tochd-x.x-x-any.pkg.tar.zst` command (where the `x`
59+
should be replaced by the version number of generated package) to install into
60+
the system. To remove the package, just use `sudo pacman -R tochd`. The
61+
installation directory is under "/usr/local/bin" and differs from the
62+
"install.sh" that is provided with the repository.
63+
5264
### Optional: Makefile and PyInstaller (you can ignore this part)
5365

5466
The included "Makefile" is to build the package with the standalone binary. It
@@ -167,16 +179,33 @@ threads with option `-t` (short for `--threads`).
167179

168180
# Additional notes, workarounds and quirks
169181

170-
If you forcefully terminate the script while working, then unfinished files and
171-
especially temporary folders cannot be removed anymore. These files and folders
172-
can take up huge amount of space! Temporary folders are hidden starting with a
173-
dot "." in the name, followed by the name of archive and some random characters
174-
added. Make sure these files are deleted, in case you forcefully terminate the
175-
script.
182+
If you forcefully terminate the entire script while working, then unfinished
183+
files and especially temporary folders cannot be removed anymore. These files
184+
and folders can take up huge amount of space! Temporary folders are hidden
185+
starting with a dot "." in the name, followed by the name of archive and some
186+
random characters. Make sure these files are deleted. The regular `Ctrl+c` to
187+
abort current job is *not* a forced termination of script (unless option `-E`
188+
is in effect).
176189

177190
Some archives contain multiple folders, each with ISO files of same name. These
178191
are usually intended to copy and overwrite files in a main folder as a meaning
179192
of patching. However, the script has no understanding and knowledge about this
180193
and would try to convert each .iso file on it's own. As a workaround all .iso
181194
files in the archive are ignored when a sheet type such as CUE or GDI files are
182195
found.
196+
197+
Somtimes .cue or .iso files found in an archive have a different name than the
198+
archive filename itself. Sometimes one of them lack important informations and
199+
you need to determine which of them is "correct". In example translations could
200+
have important information encoded in the filename of the .cue, which would be
201+
lost, as the .CHD file is automatically renamed to match the .zip or .7z
202+
archive in example. Use in such situations option `-R` (short for
203+
`--no-rename`) to prevent that and leave the original files name found inside
204+
the archive.
205+
206+
There are cases where the audio files can be a different format than what the
207+
.cue (or .gdi) files expect. In example there are cases where the audio files
208+
are in .ape format and need to be converted to .wav first. If you are unsure
209+
about this, then look into any provided readme file or the .cue sheet itself.
210+
Then convert them before handing it over to .chd conversion.
211+

tochd.py

+20-16
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class App:
2424
""" Contains all settings and meta information for the application. """
2525

2626
name: str = 'tochd'
27-
version: str = '0.8'
27+
version: str = '0.9'
2828
types = {
2929
'sheet': ('gdi', 'cue',),
3030
'image': ('iso',),
@@ -315,7 +315,8 @@ def message_job(self, message: str, path: Path, jobindex: int) -> None:
315315
pad_size: int = 12
316316
pad_size = pad_size - len(str(jobindex))
317317
padded_msg = message.rjust(pad_size)
318-
print('Job', jobindex, padded_msg + ':\t', path.as_posix())
318+
message = f"Job {jobindex} {padded_msg}:\t{path.as_posix()}"
319+
print(message, flush=True)
319320
return None
320321

321322
@classmethod
@@ -438,11 +439,12 @@ def parse_arguments(args: list[str] | None = None) -> Argparse:
438439
'file',
439440
default=[],
440441
nargs='*',
441-
help=('input multiple files or folders with ISOs or archives, all '
442-
'supported files from a given folder are processed, in addition '
443-
'use option dash "-" to read files from stdin for each line, '
444-
'note: option "--" stops parsing for options and everything '
445-
'after is a filename even those starting with a single dash "-"')
442+
help=('input multiple files or folders containing ISOs or archive '
443+
'files, script will search for supported files in top level of '
444+
'a folder, a single dash "-" character will instruct the script '
445+
'to read file paths from stdin for each line, note: option '
446+
'double dash "--" will stop parsing for program options and '
447+
'everything following that is interpreted as a file')
446448
)
447449

448450
parser.add_argument(
@@ -478,14 +480,14 @@ def parse_arguments(args: list[str] | None = None) -> Argparse:
478480
dest='p7z',
479481
metavar='CMD',
480482
default='7z',
481-
help='change path or command name of 7z program'
483+
help='change path or command name to 7z program'
482484
)
483485

484486
parser.add_argument(
485487
'--chdman',
486488
metavar='CMD',
487489
default='chdman',
488-
help='change path or command name of chdman program'
490+
help='change path or command name to chdman program'
489491
)
490492

491493
parser.add_argument(
@@ -494,7 +496,7 @@ def parse_arguments(args: list[str] | None = None) -> Argparse:
494496
default=None,
495497
help=('destination path to an existing directory to save the CHD file '
496498
'under, the temporary subfolder will be created here too, '
497-
'defaults to each input files original directory')
499+
'defaults to each input files original folder')
498500
)
499501

500502
parser.add_argument(
@@ -503,7 +505,8 @@ def parse_arguments(args: list[str] | None = None) -> Argparse:
503505
action='store_true',
504506
help=('disable automatic renaming for CHD files that were build from '
505507
'archives, no test for "if file already exists" can be provided '
506-
'beforehand, only applicable to archive sources')
508+
'beforehand, only applicable to archive sources, without this '
509+
'option files from archives are renamed to match the archive')
507510
)
508511

509512
parser.add_argument(
@@ -534,8 +537,9 @@ def parse_arguments(args: list[str] | None = None) -> Argparse:
534537
type=int,
535538
choices=range(0, cpucount()),
536539
help=('limit the number of processor cores to utilize during '
537-
'creation of the CHD files with "chdman", 0 will not limit '
538-
f'the cores (available: {os.cpu_count()}), defaults to "0"')
540+
'creation of the CHD files with "chdman" for each thread, '
541+
f'0 will not limit the cores (available: {os.cpu_count()}), '
542+
'defaults to "0"')
539543
)
540544

541545
parser.add_argument(
@@ -559,9 +563,9 @@ def parse_arguments(args: list[str] | None = None) -> Argparse:
559563
default=False,
560564
action='store_true',
561565
help=('Ctrl+c (SIGINT) will stop execution of script immadiately '
562-
'with exit code 255, without this option the script defaults to '
563-
'canceling current job process properly and continue with next '
564-
'job process')
566+
'with exit code 255, which could leave temporary files, without '
567+
'this option the script defaults to canceling current job '
568+
'process properly and continue with next job process in list')
565569
)
566570

567571
parser.add_argument(

0 commit comments

Comments
 (0)