标题确实说明了一切,但我目前有这个,但它不起作用:
class Command(BaseCommand):
help = ("Functions related to downloading, parsing, and indexing the "
"content")
def add_arguments(self, parser):
subparsers = parser.add_subparsers()
download_parser = subparsers.add_parser(
'download',
help='Using a local CSV, download the XML data for content. '
'Output is sent to the log.'
)
download_parser.add_argument(
'--start_line',
type=int,
default=0,
help='The line in the file where you wish to start processing.'
)
# Add an argparse parser for parsing the content. Yes, this is
# a bit confusing.
content_parser_parser = subparsers.add_parser(
'parse',
help="Look at the file system and parse everything you see so that "
"we have content in the databse."
)
content_parser_parser.add_argument(
'--start_item',
type=int,
default=0,
help="Assuming the content is sorted by file name, this item is "
"the one to start on."
)
我的具体想法是创建一个具有子命令的命令,用于下载 XML 内容或将其解析到数据库中。