gmg reprocess available --action-help now tells you processor arguments!

Every reprocessing action possible can inform you of its command line
argument stuff!  Is that awesome or what?
This commit is contained in:
Christopher Allan Webber 2013-08-09 13:56:23 -05:00 committed by Rodney Ewing
parent 85ead8ac3c
commit 55a10fef0a
3 changed files with 31 additions and 15 deletions

View File

@ -37,6 +37,11 @@ def reprocess_parser_setup(subparser):
"id_or_type", "id_or_type",
help="Media id or media type to check") help="Media id or media type to check")
available_parser.add_argument(
"--action-help",
action="store_true",
help="List argument help for each action available")
############################################ ############################################
# run command (TODO: and bulk_run command??) # run command (TODO: and bulk_run command??)
@ -221,13 +226,22 @@ def available(args):
processors = manager.list_eligible_processors(media_entry) processors = manager.list_eligible_processors(media_entry)
print "Available processors:" print "Available processors:"
print "---------------------" print "====================="
for processor in processors: if args.action_help:
if processor.description: for processor in processors:
print " - %s: %s" % (processor.name, processor.description) print processor.name
else: print "-" * len(processor.name)
print " - %s" % processor.name
parser = processor.generate_parser()
parser.print_help()
else:
for processor in processors:
if processor.description:
print " - %s: %s" % (processor.name, processor.description)
else:
print " - %s" % processor.name
def run(args): def run(args):

View File

@ -313,7 +313,8 @@ class CommonImageProcessor(MediaProcessor):
def resize_step(self): def resize_step(self):
pass pass
def _add_width_height_args(self, parser): @classmethod
def _add_width_height_args(cls, parser):
parser.add_argument( parser.add_argument(
"--width", default=None, "--width", default=None,
help=( help=(
@ -332,7 +333,7 @@ class InitialProcessor(CommonImageProcessor):
description = "Initial processing" description = "Initial processing"
@classmethod @classmethod
def media_is_eligibile(self, media_entry): def media_is_eligibile(cls, media_entry):
""" """
Determine if this media type is eligible for processing Determine if this media type is eligible for processing
""" """
@ -344,16 +345,17 @@ class InitialProcessor(CommonImageProcessor):
############################### ###############################
@classmethod @classmethod
def generate_parser(self): def generate_parser(cls):
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description=self.description) description=cls.description,
prog=cls.name)
self._add_width_height_args(parser) cls._add_width_height_args(parser)
return parser return parser
@classmethod @classmethod
def args_to_request(self, args): def args_to_request(cls, args):
raise NotImplementedError raise NotImplementedError

View File

@ -126,7 +126,7 @@ class MediaProcessor(object):
raise NotImplementedError raise NotImplementedError
@classmethod @classmethod
def media_is_eligibile(self, media_entry): def media_is_eligibile(cls, media_entry):
raise NotImplementedError raise NotImplementedError
############################### ###############################
@ -134,11 +134,11 @@ class MediaProcessor(object):
############################### ###############################
@classmethod @classmethod
def generate_parser(self): def generate_parser(cls):
raise NotImplementedError raise NotImplementedError
@classmethod @classmethod
def parser_to_request(self, parser): def parser_to_request(cls, parser):
raise NotImplementedError raise NotImplementedError
########################################## ##########################################