integrations/rss: Upgrade to argparse.
This commit is contained in:
parent
c4480311d7
commit
09060afcab
18
zulip/integrations/rss/rss-bot
Normal file → Executable file
18
zulip/integrations/rss/rss-bot
Normal file → Executable file
|
@ -29,7 +29,7 @@ import errno
|
||||||
import hashlib
|
import hashlib
|
||||||
from six.moves.html_parser import HTMLParser
|
from six.moves.html_parser import HTMLParser
|
||||||
import logging
|
import logging
|
||||||
import optparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -67,34 +67,34 @@ stream every 5 minutes is:
|
||||||
|
|
||||||
*/5 * * * * /usr/local/share/zulip/integrations/rss/rss-bot"""
|
*/5 * * * * /usr/local/share/zulip/integrations/rss/rss-bot"""
|
||||||
|
|
||||||
parser = optparse.OptionParser(usage) # type: optparse.OptionParser
|
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage)) # type: argparse.ArgumentParser
|
||||||
parser.add_option('--stream',
|
parser.add_argument('--stream',
|
||||||
dest='stream',
|
dest='stream',
|
||||||
help='The stream to which to send RSS messages.',
|
help='The stream to which to send RSS messages.',
|
||||||
default="rss",
|
default="rss",
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option('--data-dir',
|
parser.add_argument('--data-dir',
|
||||||
dest='data_dir',
|
dest='data_dir',
|
||||||
help='The directory where feed metadata is stored',
|
help='The directory where feed metadata is stored',
|
||||||
default=os.path.join(RSS_DATA_DIR),
|
default=os.path.join(RSS_DATA_DIR),
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option('--feed-file',
|
parser.add_argument('--feed-file',
|
||||||
dest='feed_file',
|
dest='feed_file',
|
||||||
help='The file containing a list of RSS feed URLs to follow, one URL per line',
|
help='The file containing a list of RSS feed URLs to follow, one URL per line',
|
||||||
default=os.path.join(RSS_DATA_DIR, "rss-feeds"),
|
default=os.path.join(RSS_DATA_DIR, "rss-feeds"),
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option('--unwrap',
|
parser.add_argument('--unwrap',
|
||||||
dest='unwrap',
|
dest='unwrap',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Convert word-wrapped paragraphs into single lines',
|
help='Convert word-wrapped paragraphs into single lines',
|
||||||
default=False)
|
default=False)
|
||||||
parser.add_option('--math',
|
parser.add_argument('--math',
|
||||||
dest='math',
|
dest='math',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Convert $ to $$ (for KaTeX processing)',
|
help='Convert $ to $$ (for KaTeX processing)',
|
||||||
default=False)
|
default=False)
|
||||||
parser.add_option_group(zulip.generate_option_group(parser))
|
|
||||||
(opts, args) = parser.parse_args() # type: Tuple[Any, List[str]]
|
opts = parser.parse_args() # type: Any
|
||||||
|
|
||||||
def mkdir_p(path):
|
def mkdir_p(path):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
|
|
Loading…
Reference in a new issue