On Jan 14, 12:47 pm, _sc_ <tooth...@swbell.net> wrote:
> this will apply to a finite subset of subscribers
>
>     * you must have bash
>     * you must have python
>     * your python must have BeautifulSoup
>     * you must want a slick way to get the latest netrw
>
> and i know there are already scripts to update wide swaths
> of plugins, but i had such fun writing this, and it *just
> worked* -- i just had to share
>
> in your ~/bin path, place:
>
> <cfnn>
> #!/bin/bash
> #  check for new netrw
> date '+%d %b %Y  %H:%M  %a'
> mv="v`grep '^" Version' ~/.vim/autoload/netrw.vim | awk '{ print $3 }'`"
> echo "my netrw version is $mv"
> cv=`~/py/cfnn`
> echo "charles version is $cv"
> if [ $mv == $cv ]; then
>     echo 'no netrw upgrade available'
> else
>     echo 'a netrw upgrade is coming your way'
>     mv -v ~/.vim/netrw.vba ~/.vim/netrw_save_path/netrw.vba_save_$mv
>     wgethttp://mysite.verizon.net/astronaut/vim/vbafiles/netrw.vba.gz
>     gunzip netrw.vba.gz
>     mv -v netrw.vba ~/.vim
>     gvim ~/.vim/netrw.vba
> fi
> dsh 27
> </cfnn>
>
> a diversion, but to use this you'll also want 'dsh' on your
> ~/bin path:
>
> <dsh>
> #!/usr/bin/python
> from sys import argv
> if len(argv) < 2:
>     ds = 60
> else:
>     ds = int(argv[1])
> s = "-" * ds
> print "%s" % s
> </dsh>
>
> and the real magic happens on my ~/py path:
>
> <cfnn>
> #!/usr/bin/python
> import httplib2
> from BeautifulSoup import BeautifulSoup
> collections_soup = BeautifulSoup()
> url = "http://mysite.verizon.net/astronaut/vim/index.html";
> page = httplib2.Http(cache="/home/scott/.netrwcache").request(url,"GET")
> collections_soup.feed(page[1])
> for collection in collections_soup('a'):
>     if collection['href'] == '#NETRW':
>         print collection.findNext('td').contents[0]
>         break
> </cfnn>
>
> and that's all there is to it
>
> ~/py/cfnn returned 'v135', which is different from 'v135r',
> so the calling ~/bin/cfnn saved the old netrw, grabbed the
> new one, dropped it in place, and dropped me in the middle
> of it ready to :so %
>
> sc

I had to make a couple small changes to the python script "cfnn", but
otherwise your system works like a champ.  Thanks very much.  Here's
the diff I used.

[...@oriental 617 ~]$ diff /tmp/cfnn py/cfnn
1c1
< #!/usr/bin/python
---
> #!/usr/bin/env python
4c4
< collections_soup = BeautifulSoup()
---
> #collections_soup = BeautifulSoup()
6,7c6,7
< page = httplib2.Http(cache="/home/scott/.netrwcache").request
(url,"GET")
< collections_soup.feed(page[1])
---
> page = httplib2.Http(cache="/home/dlt/.netrwcache").request(url,"GET")
> collections_soup = BeautifulSoup(page[1])
11c11,12
<         break
---
>         break
>
[Exit 1 ]

Derek Tattersall                                  (dtatt...@gmail.com)
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui