#!/usr/bin/python # From the command line to your favorite browser. # (c) GPL 2005 Claudio Saavedra # Use under your own risk. import sys import re import os # The path to your local cvs cvs_path = '/home/claudio/cvs/' # A dictionary with your local cvs copies and the URL to the viewcvs or # similar interface. cvs_uris = { 'gnome2': 'http://cvs.gnome.org/viewcvs/', 'gnome2head' : 'http://cvs.gnome.org/viewcvs/', 'gaim': 'http://cvs.sourceforge.net/viewcvs.py/gaim/'} # The call to your favorite browser. browser_call = 'epiphany -n ' if len(sys.argv) > 1: if (os.path.exists(sys.argv[1])): file_path = os.path.abspath(sys.argv[1]) rel_path = re.split (cvs_path, file_path) [1] tokens = re.split ('/', rel_path, 1) try: url_base = cvs_uris[tokens[0]] except KeyError: print "error: CVS path not found. Add it to the dictionary first." sys.exit (1) url_to_open = url_base + tokens[1] print "Opening " + url_to_open + " ..." os.system (browser_call + url_to_open) else: print "Can't find " + sys.argv[1] + " ..." else: print "You must supply a filename or path to browse."