[Cvsshell-devel] CVS: cvsshell/src configurable_app.py,1.6,1.7 cvs_shell.py,1.18,1.19 parsing.py,1.1
Status: Beta
Brought to you by:
stefanheimann
|
From: Stefan H. <ste...@us...> - 2002-03-15 09:43:54
|
Update of /cvsroot/cvsshell/cvsshell/src
In directory usw-pr-cvs1:/tmp/cvs-serv21417/src
Modified Files:
configurable_app.py cvs_shell.py parsing.py
Log Message:
Added support for
* automatic deletion of ~/.cvsshellrc if requested with the -u option
* aliases for arbitrary commands
Index: configurable_app.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/configurable_app.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** configurable_app.py 10 Mar 2002 23:13:59 -0000 1.6
--- configurable_app.py 15 Mar 2002 09:43:51 -0000 1.7
***************
*** 43,51 ****
! def setConfigFile(self, filename, default=None):
"""Set the name of the configfile. If the configfile
does not exist and no default is given, a empty config
file is created. Otherwise, default is copied as new
! config file."""
self.configFile = filename
if not os.access(self.configFile, os.R_OK):
--- 43,58 ----
! def setConfigFile(self, filename, default=None, forceDefault=0):
"""Set the name of the configfile. If the configfile
does not exist and no default is given, a empty config
file is created. Otherwise, default is copied as new
! config file. If forceDefault is true, the default configfile
! will be used no matter if filename exists or not."""
! if(forceDefault):
! try:
! os.unlink(filename)
! self.printVMsg("Configuration file %s removed." % filename)
! except OSError, msg:
! self.printVMsg(msg)
self.configFile = filename
if not os.access(self.configFile, os.R_OK):
Index: cvs_shell.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/cvs_shell.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** cvs_shell.py 15 Mar 2002 00:47:08 -0000 1.18
--- cvs_shell.py 15 Mar 2002 09:43:51 -0000 1.19
***************
*** 45,55 ****
self.setCopyright(COPYRIGHT)
self.setBugAddress(BUG_ADDRESS)
etcDir = os.path.join(self.THIS_DIR, '..', 'etc')
self.setConfigFile(os.path.join(self.HOME,'.cvsshellrc'),
! os.path.join(etcDir, 'default-cvsshellrc'))
self.setCommandFile(os.path.join(etcDir, 'cvsshell.ini'))
self.setHistoryFile(os.path.join(self.HOME,'.cvsshell_history'))
- self.initOptions([('v',"Print some extra information"),
- ('h',"Print this help message")])
self.CVS_ROOT_FILE = os.path.join('CVS', 'Root')
self.cmdRegex = re.compile(r"""
--- 45,56 ----
self.setCopyright(COPYRIGHT)
self.setBugAddress(BUG_ADDRESS)
+ self.initOptions([('v',"Print some extra information"),
+ ('h',"Print this help message"),
+ ('u',"Delete ~/.cvsshellrc and replace it with the default configuration file")])
etcDir = os.path.join(self.THIS_DIR, '..', 'etc')
self.setConfigFile(os.path.join(self.HOME,'.cvsshellrc'),
! os.path.join(etcDir, 'default-cvsshellrc'), forceDefault=self.getopt('-u'))
self.setCommandFile(os.path.join(etcDir, 'cvsshell.ini'))
self.setHistoryFile(os.path.join(self.HOME,'.cvsshell_history'))
self.CVS_ROOT_FILE = os.path.join('CVS', 'Root')
self.cmdRegex = re.compile(r"""
***************
*** 74,77 ****
--- 75,79 ----
self.cvsRootAliases = {}
self.configMap = {}
+ self.aliasesMap = {}
self.cmdToDefOpts = {}
self.cmdToDefGlobOpts = {}
***************
*** 102,106 ****
dir = 'ERROR'
if not self.showFullPrompt:
! # make to prompt match on one line
extraChars = 6
maxLineWidth = 79
--- 104,108 ----
dir = 'ERROR'
if not self.showFullPrompt:
! # make the prompt match on one line
extraChars = 6
maxLineWidth = 79
***************
*** 129,132 ****
--- 131,135 ----
return None
cmdName = result.group('name')
+ cmdName = self.aliasesMap.get(cmdName, cmdName)
cmdOpts = result.group('opts')
if cmdOpts == None:
Index: parsing.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/parsing.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** parsing.py 11 Mar 2002 09:50:41 -0000 1.1
--- parsing.py 15 Mar 2002 09:43:51 -0000 1.2
***************
*** 35,38 ****
--- 35,39 ----
else:
roots[l[0]] = l[1]
+ app.printVMsg("Aliases for cvsroots:\n%s" % `app.getCvsRootAliases()`)
***************
*** 76,85 ****
def parseConfigSection(lines, app):
for x in lines:
n = x[0]
! l = app.keyValSplitRE.split(x[1])
if len(l) != 2:
app.printErr("Syntax error in configuration file (line %d)." % n)
continue
key, value = l
! app.configMap[key] = value
--- 77,95 ----
def parseConfigSection(lines, app):
+ _parseKeyValSection(lines, app, app.getConfigMap())
+ app.printVMsg("Config options:\n%s" % `app.getConfigMap()`)
+
+ def parseAliasesSection(lines, app):
+ _parseKeyValSection(lines, app, app.getAliasesMap())
+ app.printVMsg("Aliases:\n%s" % `app.getAliasesMap()`)
+
+ def _parseKeyValSection(lines, app, map):
for x in lines:
n = x[0]
! l = app.keyValSplitRE.split(x[1], 1)
! print l
if len(l) != 2:
app.printErr("Syntax error in configuration file (line %d)." % n)
continue
key, value = l
! map[key] = value
|