I am so sorry about this. The first patch I sent was incomplete. I have
attached two patches to this email.

patch_A.txt should be used if you have NOT applied the patch I sent in
the previous email.

patch_B.txt is the incremental changes from the previous email and
should be used if you HAVE applied that first patch.

Again, I am very sorry about sending out the incomplete patch. Mistakes
like this just add confusion to a world where the entropy is very high
already.

On Tue, 2008-11-25 at 11:31 -0800, Al Niessner wrote:
> 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
> --------
> 
-- 
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-26 08:41:38.593818227 -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,4242 ----
      if len(args) != 1:
          usage()
      xschemaFileName = args[0]
+ 
+     if not outputText:
+         def makeSilent (t):
+             t = t.replace ("sys.stdout.write",
+                            "#sys.stdout.write")
+             t = t.replace ("rootObj.export(sys.stdout",
+                            "#rootObj.export(sys.stdout")
+             t = t.replace ("rootObj.exportLiteral(sys.stdout",
+                            "#rootObj.exportLiteral(sys.stdout")
+             return t
+         TEMPLATE_MAIN = makeSilent (TEMPLATE_MAIN)
+         TEMPLATE_SUBCLASS_FOOTER = makeSilent (TEMPLATE_SUBCLASS_FOOTER)
+         pass
+     
      parseAndGenerate(outFilename, subclassFilename, prefix,
          xschemaFileName, behaviorFilename, 
          processIncludes, superModule=superModule)
*** generateDS.py.p1	2008-11-25 15:57:38.149608800 -0800
--- generateDS.py	2008-11-26 08:41:38.593818227 -0800
***************
*** 4225,4234 ****
      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,
--- 4225,4240 ----
      xschemaFileName = args[0]
  
      if not outputText:
!         def makeSilent (t):
!             t = t.replace ("sys.stdout.write",
!                            "#sys.stdout.write")
!             t = t.replace ("rootObj.export(sys.stdout",
!                            "#rootObj.export(sys.stdout")
!             t = t.replace ("rootObj.exportLiteral(sys.stdout",
!                            "#rootObj.exportLiteral(sys.stdout")
!             return t
!         TEMPLATE_MAIN = makeSilent (TEMPLATE_MAIN)
!         TEMPLATE_SUBCLASS_FOOTER = makeSilent (TEMPLATE_SUBCLASS_FOOTER)
          pass
      
      parseAndGenerate(outFilename, subclassFilename, prefix,
-------------------------------------------------------------------------
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