[Cvsshell-devel] CVS: cvsshell/src parsing.py,NONE,1.1
Status: Beta
Brought to you by:
stefanheimann
From: Stefan H. <ste...@us...> - 2002-03-11 09:50:44
|
Update of /cvsroot/cvsshell/cvsshell/src In directory usw-pr-cvs1:/tmp/cvs-serv31258/src Added Files: parsing.py Log Message: initial checkin --- NEW FILE: parsing.py --- ############################################################################### # This file is part of CvsShell # # CvsShell is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # CvsShell is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with CvsShell; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Copyright 2002 by Stefan Heimann # Website: http://cvsshell.sourceforge.net/ ############################################################################### import getopt ############################## # Parsing functions ############################## def parseCvsRootSection(lines, app): roots = app.getCvsRootAliases() 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) else: roots[l[0]] = l[1] def parseInitCmdsSection(lines, app): for x in lines: cmd = x[1] app.evalCommand(cmd) def parseDefaultOptions(lines, app): for x in lines: n = x[0] l = app.keysValSplitRE.split(x[1]) if len(l) < 2: app.printErr("Syntax error in configuration file (line %d)." % n) continue value = l[-1] for y in l[:-1]: try: if y != 'ALL': (globOpt, opt, du1, du2) = app.parseArgs(value, app.getCmdToAllowedOpts().get(y,'')) app.cmdToDefOpts[y] = opt app.cmdToDefGlobOpts[y] = globOpt else: (globOpt, opt, du1, du2) = app.parseArgs(value) app.defOpts = opt app.defGlobOpts = globOpt except getopt.GetoptError, msg: app.printErr("Bad format for default options for command "\ "`%s': %s: %s" % (y, value, str(msg))) app.printVMsg("Default global options:\n" \ + `app.cmdToDefGlobOpts` + \ "\nDefault options:\n" \ + `app.cmdToDefOpts` + \ "\nDefault global options for all cmds:\n" \ + `app.defOpts` + \ "\nDefault options for all cmds:\n" \ + `app.defGlobOpts`) 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 |