I took the latest release (1.15b) and added the ability to silence the
generated code. It is simple and required very little change. It may
require a little support if more stdout.write statements are added, but
given the way the generated code is structured it most likely is good
for a long time. Anyway I attached the patch and hope that it makes it
into all subsequent releases so that I do not have to keep updating
generateDS.py.

On Wed, 2008-11-19 at 15:24 -0800, Al Niessner wrote:
> I have used generateDS to parse some Schema and now I have the output
> files. I then read a string from the somewhere that is the XML for the
> schema. I call parseString (s) and it echoes the string out to me. How
> do I tell generateDS.py to be silent during parsing?
> 
> The code being generated with generateDS.py is being done in a script
> and I do not want to have to write some goofy utility (I will if I have
> to) to comment out all of the sys.out.write statements. I can see the
> use of the echo for debugging, but it is annoying at best when things
> are working well and it is trying to parse a thousand messages a second.
> I looked through generateDS.py twice looking for a flag that would let
> me turn it off but I did not see it. So, please let me know if I missed
> something or if I have to write a silly tool to clean up the code
> generated with generateDS.py.
> 
> --
> Al Niessner
> 818.354.0859
> 
> All opinions stated above are mine and do not necessarily reflect those
> of JPL or NASA.
> 
> --------
> |  dS  | >= 0
> --------
> 
> 
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> generateds-users mailing list
> generateds-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/generateds-users
-- 
Al Niessner
818.354.0859

All opinions stated above are mine and do not necessarily reflect those
of JPL or NASA.

--------
|  dS  | >= 0
--------

*** generateDS.py.orig	2008-11-21 14:36:05.000000000 -0800
--- generateDS.py	2008-11-25 11:20:43.813316262 -0800
***************
*** 33,38 ****
--- 33,41 ----
                               default, generateDS.py will insert content
                               from files referenced by <include ... />
                               elements into the XML Schema to be processed.
+     --silence                Normally, the code generated with generateDS
+                              echoes the information being parsed. To prevent
+                              the echo from occurring, use the --silence switch.
  """
  
  
***************
*** 4159,4171 ****
  def main():
      global Force, GenerateProperties, SubclassSuffix, RootElement, \
          ValidatorBodiesBasePath, UseOldGetterSetter, \
!         UserMethodsPath, XsdNameSpace
      args = sys.argv[1:]
      try:
          options, args = getopt.getopt(args, 'hfyo:s:p:a:b:mu:',
              ['help', 'subclass-suffix=', 'root-element=', 'super=',
              'validator-bodies=', 'use-old-getter-setter',
!             'user-methods=', 'no-process-includes',
              ])
      except getopt.GetoptError, exp:
          usage()
--- 4162,4176 ----
  def main():
      global Force, GenerateProperties, SubclassSuffix, RootElement, \
          ValidatorBodiesBasePath, UseOldGetterSetter, \
!         UserMethodsPath, XsdNameSpace, \
!         TEMPLATE_MAIN, TEMPLATE_SUBCLASS_FOOTER
!     outputText = True
      args = sys.argv[1:]
      try:
          options, args = getopt.getopt(args, 'hfyo:s:p:a:b:mu:',
              ['help', 'subclass-suffix=', 'root-element=', 'super=',
              'validator-bodies=', 'use-old-getter-setter',
!             'user-methods=', 'no-process-includes', 'silence',
              ])
      except getopt.GetoptError, exp:
          usage()
***************
*** 4207,4212 ****
--- 4212,4220 ----
              UserMethodsPath = option[1]
          elif option[0] == '--no-process-includes':
              processIncludes = 0
+         elif option[0] == "--silence":
+             outputText = False
+             
      XsdNameSpace = nameSpace
      set_type_constants(nameSpace)
      if behaviorFilename and not subclassFilename:
***************
*** 4215,4220 ****
--- 4223,4236 ----
      if len(args) != 1:
          usage()
      xschemaFileName = args[0]
+ 
+     if not outputText:
+         TEMPLATE_MAIN = TEMPLATE_MAIN.replace ("sys.stdout.write",
+                                                "#sys.stdout.write")
+         TEMPLATE_SUBCLASS_FOOTER.replace ("sys.stdout.write",
+                                           "#sys.stdout.write")
+         pass
+     
      parseAndGenerate(outFilename, subclassFilename, prefix,
          xschemaFileName, behaviorFilename, 
          processIncludes, superModule=superModule)
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to