This repository has been archived by the owner on Jan 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
- Loading branch information
1 parent
806db5d
commit 3baac8f
Showing
91 changed files
with
25,623 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"*": { | ||
">=3000": [ | ||
"requests" | ||
"parse" | ||
] | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"dependencies": [], "description": "Pipenv goodness.", "url": "http://damnwidget.github.io/anaconda/", "version": "2.1.25", "platforms": ["*"], "sublime_text": ">=3000"} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import sublime | ||
import sublime_plugin | ||
|
||
|
||
|
||
from .vendor import requests | ||
from .vendor import parse | ||
|
||
TEMPLATE = "<a href='{0}'>{0}</a><br/>" | ||
|
||
def plugin_loaded(): | ||
pass | ||
|
||
|
||
class pipenv_install(sublime_plugin.WindowCommand): | ||
"""docstring for PipenvMenu""" | ||
|
||
def __init__(self, text): | ||
super(pipenv_install, self).__init__(text) | ||
|
||
# def is_enabled(self): | ||
# return True | ||
|
||
def description(self): | ||
return "Pipenv is awesome" | ||
|
||
def yield_packages(self): | ||
r = requests.get('https://pypi.python.org/simple/') | ||
for result in parse.findall(TEMPLATE, r.text): | ||
yield result[0] | ||
|
||
|
||
def run(self): | ||
for package in self.yield_packages(): | ||
print(package) | ||
|
||
|
||
class ListPackagesCommand(sublime_plugin.WindowCommand): | ||
|
||
""" | ||
A command that shows a list of all installed packages in the quick panel | ||
""" | ||
|
||
def run(self): | ||
ListPackagesThread(self.window).start() | ||
|
||
|
||
class ListPackagesThread(threading.Thread, ExistingPackagesCommand): | ||
|
||
""" | ||
A thread to prevent the listing of existing packages from freezing the UI | ||
""" | ||
|
||
def __init__(self, window, filter_function=None): | ||
""" | ||
:param window: | ||
An instance of :class:`sublime.Window` that represents the Sublime | ||
Text window to show the list of installed packages in. | ||
:param filter_function: | ||
A callable to filter packages for display. This function gets | ||
called for each package in the list with a three-element list | ||
as returned by :meth:`ExistingPackagesCommand.make_package_list`: | ||
0 - package name | ||
1 - package description | ||
2 - [action] installed version; package url | ||
If the function returns a true value, the package is listed, | ||
otherwise it is discarded. If `None`, no filtering is performed. | ||
""" | ||
|
||
self.window = window | ||
self.filter_function = filter_function | ||
self.manager = PackageManager() | ||
threading.Thread.__init__(self) | ||
|
||
def run(self): | ||
self.package_list = self.make_package_list() | ||
if self.filter_function: | ||
self.package_list = list(filter(self.filter_function, self.package_list)) | ||
|
||
def show_panel(): | ||
if not self.package_list: | ||
sublime.message_dialog(text.format( | ||
u''' | ||
Package Control | ||
There are no packages to list | ||
''' | ||
)) | ||
return | ||
show_quick_panel(self.window, self.package_list, self.on_done) | ||
sublime.set_timeout(show_panel, 10) | ||
|
||
def on_done(self, picked): | ||
""" | ||
Quick panel user selection handler - opens the homepage for any | ||
selected package in the user's browser | ||
:param picked: | ||
An integer of the 0-based package name index from the presented | ||
list. -1 means the user cancelled. | ||
""" | ||
|
||
if picked == -1: | ||
return | ||
package_name = self.package_list[picked][0] | ||
|
||
def open_dir(): | ||
package_dir = self.manager.get_package_dir(package_name) | ||
package_file = None | ||
if not os.path.exists(package_dir): | ||
package_dir = self.manager.settings['installed_packages_path'] | ||
package_file = package_name + '.sublime-package' | ||
if not os.path.exists(os.path.join(package_dir, package_file)): | ||
package_file = None | ||
|
||
open_dir_file = {'dir': package_dir} | ||
if package_file is not None: | ||
open_dir_file['file'] = package_file | ||
|
||
self.window.run_command('open_dir', open_dir_file) | ||
sublime.set_timeout(open_dir, 10) | ||
|
||
|
||
if sublime.version() < '3000': | ||
plugin_loaded() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ | ||
{ "caption": "Pipenv: Install Package", "command": "pipenv_install" }, | ||
{ "caption": "Pipenv: Uninstall Package", "command": "PipenvUninstall" } | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"build_systems": | ||
[ | ||
{ | ||
"name": "Update Pipenv Packages", | ||
"target": "PipenvUpdate" | ||
} | ||
] | ||
} |
Empty file.
Oops, something went wrong.