mostr-zulip-bot/zulip/zulip/examples/edit-stream
Anders Kaseorg 5428c5f296 typing: Convert function type annotations to Python 3 style.
Generated by com2ann (slightly patched to avoid also converting
assignment type annotations, which require Python 3.6), followed by
some manual whitespace adjustment, and two fixes for use-before-define
issues:

-    def set_zulip_client(self, zulipToJabberClient: ZulipToJabberBot) -> None:
+    def set_zulip_client(self, zulipToJabberClient: 'ZulipToJabberBot') -> None:

-def init_from_options(options: Any, client: Optional[str] = None) -> Client:
+def init_from_options(options: Any, client: Optional[str] = None) -> 'Client':

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-18 20:31:14 -07:00

39 lines
1.2 KiB
Python
Executable file

#!/usr/bin/env python3
import argparse
import zulip
usage = """edit-stream --stream-id <stream_id>
[--description <new_description> --new-name <new_name>
--private --announcement-only --history-public-to-subscribers]
Example: edit-stream --stream-id=42 --description="A city in Italy." \
--new-name="Verona" --private
Example: edit-stream --stream-id=3 --history-public-to-subscribers
"""
def quote(string: str) -> str:
return '"{}"'.format(string)
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage))
parser.add_argument('--stream-id', type=int, required=True)
parser.add_argument('--description')
parser.add_argument('--new-name')
parser.add_argument('--private', action='store_true')
parser.add_argument('--announcement-only', action='store_true')
parser.add_argument('--history-public-to-subscribers', action='store_true')
options = parser.parse_args()
client = zulip.init_from_options(options)
print(client.update_stream({
'stream_id': options.stream_id,
'description': quote(options.description),
'new_name': quote(options.new_name),
'is_private': options.private,
'is_announcement_only': options.announcement_only,
'history_public_to_subscribers': options.history_public_to_subscribers
}))