|
From: <cm...@us...> - 2006-06-05 23:43:48
|
Revision: 1235 Author: cmoad Date: 2006-06-05 06:15:44 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/pywebsvcs/?rev=1235&view=rev Log Message: ----------- forgot to add optional args to wsdl2dispatch Modified Paths: -------------- trunk/zsi/ZSI/generate/commands.py Modified: trunk/zsi/ZSI/generate/commands.py =================================================================== --- trunk/zsi/ZSI/generate/commands.py 2006-06-04 22:04:29 UTC (rev 1234) +++ trunk/zsi/ZSI/generate/commands.py 2006-06-05 13:15:44 UTC (rev 1235) @@ -217,7 +217,7 @@ fd.close() -def wsdl2dispatch(): +def wsdl2dispatch(args=None): """ wsdl2dispatch @@ -250,7 +250,11 @@ op.add_option("-s", "--simple-naming", action="store_true", dest="simple_naming", default=False, help="Simplify generated naming.") - (options, args) = op.parse_args() + + if args is None: + (options, args) = op.parse_args() + else: + (options, args) = op.parse_args(args) if options.simple_naming: ServiceDescription.server_module_suffix = '_interface' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eo...@us...> - 2007-01-11 17:27:34
|
Revision: 1316
http://svn.sourceforge.net/pywebsvcs/?rev=1316&view=rev
Author: eolson
Date: 2007-01-11 09:27:28 -0800 (Thu, 11 Jan 2007)
Log Message:
-----------
Fix import name conflict with "ServiceDescription" for wsdl2py and
wsdl2dispatch. Perhaps a more thorough naming fix is needed.
This fixes a bug in the --simple-naming option's use of a
separate messages file (and the import of it).
Modified Paths:
--------------
trunk/zsi/ZSI/generate/commands.py
Modified: trunk/zsi/ZSI/generate/commands.py
===================================================================
--- trunk/zsi/ZSI/generate/commands.py 2007-01-05 22:14:35 UTC (rev 1315)
+++ trunk/zsi/ZSI/generate/commands.py 2007-01-11 17:27:28 UTC (rev 1316)
@@ -8,7 +8,7 @@
from operator import xor
import ZSI
from ConfigParser import ConfigParser
-from ZSI.generate.wsdl2python import WriteServiceModule, ServiceDescription
+from ZSI.generate.wsdl2python import WriteServiceModule, ServiceDescription as wsdl2pyServiceDescription
from ZSI.wstools import WSDLTools, XMLSchema
from ZSI.wstools.logging import setBasicLoggerDEBUG
from ZSI.generate import containers, utility
@@ -190,7 +190,7 @@
# Use a different client suffix
# WriteServiceModule.client_module_suffix = "_client"
# Write messages definitions to a separate file.
- ServiceDescription.separate_messages = True
+ wsdl2pyServiceDescription.separate_messages = True
# Use more simple type and element class names
containers.SetTypeNameFunc( lambda n: '%s_' %(NC_to_CN(n)) )
containers.SetElementNameFunc( lambda n: '%s' %(NC_to_CN(n)) )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-14 19:48:25
|
Revision: 1396
http://svn.sourceforge.net/pywebsvcs/?rev=1396&view=rev
Author: boverhof
Date: 2007-06-14 12:48:27 -0700 (Thu, 14 Jun 2007)
Log Message:
-----------
M ZSI/generate/commands.py
-- changed behavior of "wsdl2py" a bit, if you call it with "args" then it will
return the files names which ServiceProxy needs. If it's called via command-line
tool, "args" is None and it will return None.
From: sh...@me...
Subject: [Pywebsvcs-talk] wsdl2py return code
Date: June 7, 2007 8:51:16 PM PDT
To: pyw...@li...
In svn head wsdl2py utility on successful run returns 1
(for example runing on wsdl from zsi/test/wsdl2py/wsdl)
-- shell --
$wsdl2py -o /tmp/ Racing.wsdl
[u'/tmp/Racing_client.py', u'/tmp/Racing_types.py', u'Racing_server.py']
$echo $?
1
-- shell --
It was introduced in svn revision 1378 in chunk (sorry for git diff)
diff --git a/zsi/ZSI/generate/commands.py b/zsi/ZSI/generate/commands.py
index 40afb07..4a854f3 100644
--- a/zsi/ZSI/generate/commands.py
+++ b/zsi/ZSI/generate/commands.py
@@ -179,11 +179,11 @@ respectively.
if isinstance(wsdl, XMLSchema.XMLSchema):
wsdl.location = location
- _wsdl2py(options, wsdl)
- return
+ return _wsdl2py(options, wsdl)
- _wsdl2py(options, wsdl)
- _wsdl2dispatch(options, wsdl)
+ modules = _wsdl2py(options, wsdl)
+ modules.append(_wsdl2dispatch(options, wsdl))
+ return modules
Link to diff in sf repo
http://svn.sourceforge.net/viewvc/pywebsvcs/trunk/zsi/ZSI/generate/commands.py?view=diff&r1=1377&r2=1378
This behaviour breaks Makefile rules depending on zero return code of
successful wsdl2py invocation.
Pavel
Revision Links:
--------------
http://svn.sourceforge.net/pywebsvcs/?rev=1378&view=rev
Modified Paths:
--------------
trunk/zsi/ZSI/generate/commands.py
Modified: trunk/zsi/ZSI/generate/commands.py
===================================================================
--- trunk/zsi/ZSI/generate/commands.py 2007-06-14 06:49:35 UTC (rev 1395)
+++ trunk/zsi/ZSI/generate/commands.py 2007-06-14 19:48:27 UTC (rev 1396)
@@ -5,6 +5,8 @@
############################################################################
import exceptions, sys, optparse, os, warnings, traceback
+from os.path import isfile, join, split
+
#from operator import xor
import ZSI
from ConfigParser import ConfigParser
@@ -18,6 +20,7 @@
from ZSI.generate.wsdl2dispatch import WSAServiceModuleWriter as ServiceDescriptionWSA
from ZSI.generate.wsdl2dispatch import DelAuthWSAServiceModuleWriter as DelAuthServiceDescriptionWSA
+
warnings.filterwarnings('ignore', '', exceptions.UserWarning)
def SetDebugCallback(option, opt, value, parser, *args, **kwargs):
setBasicLoggerDEBUG()
@@ -25,7 +28,9 @@
def SetPyclassMetaclass(option, opt, value, parser, *args, **kwargs):
"""set up pyclass metaclass for complexTypes"""
- from ZSI.generate.containers import ServiceHeaderContainer, TypecodeContainerBase, TypesHeaderContainer
+ from ZSI.generate.containers import ServiceHeaderContainer,\
+ TypecodeContainerBase, TypesHeaderContainer
+
TypecodeContainerBase.metaclass = kwargs['metaclass']
TypesHeaderContainer.imports.append(\
'from %(module)s import %(metaclass)s' %kwargs
@@ -45,45 +50,31 @@
TypecodeContainerBase.lazy = True
-def formatSchemaObject(fname, schemaObj):
- """ In the case of a 'schema only' generation (-s) this creates
- a fake wsdl object that will function w/in the adapters
- and allow the generator to do what it needs to do.
- """
-
- class fake:
- pass
- f = fake()
-
- if fname.rfind('/'):
- tmp = fname[fname.rfind('/') + 1 :].split('.')
- else:
- tmp = fname.split('.')
-
- f.name = '_'.join(tmp)
- f.types = { schemaObj.targetNamespace : schemaObj }
-
- return f
-
def wsdl2py(args=None):
- """Utility for automatically generating client/service interface code from a wsdl
-definition, and a set of classes representing element declarations and
-type definitions. By default invoking this script produces three files, each
-named after the wsdl definition name, in the current working directory.
-These files will end with '_client.py', '_types.py', '_server.py'
-respectively.
+ """Utility for automatically generating client/service interface code from
+ a wsdl definition, and a set of classes representing element declarations
+ and type definitions. By default invoking this script produces three files,
+ each named after the wsdl definition name, in the current working directory.
+
+ Generated Modules Suffix:
+ _client.py -- client locator, rpc proxy port, messages
+ _types.py -- typecodes representing
+ _server.py -- server-side bindings
+
+ Parameters:
+ args -- optional can provide arguments, rather than parsing
+ command-line.
+
+ return:
+ Default behavior is to return None, if args are provided then
+ return names of the generated files.
+
"""
op = optparse.OptionParser(usage="USAGE: %wsdl2py [options] WSDL",
description=wsdl2py.__doc__)
# Basic options
- #op.add_option("-f", "--file",
- # action="store", dest="file", default=None, type="string",
- # help="FILE to load wsdl from")
- #op.add_option("-u", "--url",
- # action="store", dest="url", default=None, type="string",
- # help="URL to load wsdl from")
op.add_option("-x", "--schema",
action="store_true", dest="schema", default=False,
help="process just the schema from an xsd file [no services]")
@@ -117,56 +108,34 @@
'metaclass':'pyclass_type'},
help="generate a twisted.web client/server, dependencies python>=2.4, Twisted>=2.0.0, TwistedWeb>=0.5.0")
- # Extended generation options
- #op.add_option("-e", "--extended",
- # action="store_true", dest="extended", default=False,
- # help="Do Extended code generation.")
- #op.add_option("-z", "--aname",
- # action="store", dest="aname", default=None, type="string",
- # help="pass in a function for attribute name creation")
- #op.add_option("-t", "--types",
- # action="store", dest="types", default=None, type="string",
- # help="file to load types from")
op.add_option("-o", "--output-dir",
action="store", dest="output_dir", default=".", type="string",
help="save files in directory")
+
op.add_option("-s", "--simple-naming",
action="store_true", dest="simple_naming", default=False,
help="map element names directly to python attributes")
- #op.add_option("-c", "--clientClassSuffix",
- # action="store", dest="clientClassSuffix", default=None, type="string",
- # help="Suffix to use for service client class (default \"SOAP\")")
- #op.add_option("-m", "--pyclassMapModule",
- # action="store", dest="pyclassMapModule", default=None, type="string",
- # help="Python file that maps external python classes to a schema type. The classes are used as the \"pyclass\" for that type. The module should contain a dict() called mapping in the format: mapping = {schemaTypeName:(moduleName.py,className) }")
-
- if args is None:
+
+ is_cmdline = args is None
+ if is_cmdline:
(options, args) = op.parse_args()
else:
(options, args) = op.parse_args(args)
- #if not xor(options.file is None, options.url is None):
- # print 'Must specify either --file or --url option'
- # sys.exit(os.EX_USAGE)
- #location = options.file
- #if options.url is not None:
- # location = options.url
if len(args) != 1:
print>>sys.stderr, 'Expecting a file/url as argument (WSDL).'
sys.exit(os.EX_USAGE)
location = args[0]
-
if options.schema is True:
reader = XMLSchema.SchemaReader(base_url=location)
else:
reader = WSDLTools.WSDLReader()
load = reader.loadFromFile
- if not os.path.isfile(location):
+ if not isfile(location):
load = reader.loadFromURL
- wsdl = None
try:
wsdl = load(location)
except Exception, e:
@@ -180,104 +149,23 @@
wsdl.location = location
return _wsdl2py(options, wsdl)
- modules = _wsdl2py(options, wsdl)
- modules.append(_wsdl2dispatch(options, wsdl))
- return modules
+ files = _wsdl2py(options, wsdl)
+ files.append(_wsdl2dispatch(options, wsdl))
+ if is_cmdline:
+ return
+ return files
-def _wsdl2py(options, wsdl):
- if options.simple_naming:
- # Use a different client suffix
- # WriteServiceModule.client_module_suffix = "_client"
- # Write messages definitions to a separate file.
- #wsdl2pyServiceDescription.separate_messages = True
- # Use more simple type and element class names
- containers.SetTypeNameFunc( lambda n: '%s_' %(NC_to_CN(n)) )
- containers.SetElementNameFunc( lambda n: '%s' %(NC_to_CN(n)) )
- # Don't add "_" to the attribute name (remove when --aname works well)
- containers.ContainerBase.func_aname = lambda instnc,n: TextProtect(str(n))
- # write out the modules with their names rather than their number.
- utility.namespace_name = lambda cls, ns: utility.Namespace2ModuleName(ns)
- #if options.clientClassSuffix:
- # from ZSI.generate.containers import ServiceContainerBase
- # ServiceContainerBase.clientClassSuffix = options.clientClassSuffix
-
- if options.schema is True:
- wsdl = formatSchemaObject(wsdl.location, wsdl)
-
- #if options.aname is not None:
- # args = options.aname.rsplit('.',1)
- # assert len(args) == 2, 'expecting module.function'
- # # The following exec causes a syntax error.
- # #exec('from %s import %s as FUNC' %(args[0],args[1]))
- # assert callable(FUNC),\
- # '%s must be a callable method with one string parameter' %options.aname
- # from ZSI.generate.containers import TypecodeContainerBase
- # TypecodeContainerBase.func_aname = staticmethod(FUNC)
-
- #if options.pyclassMapModule != None:
- # mod = __import__(options.pyclassMapModule)
- # components = options.pyclassMapModule.split('.')
- # for comp in components[1:]:
- # mod = getattr(mod, comp)
- # extPyClasses = mod.mapping
- #else:
- # extPyClasses = None
-
- #wsm = WriteServiceModule(wsdl, addressing=options.address, do_extended=options.extended, extPyClasses=extPyClasses)
- wsm = WriteServiceModule(wsdl, addressing=options.address)
-# if options.types != None:
-# wsm.setTypesModuleName(options.types)
-
- files = []
- append = files.append
- if options.schema is False:
- client_mod = wsm.getClientModuleName()
- client_file = os.path.join(options.output_dir, '%s.py' %client_mod)
- append(client_file)
- fd = open(client_file, 'w+')
-
- # simple naming writes the messages to a separate file
- if not options.simple_naming:
- wsm.writeClient(fd)
- else: # provide a separate file to store messages to.
- msg_fd = open( os.path.join(options.output_dir, '%s.py' %wsm.getMessagesModuleName()), 'w+' )
- wsm.writeClient(fd, msg_fd=msg_fd)
- msg_fd.close()
- fd.close()
-
-
- types_mod = wsm.getTypesModuleName()
- types_file = os.path.join(options.output_dir, '%s.py' %types_mod)
- append(types_file)
- fd = open( os.path.join(options.output_dir, '%s.py' %types_mod), 'w+' )
- wsm.writeTypes(fd)
- fd.close()
- return files
-
-
def wsdl2dispatch(args=None):
- """
- wsdl2dispatch
-
+ """Deprecated: wsdl2py now generates everything
A utility for automatically generating service skeleton code from a wsdl
definition.
"""
-
op = optparse.OptionParser()
-# op.add_option("-f", "--file",
-# action="store", dest="file", default=None, type="string",
-# help="file to load wsdl from")
-# op.add_option("-u", "--url",
-# action="store", dest="url", default=None, type="string",
-# help="URL to load wsdl from")
op.add_option("-a", "--address",
action="store_true", dest="address", default=False,
help="ws-addressing support, must include WS-Addressing schema.")
-# op.add_option("-e", "--extended",
-# action="store_true", dest="extended", default=False,
-# help="Extended code generation.")
op.add_option("-d", "--debug",
action="callback", callback=SetDebugCallback,
help="debug output")
@@ -301,14 +189,60 @@
sys.exit(os.EX_USAGE)
reader = WSDLTools.WSDLReader()
- if os.path.isfile(args[0]):
- wsdl = reader.loadFromFile(args[0])
+ if isfile(args[0]):
+ _wsdl2dispatch(options, reader.loadFromFile(args[0]))
+ return
+
+ _wsdl2dispatch(options, reader.loadFromURL(args[0]))
+
+
+def _wsdl2py(options, wsdl):
+ if options.simple_naming:
+ # Use a different client suffix
+ # WriteServiceModule.client_module_suffix = "_client"
+ # Write messages definitions to a separate file.
+ #wsdl2pyServiceDescription.separate_messages = True
+ # Use more simple type and element class names
+ containers.SetTypeNameFunc( lambda n: '%s_' %(NC_to_CN(n)) )
+ containers.SetElementNameFunc( lambda n: '%s' %(NC_to_CN(n)) )
+ # Don't add "_" to the attribute name (remove when --aname works well)
+ containers.ContainerBase.func_aname = lambda instnc,n: TextProtect(str(n))
+ # write out the modules with their names rather than their number.
+ utility.namespace_name = lambda cls, ns: utility.Namespace2ModuleName(ns)
+
+ files = []
+ append = files.append
+ if isinstance(wsdl, XMLSchema.XMLSchema):
+ wsm = WriteServiceModule(_XMLSchemaAdapter(wsdl.location, wsdl),
+ addressing=options.address)
else:
- wsdl = reader.loadFromURL(args[0])
+ wsm = WriteServiceModule(wsdl, addressing=options.address)
+ client_mod = wsm.getClientModuleName()
+ client_file = join(options.output_dir, '%s.py' %client_mod)
+ append(client_file)
+ fd = open(client_file, 'w+')
- return _wsdl2dispatch(options, wsdl)
+ # simple naming writes the messages to a separate file
+ if not options.simple_naming:
+ wsm.writeClient(fd)
+ else: # provide a separate file to store messages to.
+ msg_fd = open(join(options.output_dir,
+ '%s.py' %(wsm.getMessagesModuleName()), 'w+' ))
+ wsm.writeClient(fd, msg_fd=msg_fd)
+ msg_fd.close()
+
+ fd.close()
+ types_mod = wsm.getTypesModuleName()
+ types_file = join(options.output_dir, '%s.py' %types_mod)
+ append(types_file)
+ fd = open( join(options.output_dir, '%s.py' %types_mod), 'w+' )
+ wsm.writeTypes(fd)
+ fd.close()
+ return files
+
+
def _wsdl2dispatch(options, wsdl):
if options.simple_naming:
ServiceDescription.server_module_suffix = '_interface'
@@ -317,23 +251,30 @@
# use module names rather than their number.
utility.namespace_name = lambda cls, ns: utility.Namespace2ModuleName(ns)
-
- ss = None
if options.address is True:
-# if options.extended:
-# ss = DelAuthServiceDescriptionWSA(do_extended=options.extended)
-# else:
- ss = ServiceDescriptionWSA()
+ ss = ServiceDescriptionWSA()
else:
-# if options.extended:
-# ss = DelAuthServiceDescription(do_extended=options.extended)
-# else:
- ss = ServiceDescription()
+ ss = ServiceDescription()
ss.fromWSDL(wsdl)
- module_name = ss.getServiceModuleName()+'.py'
- fd = open( os.path.join(options.output_dir, module_name), 'w+')
+ file_name = ss.getServiceModuleName()+'.py'
+ fd = open( join(options.output_dir, file_name), 'w+')
ss.write(fd)
-
- return module_name
fd.close()
+
+ return file_name
+
+
+class _XMLSchemaAdapter:
+ """Adapts an obj XMLSchema.XMLSchema to look like a WSDLTools.WSDL,
+ just setting a couple attributes code expects to see.
+ """
+ def __init__(self, location, schema):
+ """Parameters:
+ location -- base location, file path
+ schema -- XMLSchema instance
+ """
+ self.name = '_'.join(split(location)[-1].split('.'))
+ self.types = {schema.targetNamespace:schema}
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-07-07 00:33:45
|
Revision: 1403
http://svn.sourceforge.net/pywebsvcs/?rev=1403&view=rev
Author: boverhof
Date: 2007-07-06 17:33:48 -0700 (Fri, 06 Jul 2007)
Log Message:
-----------
M ZSI/generate/commands.py
-- adding a pydoc option to generate API docs.
Modified Paths:
--------------
trunk/zsi/ZSI/generate/commands.py
Modified: trunk/zsi/ZSI/generate/commands.py
===================================================================
--- trunk/zsi/ZSI/generate/commands.py 2007-07-06 22:51:32 UTC (rev 1402)
+++ trunk/zsi/ZSI/generate/commands.py 2007-07-07 00:33:48 UTC (rev 1403)
@@ -114,6 +114,11 @@
action="store_true", dest="simple_naming", default=False,
help="map element names directly to python attributes")
+ op.add_option("-p", "--pydoc",
+ action="store", dest="pydoc", default=False,
+ help="top-level directory for pydoc documentation.")
+
+
is_cmdline = args is None
if is_cmdline:
(options, args) = op.parse_args()
@@ -149,6 +154,10 @@
files = _wsdl2py(options, wsdl)
files.append(_wsdl2dispatch(options, wsdl))
+
+ if getattr(options, 'pydoc', False):
+ _writepydoc(os.path.join('docs', 'API'), *files)
+
if is_cmdline:
return
@@ -266,4 +275,257 @@
self.name = '_'.join(split(location)[-1].split('.'))
self.types = {schema.targetNamespace:schema}
+
+
+
+import os, pydoc, sys, warnings, inspect
+import os.path
+from distutils import log
+from distutils.command.build_py import build_py
+from distutils.util import convert_path
+
+#from setuptools import find_packages
+#from setuptools import Command
+from ZSI.schema import ElementDeclaration, TypeDefinition
+#from pyGridWare.utility.generate.Modules import NR
+#from pyGridWare.utility.generate.Modules import CLIENT, TYPES
+
+#def find_packages_modules(where='.'):
+# #pack,mod,mod_file
+# """Return a list all Python packages found within directory 'where'
+# """
+# out = []
+# stack=[(convert_path(where), '')]
+# while stack:
+# where,prefix = stack.pop(0)
+# for name in os.listdir(where):
+# fn = os.path.join(where,name)
+# #if (os.path.isdir(fn) and
+# # os.path.isfile(os.path.join(fn,'__init__.py'))
+# #):
+# # out.append(prefix+name); stack.append((fn,prefix+name+'.'))
+# if (os.path.isdir(fn) and
+# os.path.isfile(os.path.join(fn,'__init__.py'))):
+# stack.append((fn,prefix+name+'.'))
+# continue
+#
+# if name == '__init__.py' or not name.endswith('.py'):
+# continue
+#
+# out.append((prefix, name.split('.py')[0]))
+#
+# return out
+
+
+def _writedoc(doc, thing, forceload=0):
+ """Write HTML documentation to a file in the current directory.
+ """
+ try:
+ object, name = pydoc.resolve(thing, forceload)
+ page = pydoc.html.page(pydoc.describe(object), pydoc.html.document(object, name))
+ fname = os.path.join(doc, name + '.html')
+ file = open(fname, 'w')
+ file.write(page)
+ file.close()
+ except (ImportError, pydoc.ErrorDuringImport), value:
+ traceback.print_exc(sys.stderr)
+ else:
+ return name + '.html'
+
+
+def _writeclientdoc(doc, thing, forceload=0):
+ """Write HTML documentation to a file in the current directory.
+ """
+ docmodule = pydoc.HTMLDoc.docmodule
+ def strongarm(self, object, name=None, mod=None, *ignored):
+ result = docmodule(self, object, name, mod, *ignored)
+
+ # Grab all the aliases to pyclasses and create links.
+ nonmembers = []
+ push = nonmembers.append
+ for k,v in inspect.getmembers(object, inspect.isclass):
+ if inspect.getmodule(v) is not object and getattr(v,'typecode',None) is not None:
+ push('<a href="%s.html">%s</a>: pyclass alias<br/>' %(v.__name__,k))
+
+ result += self.bigsection('Aliases', '#ffffff', '#eeaa77', ''.join(nonmembers))
+ return result
+
+ pydoc.HTMLDoc.docmodule = strongarm
+ try:
+ object, name = pydoc.resolve(thing, forceload)
+ page = pydoc.html.page(pydoc.describe(object), pydoc.html.document(object, name))
+ name = os.path.join(doc, name + '.html')
+ file = open(name, 'w')
+ file.write(page)
+ file.close()
+ except (ImportError, pydoc.ErrorDuringImport), value:
+ log.debug(str(value))
+
+ pydoc.HTMLDoc.docmodule = docmodule
+
+def _writetypesdoc(doc, thing, forceload=0):
+ """Write HTML documentation to a file in the current directory.
+ """
+ try:
+ object, name = pydoc.resolve(thing, forceload)
+ name = os.path.join(doc, name + '.html')
+ except (ImportError, pydoc.ErrorDuringImport), value:
+ log.debug(str(value))
+ return
+
+ # inner classes
+ cdict = {}
+ fdict = {}
+ elements_dict = {}
+ types_dict = {}
+ for kname,klass in inspect.getmembers(thing, inspect.isclass):
+ if thing is not inspect.getmodule(klass):
+ continue
+
+ cdict[kname] = inspect.getmembers(klass, inspect.isclass)
+ for iname,iklass in cdict[kname]:
+ key = (kname,iname)
+ fdict[key] = _writedoc(doc, iklass)
+ if issubclass(iklass, ElementDeclaration):
+
+ try:
+ typecode = iklass()
+ except (AttributeError,RuntimeError), ex:
+ elements_dict[iname] = _writebrokedoc(doc, ex, iname)
+ continue
+
+ elements_dict[iname] = None
+ if typecode.pyclass is not None:
+ elements_dict[iname] = _writedoc(doc, typecode.pyclass)
+
+ continue
+
+ if issubclass(iklass, TypeDefinition):
+ try:
+ typecode = iklass(None)
+ except (AttributeError,RuntimeError), ex:
+ types_dict[iname] = _writebrokedoc(doc, ex, iname)
+ continue
+
+ types_dict[iname] = None
+ if typecode.pyclass is not None:
+ types_dict[iname] = _writedoc(doc, typecode.pyclass)
+
+ continue
+
+
+ def strongarm(self, object, name=None, mod=None, funcs={}, classes={}, *ignored):
+ """Produce HTML documentation for a class object."""
+ realname = object.__name__
+ name = name or realname
+ bases = object.__bases__
+ object, name = pydoc.resolve(object, forceload)
+ contents = []
+ push = contents.append
+ if name == realname:
+ title = '<a name="%s">class <strong>%s</strong></a>' % (
+ name, realname)
+ else:
+ title = '<strong>%s</strong> = <a name="%s">class %s</a>' % (
+ name, name, realname)
+
+ mdict = {}
+ if bases:
+ parents = []
+ for base in bases:
+ parents.append(self.classlink(base, object.__module__))
+ title = title + '(%s)' % pydoc.join(parents, ', ')
+
+ doc = self.markup(pydoc.getdoc(object), self.preformat, funcs, classes, mdict)
+ doc = doc and '<tt>%s<br> </tt>' % doc
+ for iname,iclass in cdict[name]:
+ fname = fdict[(name,iname)]
+
+ if elements_dict.has_key(iname):
+ push('class <a href="%s">%s</a>: element declaration typecode<br/>'\
+ %(fname,iname))
+ pyclass = elements_dict[iname]
+ if pyclass is not None:
+ push('<ul>instance attributes:')
+ push('<li><a href="%s">pyclass</a>: instances serializable to XML<br/></li>'\
+ %elements_dict[iname])
+ push('</ul>')
+ elif types_dict.has_key(iname):
+ push('class <a href="%s">%s</a>: type definition typecode<br/>' %(fname,iname))
+ pyclass = types_dict[iname]
+ if pyclass is not None:
+ push('<ul>instance attributes:')
+ push('<li><a href="%s">pyclass</a>: instances serializable to XML<br/></li>'\
+ %types_dict[iname])
+ push('</ul>')
+ else:
+ push('class <a href="%s">%s</a>: TODO not sure what this is<br/>' %(fname,iname))
+
+ contents = ''.join(contents)
+ return self.section(title, '#000000', '#ffc8d8', contents, 3, doc)
+
+ doclass = pydoc.HTMLDoc.docclass
+ pydoc.HTMLDoc.docclass = strongarm
+
+ try:
+ page = pydoc.html.page(pydoc.describe(object), pydoc.html.document(object, name))
+ file = open(name, 'w')
+ file.write(page)
+ file.close()
+ except (ImportError, pydoc.ErrorDuringImport), value:
+ log.debug(str(value))
+
+ pydoc.HTMLDoc.docclass = doclass
+
+
+
+def _writebrokedoc(doc, ex, name, forceload=0):
+ try:
+ fname = os.path.join(doc, name + '.html')
+ page = pydoc.html.page(pydoc.describe(ex), pydoc.html.document(str(ex), fname))
+ file = open(fname, 'w')
+ file.write(page)
+ file.close()
+ except (ImportError, pydoc.ErrorDuringImport), value:
+ log.debug(str(value))
+
+ return name + '.html'
+
+def _writepydoc(doc, *args):
+ """create pydoc html pages
+ doc -- destination directory for documents
+ *args -- modules run thru pydoc
+ """
+ ok = True
+ if not os.path.isdir(doc):
+ os.makedirs(doc)
+
+ if os.path.curdir not in sys.path:
+ sys.path.append(os.path.curdir)
+
+ for f in args:
+ if f.startswith('./'): f = f[2:]
+ name = os.path.sep.join(f.strip('.py').split(os.path.sep))
+ try:
+ e = __import__(name)
+ except Exception,ex:
+ raise
+# _writebrokedoc(doc, ex, name)
+# continue
+
+ if name.endswith('_client'):
+ _writeclientdoc(doc, e)
+ continue
+
+ if name.endswith('_types'):
+ _writetypesdoc(doc, e)
+ continue
+
+ try:
+ _writedoc(doc, e)
+ except IndexError,ex:
+ _writebrokedoc(doc, ex, name)
+ continue
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-07-07 00:46:03
|
Revision: 1404
http://svn.sourceforge.net/pywebsvcs/?rev=1404&view=rev
Author: boverhof
Date: 2007-07-06 17:46:05 -0700 (Fri, 06 Jul 2007)
Log Message:
-----------
M ZSI/generate/commands.py
-- store_true not store
Modified Paths:
--------------
trunk/zsi/ZSI/generate/commands.py
Modified: trunk/zsi/ZSI/generate/commands.py
===================================================================
--- trunk/zsi/ZSI/generate/commands.py 2007-07-07 00:33:48 UTC (rev 1403)
+++ trunk/zsi/ZSI/generate/commands.py 2007-07-07 00:46:05 UTC (rev 1404)
@@ -115,7 +115,7 @@
help="map element names directly to python attributes")
op.add_option("-p", "--pydoc",
- action="store", dest="pydoc", default=False,
+ action="store_true", dest="pydoc", default=False,
help="top-level directory for pydoc documentation.")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|