[options] swap --print and --Print semantics
--print now outputs values without downloading files --Print now outputs values AND downloads files add --Print-to-file with the same difference to --print-to-file
This commit is contained in:
@@ -49,12 +49,16 @@
|
|||||||
values for the given URLs
|
values for the given URLs
|
||||||
-e, --error-file FILE Add input URLs which returned an error to FILE
|
-e, --error-file FILE Add input URLs which returned an error to FILE
|
||||||
-N, --print [EVENT:]FORMAT Write FORMAT during EVENT (default 'prepare')
|
-N, --print [EVENT:]FORMAT Write FORMAT during EVENT (default 'prepare')
|
||||||
to standard output. Examples: 'id' or
|
to standard output instead of downloading
|
||||||
'post:{md5[:8]}'
|
files. Can be used multiple times. Examples:
|
||||||
--Print [EVENT:]FORMAT Like --print, but also sets --no-download,
|
'id' or 'post:{md5[:8]}'
|
||||||
--no-skip, and disables other output to stdout
|
--Print [EVENT:]FORMAT Like --print, but downloads files as well
|
||||||
--print-to-file [EVENT:]FORMAT FILE
|
--print-to-file [EVENT:]FORMAT FILE
|
||||||
Append FORMAT during EVENT to FILE
|
Append FORMAT during EVENT to FILE instead of
|
||||||
|
downloading files. Can be used multiple times
|
||||||
|
--Print-to-file [EVENT:]FORMAT FILE
|
||||||
|
Like --print-to-file, but downloads files as
|
||||||
|
well
|
||||||
--list-modules Print a list of available extractor modules
|
--list-modules Print a list of available extractor modules
|
||||||
--list-extractors [CATEGORIES]
|
--list-extractors [CATEGORIES]
|
||||||
Print a list of extractor classes with
|
Print a list of extractor classes with
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class UgoiraAction(argparse.Action):
|
|||||||
class PrintAction(argparse.Action):
|
class PrintAction(argparse.Action):
|
||||||
def __call__(self, parser, namespace, value, option_string=None):
|
def __call__(self, parser, namespace, value, option_string=None):
|
||||||
if self.const:
|
if self.const:
|
||||||
if self.const == "+":
|
if self.const == "-":
|
||||||
namespace.options.append(((), "skip", False))
|
namespace.options.append(((), "skip", False))
|
||||||
namespace.options.append(((), "download", False))
|
namespace.options.append(((), "download", False))
|
||||||
namespace.options.append((("output",), "mode", False))
|
namespace.options.append((("output",), "mode", False))
|
||||||
@@ -164,6 +164,9 @@ class PrintAction(argparse.Action):
|
|||||||
base = None
|
base = None
|
||||||
mode = "w"
|
mode = "w"
|
||||||
else:
|
else:
|
||||||
|
if self.const is None:
|
||||||
|
namespace.options.append(((), "skip", False))
|
||||||
|
namespace.options.append(((), "download", False))
|
||||||
value, path = value
|
value, path = value
|
||||||
base, filename = os.path.split(path)
|
base, filename = os.path.split(path)
|
||||||
mode = "a"
|
mode = "a"
|
||||||
@@ -405,20 +408,28 @@ def build_parser():
|
|||||||
dest="postprocessors", metavar="[EVENT:]FORMAT",
|
dest="postprocessors", metavar="[EVENT:]FORMAT",
|
||||||
action=PrintAction, const="-", default=[],
|
action=PrintAction, const="-", default=[],
|
||||||
help=("Write FORMAT during EVENT (default 'prepare') to standard "
|
help=("Write FORMAT during EVENT (default 'prepare') to standard "
|
||||||
"output. Examples: 'id' or 'post:{md5[:8]}'"),
|
"output instead of downloading files. "
|
||||||
|
"Can be used multiple times. "
|
||||||
|
"Examples: 'id' or 'post:{md5[:8]}'"),
|
||||||
)
|
)
|
||||||
output.add_argument(
|
output.add_argument(
|
||||||
"--Print",
|
"--Print",
|
||||||
dest="postprocessors", metavar="[EVENT:]FORMAT",
|
dest="postprocessors", metavar="[EVENT:]FORMAT",
|
||||||
action=PrintAction, const="+",
|
action=PrintAction, const="+",
|
||||||
help=("Like --print, but also sets --no-download, --no-skip, "
|
help="Like --print, but downloads files as well",
|
||||||
"and disables other output to stdout"),
|
|
||||||
)
|
)
|
||||||
output.add_argument(
|
output.add_argument(
|
||||||
"--print-to-file",
|
"--print-to-file",
|
||||||
dest="postprocessors", metavar="[EVENT:]FORMAT FILE",
|
dest="postprocessors", metavar="[EVENT:]FORMAT FILE",
|
||||||
action=PrintAction, nargs=2,
|
action=PrintAction, const=None, nargs=2,
|
||||||
help="Append FORMAT during EVENT to FILE",
|
help=("Append FORMAT during EVENT to FILE instead of downloading "
|
||||||
|
"files. Can be used multiple times"),
|
||||||
|
)
|
||||||
|
output.add_argument(
|
||||||
|
"--Print-to-file",
|
||||||
|
dest="postprocessors", metavar="[EVENT:]FORMAT FILE",
|
||||||
|
action=PrintAction, const=False, nargs=2,
|
||||||
|
help="Like --print-to-file, but downloads files as well",
|
||||||
)
|
)
|
||||||
output.add_argument(
|
output.add_argument(
|
||||||
"--list-modules",
|
"--list-modules",
|
||||||
|
|||||||
Reference in New Issue
Block a user