[Modeling-cvs] ProjectModeling/Modeling/scripts mdl_generate_python_code.py,1.4,1.5
Status: Abandoned
Brought to you by:
sbigaret
|
From: <sbi...@us...> - 2003-05-26 15:44:53
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/scripts
In directory sc8-pr-cvs1:/tmp/cvs-serv21164/scripts
Modified Files:
mdl_generate_python_code.py
Log Message:
Merged changes from brch-0_9pre6-1-ModelMasons_base_generation_scheme to trunk
Index: mdl_generate_python_code.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/scripts/mdl_generate_python_code.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** mdl_generate_python_code.py 20 Apr 2003 16:10:41 -0000 1.4
--- mdl_generate_python_code.py 26 May 2003 15:44:49 -0000 1.5
***************
*** 55,60 ****
del tb
! def build_python_code(model, generation_scheme,
! rootPath=None, typeOfCode='python', verbose_mode=0):
"""
Builds the python-code templates for the supplied model
--- 55,60 ----
del tb
! def build_python_code(model, generation_scheme, rootPath=None,
! typeOfCode='python', verbose_mode=0, fake_mode=0):
"""
Builds the python-code templates for the supplied model
***************
*** 75,78 ****
--- 75,80 ----
is false.
+ fake_mode -- if true, do not create or change any file, just report what
+ would be done
Raises TargetDirectoryAlreadyExists if 'overwrite' is false and the target
***************
*** 86,90 ****
from Modeling.ModelMasons.PyModelMason import PyModelMason
mason = PyModelMason(model, rootPath, verbose_mode=verbose_mode,
! generation_scheme=generation_scheme)
mason.build()
--- 88,93 ----
from Modeling.ModelMasons.PyModelMason import PyModelMason
mason = PyModelMason(model, rootPath, verbose_mode=verbose_mode,
! generation_scheme=generation_scheme,
! fake_mode=fake_mode)
mason.build()
***************
*** 104,113 ****
General options:
----------------
! -h --help gives this help
! -v --verbose verbose mode (default)
! -q --quiet quiet mode
Generation options:
-------------------
-B --base-generation-scheme use the 'base' scheme
-C --compact-generation-scheme use the 'compact' scheme (default)
--- 107,120 ----
General options:
----------------
! -h --help gives this help
! -n --dry-run do not create or change any file, just report what would
! be done
! -q --quiet quiet mode
! -v --verbose verbose mode (default)
Generation options:
-------------------
+ For an explanation on generation schemes, see below
+
-B --base-generation-scheme use the 'base' scheme
-C --compact-generation-scheme use the 'compact' scheme (default)
***************
*** 116,120 ****
--generation_scheme=<scheme> use <scheme> as the generation scheme
(either 'base' or 'compact')
!
""" % prgName
sys.stderr.write(_usage)
--- 123,141 ----
--generation_scheme=<scheme> use <scheme> as the generation scheme
(either 'base' or 'compact')
!
! 'compact' scheme: puts all generated file in the same directory (the package
! for the model). When re-generating the files, only the two files
! containing the model are overwritten, every other file that already exists
! is never overwritten
!
! 'base' scheme: adds a sub-module 'MDL' within the generated package. All files
! within MDL/ are ALWAYS overwritten when the python code is regenerated,
! while others (in the root package) are never overwritten if they exist.
! This is probably the one you want to use if your model changes often.
!
! Note: this can be used if and only if there is no entity sharing the same
! module with one of its (direct or indirect) subentities. If this is
! not the case, the generation will raise and indicate the problem.
!
""" % prgName
sys.stderr.write(_usage)
***************
*** 126,137 ****
me=args[0]
try: options, args = getopt.getopt(sys.argv[1:],
! 'BCg:hqv',
["help", "quiet", "verbose",
"generation_scheme=",
"compact-generation-scheme",
! "base-generation-scheme"])
except: usage(me); return 1
global verbose
generation_scheme='compact'
for k, v in options:
if k in ('-h', '--help'): usage(me); return 0
--- 147,160 ----
me=args[0]
try: options, args = getopt.getopt(sys.argv[1:],
! 'BCg:hnqv',
["help", "quiet", "verbose",
"generation_scheme=",
"compact-generation-scheme",
! "base-generation-scheme",
! "dry-run"])
except: usage(me); return 1
global verbose
generation_scheme='compact'
+ fake_mode=0
for k, v in options:
if k in ('-h', '--help'): usage(me); return 0
***************
*** 140,143 ****
--- 163,167 ----
if k in ('-C', '--compact-generation-scheme'): generation_scheme='compact'; continue
if k in ('-B', '--base-generation-scheme'): generation_scheme='base'; continue
+ if k in ('-n', '--dry-run'): fake_mode=1; continue
if len(args) not in (1,2): usage(me) ; return 1
***************
*** 159,163 ****
model=ms.models()[0]
try:
! build_python_code(model, generation_scheme, rootPath, verbose_mode=verbose)
except TargetDirectoryAlreadyExists, exc:
sys.stderr.write(str(sys.exc_info()[1])+'\n')
--- 183,188 ----
model=ms.models()[0]
try:
! build_python_code(model, generation_scheme, rootPath, verbose_mode=verbose,
! fake_mode=fake_mode)
except TargetDirectoryAlreadyExists, exc:
sys.stderr.write(str(sys.exc_info()[1])+'\n')
|