diff --git a/PluginDirectories/1/pypi.bundle/info.json b/PluginDirectories/1/pypi.bundle/info.json index 1b399529..02c0548e 100644 --- a/PluginDirectories/1/pypi.bundle/info.json +++ b/PluginDirectories/1/pypi.bundle/info.json @@ -5,5 +5,7 @@ "description": "Search at PyPI - the Python Package Index", "description_de": "Suche auf PyPI - dem Python Package Index", "examples": ["pypi setuptools"], - "categories": ["Developer"] + "categories": ["Developer"], + "creator_name": "Yusuke Miyazaki", + "creator_url": "http://www.ymyzk.com" } diff --git a/PluginDirectories/1/pypi.bundle/options.json b/PluginDirectories/1/pypi.bundle/options.json new file mode 100644 index 00000000..3b04fc4e --- /dev/null +++ b/PluginDirectories/1/pypi.bundle/options.json @@ -0,0 +1,14 @@ +{ + "options": [ + { + "text": "Server:", + "type": "dropdown", + "key": "server", + "options": [ + {"text": "https://pypi.python.org (CheeseShop)", "value": "cheeseshop"}, + {"text": "https://warehouse.python.org (Warehouse)", "value": "warehouse"}, + {"text": "http://localhost:3141 (devpi)", "value": "devpi"} + ] + } + ] +} diff --git a/PluginDirectories/1/pypi.bundle/plugin.py b/PluginDirectories/1/pypi.bundle/plugin.py index 5bc1ae4b..df9f22de 100644 --- a/PluginDirectories/1/pypi.bundle/plugin.py +++ b/PluginDirectories/1/pypi.bundle/plugin.py @@ -1,12 +1,31 @@ +import json import urllib + def results(parsed, original_query): if '~query' not in parsed: return query = parsed['~query'] - url = 'https://pypi.python.org/pypi?:action=search&term={0}'.format( - urllib.quote_plus(query)) + + # Query is too short + if len(query) < 2: + return + + # Load server settings + with open('preferences.json') as f: + settings = json.load(f) + server = settings.get('server', None) + + # Set server URL + if server == 'warehouse': + url_template = 'https://warehouse.python.org/search/project/?q={0}' + elif server == 'devpi': + url_template = 'http://localhost:3141/+search?query={0}' + else: + url_template = 'https://pypi.python.org/pypi?:action=search&term={0}' + + url = url_template.format(urllib.quote_plus(query)) html = """