added help messages
This commit is contained in:
19
cbrtocbz.py
19
cbrtocbz.py
@@ -5,7 +5,6 @@ import tempfile
|
||||
from sys import argv
|
||||
from os import curdir, remove, walk
|
||||
from os.path import splitext, join
|
||||
#from glob import glob
|
||||
from typing import Final
|
||||
|
||||
#optionally prints a message if the verbosity level is high enough
|
||||
@@ -16,15 +15,15 @@ vprint.verbosity = 0
|
||||
|
||||
def main(arguments):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-e', '--ext', type=str)
|
||||
parser.add_argument('-p', '--path', type=str)
|
||||
parser.add_argument('-d', '--delete', action='store_true')
|
||||
parser.add_argument('-v', action='count')
|
||||
parser.add_argument('-e', '--ext', type=str, help='set output file extension (default "cbr")', default='cbz')
|
||||
parser.add_argument('-p', '--path', type=str, help='output path', default='.')
|
||||
parser.add_argument('-d', '--delete', action='store_true', help='delete source file after successful conversion')
|
||||
parser.add_argument('-v', action='count', help='display additional information')
|
||||
parser.add_argument('files', nargs='+', type=str)
|
||||
args = parser.parse_args(arguments)
|
||||
files = args.files
|
||||
ext = args.ext or 'cbz'
|
||||
delete = args.delete
|
||||
files: Final = args.files
|
||||
ext: Final = args.ext.lstrip('.')
|
||||
delete: Final = args.delete
|
||||
path: Final = args.path or curdir
|
||||
|
||||
|
||||
@@ -36,8 +35,8 @@ def main(arguments):
|
||||
rar.extractall(dir)
|
||||
z_f = join(path, splitext(f)[0] + '.' + ext)
|
||||
with zipfile.ZipFile(z_f, 'x') as zip:
|
||||
for dirpath, dirs, files in walk(dir):
|
||||
for file in files:
|
||||
for dirpath, dirs, fs in walk(dir):
|
||||
for file in fs:
|
||||
p = join(dirpath, file)
|
||||
zip.write(p)
|
||||
vprint('finished ' + z_f, 0)
|
||||
|
||||
Reference in New Issue
Block a user