From 8730c03848616652664f9aa88b95309632004e45 Mon Sep 17 00:00:00 2001
From: Gael Pasgrimaud
Date: Mon, 23 May 2011 22:25:54 +0200
Subject: add a pypi command with autocompletion
---
pypi.js | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
create mode 100644 pypi.js
(limited to 'pypi.js')
diff --git a/pypi.js b/pypi.js
new file mode 100644
index 0000000..ff19eb8
--- /dev/null
+++ b/pypi.js
@@ -0,0 +1,80 @@
+var PLUGIN_INFO =
+
+pypi
+Add a pypi command
+gawel
+1.1
+MPL 1.1/GPL 2.0/LGPL 2.1
+2.0pre
+2.0
+https://github.com/gawel/vimperator-plugins/raw/master/pypi.js
+
+;
+
+liberator.plugins.pypi = (function(){
+
+var Pypi = {
+ packages: [],
+ init_packages: function() {
+ var req = new XMLHttpRequest();
+ req.onreadystatechange = function() {
+ if (req.readyState == 4) {
+ var lines = req.responseText.split('\n');
+ for (var i=0; i')[1].split('<')[0]);
+ }
+ liberator.echo('Pypi packages list is up to date');
+ }
+ }
+ req.open("GET", "http://pypi.python.org/simple/", false);
+ req.send(null);
+ setTimeout(Pypi.init_packages, 600000);
+ }
+}
+
+setTimeout(Pypi.init_packages, 1000);
+
+commands.addUserCommand(["pypi"], "pypi search",
+ function(args){
+ var doc = window.content.document;
+ if (!args.length) {
+ doc.location.href = 'http://pypi.python.org/pypi';
+ }
+ var filter = args[0];
+ var packages = plugins.pypi.packages;
+ for (var i=0; i