[Cvsshell-devel] CVS: cvsshell/src basic_cmds.py,1.12,1.13 configurable_app.py,1.4,1.5 cvs_shell.py,
Status: Beta
Brought to you by:
stefanheimann
|
From: Stefan H. <ste...@us...> - 2002-03-09 10:56:24
|
Update of /cvsroot/cvsshell/cvsshell/src
In directory usw-pr-cvs1:/tmp/cvs-serv24812/src
Modified Files:
basic_cmds.py configurable_app.py cvs_shell.py utils.py
Log Message:
* Added support for pager for long listings
Index: basic_cmds.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/basic_cmds.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** basic_cmds.py 8 Mar 2002 22:31:01 -0000 1.12
--- basic_cmds.py 9 Mar 2002 10:56:20 -0000 1.13
***************
*** 137,141 ****
dir = dirRes.group('dir')
if dir == '.': dir = ''
! l = context['basic_cmds.listing'] = utils.Listing(os.getcwd(),
entries)
context['basic_cmds.dirty_listing'] = 0
--- 137,141 ----
dir = dirRes.group('dir')
if dir == '.': dir = ''
! l = context['basic_cmds.listing'] = utils.Listing(app, os.getcwd(),
entries)
context['basic_cmds.dirty_listing'] = 0
***************
*** 163,167 ****
dir = os.path.dirname(x[1])
entries.append(utils.Entry(dir, name, status))
! l = context['basic_cmds.listing'] = utils.Listing(os.getcwd(),
entries)
context['basic_cmds.dirty_listing'] = 0
--- 163,167 ----
dir = os.path.dirname(x[1])
entries.append(utils.Entry(dir, name, status))
! l = context['basic_cmds.listing'] = utils.Listing(app, os.getcwd(),
entries)
context['basic_cmds.dirty_listing'] = 0
***************
*** 286,290 ****
return e
(rootDir, toDelete) = _applyOnEntryList(rest, context, __doIt)
! toDeleteList = utils.Listing(rootDir, toDelete)
filenames = []
if toDelete:
--- 286,290 ----
return e
(rootDir, toDelete) = _applyOnEntryList(rest, context, __doIt)
! toDeleteList = utils.Listing(app, rootDir, toDelete)
filenames = []
if toDelete:
***************
*** 477,481 ****
app.printErr(noListingErrMsg)
else:
! listing.printEntries(app.output)
if _isDirtyListing(context):
app.printMsg("Listing may be out-of-date. " \
--- 477,481 ----
app.printErr(noListingErrMsg)
else:
! listing.printEntries()
if _isDirtyListing(context):
app.printMsg("Listing may be out-of-date. " \
***************
*** 587,590 ****
--- 587,603 ----
context['basic_cmds.defaultOptions'] = defOpts
context['basic_cmds.defaultGlobalOptions'] = defGlobOpts
+
+
+ def parseConfigSection(lines, context):
+ app = context['APP']
+ splitRE = re.compile(r'\s*=\s*')
+ for x in lines:
+ n = x[0]
+ l = splitRE.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
Index: configurable_app.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/configurable_app.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** configurable_app.py 8 Mar 2002 22:31:01 -0000 1.4
--- configurable_app.py 9 Mar 2002 10:56:20 -0000 1.5
***************
*** 107,111 ****
# helper methods
########################################
!
def _getFun(self, fun):
"""Returns the function that is given by `fun'. If `fun' is a
--- 107,111 ----
# helper methods
########################################
!
def _getFun(self, fun):
"""Returns the function that is given by `fun'. If `fun' is a
Index: cvs_shell.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/cvs_shell.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** cvs_shell.py 8 Mar 2002 22:31:01 -0000 1.10
--- cvs_shell.py 9 Mar 2002 10:56:20 -0000 1.11
***************
*** 20,24 ****
###############################################################################
! import os, sys, re, types
from configurable_app import SyntaxError
from interactive_app import InteractiveApp
--- 20,24 ----
###############################################################################
! import os, sys, re, string, types
from configurable_app import SyntaxError
from interactive_app import InteractiveApp
***************
*** 45,51 ****
('h',"Print this help message")])
self.CVS_ROOT_FILE = os.path.join('CVS', 'Root')
- self.cvsRoot = None
- self.cvsRootAutoUpdate = 0
- self.showFullPrompt = 0
self.cmdRegex = re.compile(r"""
^\s* # matches leading whitespace
--- 45,48 ----
***************
*** 56,59 ****
--- 53,60 ----
)? # options are optional
""", re.VERBOSE)
+ self.cvsRoot = None
+ self.cvsRootAutoUpdate = 0
+ self.showFullPrompt = 0
+ self.configMap = {}
self.readCommandFile()
self.readConfigFile()
***************
*** 111,117 ****
--- 112,120 ----
return fun(cmdName, cmdOpts, self.CONTEXT)
+
def run(self): # FIXME: why must I redefine run here?
InteractiveApp.run(self)
+
_cvsChangeCmdRE = re.compile(r"""\s+
(ad(d)?|new|ci|com(mit)?|delete|remove)
***************
*** 124,128 ****
app.shell('%s %s' % (name, opts))
!
if __name__ == '__main__':
app = CvsShell()
--- 127,151 ----
app.shell('%s %s' % (name, opts))
!
! def more(self, lines=None, str=None, numlines=24):
! if lines is not None:
! str = string.join(lines, '')
! elif str is not None:
! lines = str.split('\n')
! else:
! raise AppError, \
! "Illegal argument: One of lines or str must be given"
! if len(lines) <= numlines or not self.configMap.has_key('pager'):
! self.printMsg(str)
! else:
! pager = self.configMap['pager']
! try:
! os.popen(pager, 'w').write(str)
! except IOError: pass
! except OSError, msg:
! self.printMsg(str)
! self.printErr("Error invoking pager: %s" % str(msg))
!
!
if __name__ == '__main__':
app = CvsShell()
Index: utils.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/utils.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** utils.py 8 Mar 2002 22:31:01 -0000 1.6
--- utils.py 9 Mar 2002 10:56:20 -0000 1.7
***************
*** 31,35 ****
class Listing:
! def __init__(self, rootDir, entries):
self.rootDir = rootDir
self.entries = entries
--- 31,36 ----
class Listing:
! def __init__(self, app, rootDir, entries):
! self.app = app
self.rootDir = rootDir
self.entries = entries
***************
*** 50,56 ****
self.entries.sort(__EntrySorter(self.sortOrder).cmp)
! def printEntries(self, output):
if not self.entries:
! output.write('No entries available.\n')
return
max = 0
--- 51,57 ----
self.entries.sort(__EntrySorter(self.sortOrder).cmp)
! def printEntries(self):
if not self.entries:
! self.app.printMsg('No entries available.\n')
return
max = 0
***************
*** 61,71 ****
oldDir = None
id = 0
for e in self.entries:
newDir = e.dir
if oldDir != newDir:
! output.write("%s:\n" % newDir)
! output.write(formatStr % (id, e.status, e.name))
id += 1
oldDir = newDir
##############################
--- 62,74 ----
oldDir = None
id = 0
+ lines = []
for e in self.entries:
newDir = e.dir
if oldDir != newDir:
! lines.append("%s:\n" % newDir)
! lines.append(formatStr % (id, e.status, e.name))
id += 1
oldDir = newDir
+ self.app.more(lines)
##############################
|