Last active
August 29, 2015 13:56
-
-
Save janpipek/9110501 to your computer and use it in GitHub Desktop.
Load python package in sublime (version 2/3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import sys | |
| import pkgutil | |
| import os | |
| if len(sys.argv) != 2: | |
| print("Usage: sublime_load.py <package-name>") | |
| else: | |
| package = sys.argv[1] | |
| loader = pkgutil.find_loader(package) | |
| if loader: | |
| if sys.version_info[0] == 2: | |
| filename = loader.filename | |
| else: | |
| filename = loader.path | |
| if filename.endswith("__init__.py"): | |
| filename = os.path.dirname(filename) | |
| os.system("sublime_text " + filename) | |
| else: | |
| print("Package could not be found") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment