summaryrefslogtreecommitdiffstats
path: root/netaddr/cli.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 17:45:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 17:45:09 +0000
commitda1a8f12d7a38f67f3f464aaaffa851f929ae4ea (patch)
tree677688f3aeab7f324f266d106770165708522c2c /netaddr/cli.py
parentInitial commit. (diff)
downloadpython-netaddr-upstream/0.10.1.tar.xz
python-netaddr-upstream/0.10.1.zip
Adding upstream version 0.10.1.upstream/0.10.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xnetaddr/cli.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/netaddr/cli.py b/netaddr/cli.py
new file mode 100755
index 0000000..c97eab9
--- /dev/null
+++ b/netaddr/cli.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+#-----------------------------------------------------------------------------
+# Copyright (c) 2008 by David P. D. Moss. All rights reserved.
+#
+# Released under the BSD license. See the LICENSE file for details.
+#-----------------------------------------------------------------------------
+"""an interactive shell for the netaddr library"""
+
+import os
+import sys
+import netaddr
+from netaddr import *
+
+# aliases to save some typing ...
+from netaddr import IPAddress as IP, IPNetwork as CIDR
+from netaddr import EUI as MAC
+
+def main():
+ argv = sys.argv[1:]
+
+ banner = "\nnetaddr shell %s - %s\n" % (netaddr.__version__, __doc__)
+ exit_msg = "\nShare and enjoy!"
+ rc_override = None
+
+ try:
+ try:
+ # ipython >= 0.11
+ from IPython.terminal.embed import InteractiveShellEmbed
+ ipshell = InteractiveShellEmbed(banner1=banner, exit_msg=exit_msg)
+ except ImportError:
+ # ipython < 0.11
+ from IPython.Shell import IPShellEmbed
+ ipshell = IPShellEmbed(argv, banner, exit_msg, rc_override)
+ except ImportError:
+ sys.stderr.write('IPython (http://ipython.scipy.org/) not found!\n')
+ sys.exit(1)
+
+ ipshell()
+
+
+if __name__ == '__main__':
+ main()