-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmavencentral.py
More file actions
33 lines (23 loc) · 791 Bytes
/
Copy pathmavencentral.py
File metadata and controls
33 lines (23 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
__author__ = 'eveliotc'
__license__ = 'See LICENSE'
import sys
# sigh not using requests to minimize deps and simplify this little scrypt
import urllib
import urllib2
import json
from common import json_to_obj
def maven_central_search(query):
base_url = u'http://search.maven.org/solrsearch/select?wt=json&q=%s'
url = base_url % urllib.quote_plus(query)
parsed_json = json.load(urllib2.urlopen(url))
root = json_to_obj(parsed_json)
docs = root.response.docs
s_docs = sorted(docs, key=lambda doc: doc['latestVersion'], reverse=True)
suggestions = root.spellcheck.suggestions
return (s_docs, suggestions)
def main(args):
print maven_central_search(' '.join(args))
pass
if __name__ == '__main__':
main(sys.argv[1:])