Update of /cvsroot/modeling/ProjectModeling/Modeling/scripts
In directory sc8-pr-cvs1:/tmp/cvs-serv28351/scripts
Modified Files:
mdl_generate_python_code.py
Log Message:
Refactored ModelMasons: ModelMason and PyModelMason are now clearer
than they used to be. See PyModelMason for an example of use.
Fixed: bug #710817
Index: mdl_generate_python_code.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/scripts/mdl_generate_python_code.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** mdl_generate_python_code.py 20 Feb 2003 22:14:40 -0000 1.2
--- mdl_generate_python_code.py 20 Apr 2003 14:16:41 -0000 1.3
***************
*** 56,60 ****
def build_python_code(model, rootPath=None, typeOfCode='python',
! verbose_mode=0, overwrite=0):
"""
Builds the python-code templates for the supplied model
--- 56,60 ----
def build_python_code(model, rootPath=None, typeOfCode='python',
! verbose_mode=0):
"""
Builds the python-code templates for the supplied model
***************
*** 69,81 ****
future dev. will probably include generation of zope products.
- overwrite -- when set to false (the default), it makes the building
- process abort if the ModelMason.productBaseDirectory() already exists.
- Please note that only the productBaseDirectory() is checked for
- existence ; if the directory exists but does not contain any of the
- files that are to be generated, the process will be aborted as well.
-
- When set to true, the building process will ignore already existing
- files and it will OVERWRITE them, so please be careful!
-
verbose_mode -- if set to true, the building process logs some
informational message onto sys.stderr while building the files. Default
--- 69,72 ----
***************
*** 94,102 ****
mason = PyModelMason(model, rootPath, verbose_mode=verbose_mode)
- if not overwrite:
- import os
- if os.path.exists(mason.productBaseDirectory()):
- raise TargetDirectoryAlreadyExists, 'Error: Target directory %s exists. Aborted'%mason.productBaseDirectory()
-
mason.build()
--- 85,88 ----
***************
*** 116,136 ****
--------
-h --help gives this help
! -v --verbose verbose mode
!
! --overwrite-existing-files overwrites any existing files -- USE WITH CARE!
! There is no short option, this is intended: a
! typo would otherwise too easily overwrite
! valuable code.
!
! Important note:
!
! The building process will immediately abort if the target directory exists
! (except if option --overwrite-existing-files is given). However and despite
! the name of the option, the building process does not look for files it is
! about to create. The decision is simpler: if the target directory already
! exists, the build process is stopped, even if the files it contains would
! not be overriden by the code-generation process (and even if this directory
! is empty!) --for the curious, this is due to the lack of such a feature in
! Modeling.ModelMasons package and it has been added to the TODO list.
--- 102,107 ----
--------
-h --help gives this help
! -v --verbose verbose mode (default)
! -q --quiet quiet mode
***************
*** 139,157 ****
# Global variables
! verbose=0
def main(args):
me=args[0]
try: options, args = getopt.getopt(sys.argv[1:],
! 'hv',
! ["help", "verbose",
! "overwrite-existing-files"])
except: usage(me); return 1
global verbose
- overwrite=0
for k, v in options:
if k in ('-h', '--help'): usage(me); return 0
if k in ('-v', '--verbose'): verbose=1; continue
- if k=='--overwrite-existing-files': overwrite=1; continue
if len(args) not in (1,2): usage(me) ; return 1
--- 110,126 ----
# Global variables
! verbose=1
def main(args):
me=args[0]
try: options, args = getopt.getopt(sys.argv[1:],
! 'hqv',
! ["help", "quiet", "verbose"])
except: usage(me); return 1
global verbose
for k, v in options:
if k in ('-h', '--help'): usage(me); return 0
+ if k in ('-q', '--quiet'): verbose=0; continue
if k in ('-v', '--verbose'): verbose=1; continue
if len(args) not in (1,2): usage(me) ; return 1
***************
*** 173,177 ****
model=ms.models()[0]
try:
! build_python_code(model, rootPath, verbose_mode=verbose, overwrite=overwrite)
except TargetDirectoryAlreadyExists, exc:
sys.stderr.write(str(sys.exc_info()[1])+'\n')
--- 142,146 ----
model=ms.models()[0]
try:
! build_python_code(model, rootPath, verbose_mode=verbose)
except TargetDirectoryAlreadyExists, exc:
sys.stderr.write(str(sys.exc_info()[1])+'\n')
|