From 61d84cd649f1337a8ff9e25c725cc6877daf64a5 Mon Sep 17 00:00:00 2001 From: Eeshan Garg Date: Sat, 29 Jul 2017 00:24:42 -0230 Subject: [PATCH] zulip/examples: Remove sys.path modifications. With the new repo, doing a `pip install -e ./zulip` will be a part of the core workflow. This mitigates the risk of developers accidentally testing their changes against an installed copy of the zulip package rather than the copy in their checkout. Therefore, we can now get rid of the various `sys.path.inserts` in the examples. --- zulip/examples/create-user | 3 --- zulip/examples/edit-message | 3 --- zulip/examples/get-presence | 3 --- zulip/examples/get-public-streams | 3 --- zulip/examples/list-members | 3 --- zulip/examples/list-subscriptions | 4 +--- zulip/examples/print-events | 4 +--- zulip/examples/print-messages | 4 +--- zulip/examples/recent-messages | 4 +--- zulip/examples/send-message | 3 --- zulip/examples/subscribe | 3 +-- zulip/examples/unsubscribe | 3 +-- zulip/examples/upload-file | 3 --- 13 files changed, 6 insertions(+), 37 deletions(-) diff --git a/zulip/examples/create-user b/zulip/examples/create-user index f6ec2fb..8f4724b 100755 --- a/zulip/examples/create-user +++ b/zulip/examples/create-user @@ -22,8 +22,6 @@ # THE SOFTWARE. from __future__ import print_function -import sys -from os import path import argparse usage = """create-user --new-email= --new-password= --new-full-name= --new-short-name= [options] @@ -34,7 +32,6 @@ will be created in your realm. Example: create-user --site=http://localhost:9991 --user=rwbarton@example.com --new-email=jarthur@example.com --new-password=random17 --new-full-name 'J. Arthur Random' --new-short-name='jarthur' """ -sys.path.append(path.join(path.dirname(__file__), '..')) import zulip parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) diff --git a/zulip/examples/edit-message b/zulip/examples/edit-message index cc28228..0776e91 100755 --- a/zulip/examples/edit-message +++ b/zulip/examples/edit-message @@ -22,8 +22,6 @@ # THE SOFTWARE. from __future__ import print_function -import sys -import os import argparse usage = """edit-message [options] --message= --subject= --content= --user= --api-key= @@ -35,7 +33,6 @@ Example: edit-message --message-id="348135" --subject="my subject" --content="te You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) import zulip parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) diff --git a/zulip/examples/get-presence b/zulip/examples/get-presence index 10144ea..aa9a849 100755 --- a/zulip/examples/get-presence +++ b/zulip/examples/get-presence @@ -22,8 +22,6 @@ # THE SOFTWARE. from __future__ import print_function -import sys -from os import path import argparse usage = """get-presence --email= [options] @@ -31,7 +29,6 @@ usage = """get-presence --email= [options] Get presence data for another user. """ -sys.path.append(path.join(path.dirname(__file__), '..')) import zulip parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) diff --git a/zulip/examples/get-public-streams b/zulip/examples/get-public-streams index 4ef8f42..b28b24c 100755 --- a/zulip/examples/get-public-streams +++ b/zulip/examples/get-public-streams @@ -22,8 +22,6 @@ # THE SOFTWARE. from __future__ import print_function -import sys -import os import argparse usage = """get-public-streams --user= --api-key= [options] @@ -35,7 +33,6 @@ Example: get-public-streams --user=othello-bot@example.com --api-key=a0b1c2d3e4f You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import zulip parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) diff --git a/zulip/examples/list-members b/zulip/examples/list-members index a5bc945..1dc9804 100755 --- a/zulip/examples/list-members +++ b/zulip/examples/list-members @@ -22,8 +22,6 @@ # THE SOFTWARE. from __future__ import print_function -import sys -import os import argparse usage = """list-members --user= --api-key= [options] @@ -33,7 +31,6 @@ List the names and e-mail addresses of the people in your realm. You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import zulip parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) diff --git a/zulip/examples/list-subscriptions b/zulip/examples/list-subscriptions index e17ac85..e46b41e 100755 --- a/zulip/examples/list-subscriptions +++ b/zulip/examples/list-subscriptions @@ -22,8 +22,6 @@ # THE SOFTWARE. from __future__ import print_function -import sys -import os import argparse usage = """list-subscriptions --user= --api-key= [options] @@ -34,7 +32,7 @@ Example: list-subscriptions --user=username@example.com --api-key=a0b1c2d3e4f5a6 You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + import zulip parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) diff --git a/zulip/examples/print-events b/zulip/examples/print-events index b4f8f3e..1de7782 100755 --- a/zulip/examples/print-events +++ b/zulip/examples/print-events @@ -22,8 +22,6 @@ # THE SOFTWARE. from __future__ import print_function -import sys -import os import argparse from typing import Any, Dict @@ -36,7 +34,7 @@ Example: print-events --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8d9 You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + import zulip parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) diff --git a/zulip/examples/print-messages b/zulip/examples/print-messages index 4f734eb..3cf24d5 100755 --- a/zulip/examples/print-messages +++ b/zulip/examples/print-messages @@ -22,8 +22,6 @@ # THE SOFTWARE. from __future__ import print_function -import sys -import os import argparse from typing import Any, Dict @@ -36,7 +34,7 @@ Example: print-messages --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8 You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + import zulip parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) diff --git a/zulip/examples/recent-messages b/zulip/examples/recent-messages index b7df950..d854dc5 100755 --- a/zulip/examples/recent-messages +++ b/zulip/examples/recent-messages @@ -22,8 +22,6 @@ # THE SOFTWARE. from __future__ import print_function -import sys -import os import json import argparse @@ -35,7 +33,7 @@ Example: recent-messages --count=101 --user=username@example.com --api-key=a0b1c You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) + import zulip parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) diff --git a/zulip/examples/send-message b/zulip/examples/send-message index 1e8f4b0..082a195 100755 --- a/zulip/examples/send-message +++ b/zulip/examples/send-message @@ -22,9 +22,6 @@ # THE SOFTWARE. from __future__ import print_function -import sys -import os -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import argparse import zulip diff --git a/zulip/examples/subscribe b/zulip/examples/subscribe index d7cf954..15254a5 100755 --- a/zulip/examples/subscribe +++ b/zulip/examples/subscribe @@ -23,7 +23,6 @@ from __future__ import print_function import sys -import os import argparse usage = """subscribe --user= --api-key= [options] --streams= @@ -35,7 +34,7 @@ Examples: subscribe --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0 You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + import zulip parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) diff --git a/zulip/examples/unsubscribe b/zulip/examples/unsubscribe index 030b559..c128b26 100755 --- a/zulip/examples/unsubscribe +++ b/zulip/examples/unsubscribe @@ -23,7 +23,6 @@ from __future__ import print_function import sys -import os import argparse usage = """unsubscribe --user= --api-key= [options] --streams= @@ -35,7 +34,7 @@ Examples: unsubscribe --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8d9 You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + import zulip parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) diff --git a/zulip/examples/upload-file b/zulip/examples/upload-file index a6cb36c..a8024e5 100755 --- a/zulip/examples/upload-file +++ b/zulip/examples/upload-file @@ -22,12 +22,9 @@ # THE SOFTWARE. from __future__ import print_function -import importlib -import sys import argparse from six.moves import StringIO as _StringIO -sys.path.insert(0, './api') from typing import IO import zulip