Add --dry-run option for testing.
This commit is contained in:
parent
760bb703cf
commit
f7c3d39fcf
1 changed files with 7 additions and 3 deletions
10
dosage
10
dosage
|
@ -80,6 +80,7 @@ def setupOptions():
|
||||||
parser.add_argument('-t', '--timestamps', action='store_true', help='print timestamps for all output at any info level')
|
parser.add_argument('-t', '--timestamps', action='store_true', help='print timestamps for all output at any info level')
|
||||||
parser.add_argument('-o', '--output', action='append', dest='handler', choices=events.getHandlerNames(), help='sets output handlers for downloaded comics')
|
parser.add_argument('-o', '--output', action='append', dest='handler', choices=events.getHandlerNames(), help='sets output handlers for downloaded comics')
|
||||||
parser.add_argument('--adult', action='store_true', help='confirms that you are old enough to view adult content')
|
parser.add_argument('--adult', action='store_true', help='confirms that you are old enough to view adult content')
|
||||||
|
parser.add_argument('--dry-run', action='store_true', help=argparse.SUPPRESS)
|
||||||
# multimatch is only used for development, eg. testing if all comics of a scripted plugin are working
|
# multimatch is only used for development, eg. testing if all comics of a scripted plugin are working
|
||||||
parser.add_argument('--multimatch', action='store_true', help=argparse.SUPPRESS)
|
parser.add_argument('--multimatch', action='store_true', help=argparse.SUPPRESS)
|
||||||
parser.add_argument('comic', nargs='*', help='comic module name (including case insensitive substrings)')
|
parser.add_argument('comic', nargs='*', help='comic module name (including case insensitive substrings)')
|
||||||
|
@ -132,13 +133,16 @@ def setOutputInfo(options):
|
||||||
out.timestamps = options.timestamps
|
out.timestamps = options.timestamps
|
||||||
|
|
||||||
|
|
||||||
def saveComicStrip(strip, basepath):
|
def saveComicStrip(strip, basepath, dryrun):
|
||||||
"""Save a comic strip which can consist of multiple images."""
|
"""Save a comic strip which can consist of multiple images."""
|
||||||
errors = 0
|
errors = 0
|
||||||
allskipped = True
|
allskipped = True
|
||||||
for image in strip.getImages():
|
for image in strip.getImages():
|
||||||
try:
|
try:
|
||||||
filename, saved = image.save(basepath)
|
if dryrun:
|
||||||
|
filename, saved = "", False
|
||||||
|
else:
|
||||||
|
filename, saved = image.save(basepath)
|
||||||
if saved:
|
if saved:
|
||||||
allskipped = False
|
allskipped = False
|
||||||
except Exception as msg:
|
except Exception as msg:
|
||||||
|
@ -232,7 +236,7 @@ def getStrips(scraperobj, options):
|
||||||
out.context = scraperobj.getName()
|
out.context = scraperobj.getName()
|
||||||
try:
|
try:
|
||||||
for strip in scraperobj.getStrips(numstrips):
|
for strip in scraperobj.getStrips(numstrips):
|
||||||
_errors, skipped = saveComicStrip(strip, options.basepath)
|
_errors, skipped = saveComicStrip(strip, options.basepath, options.dry_run)
|
||||||
errors += _errors
|
errors += _errors
|
||||||
if skipped and options.cont:
|
if skipped and options.cont:
|
||||||
# stop when retrieval skipped an image for one comic strip
|
# stop when retrieval skipped an image for one comic strip
|
||||||
|
|
Loading…
Reference in a new issue