Update of /cvsroot/pywin32/pywin32/AutoDuck
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv25359
Modified Files:
BuildHHP.py Dump2HHC.py InsertExternalOverviews.py TOCToHHK.py
document_object.py makedfromi.py py2d.py
Log Message:
Fix bug 2896861: AutoDuck Py3k port (Sridhar Ratnakumar)
Index: py2d.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/py2d.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** py2d.py 28 Jan 2009 10:47:10 -0000 1.2
--- py2d.py 2 Dec 2009 10:49:35 -0000 1.3
***************
*** 6,9 ****
--- 6,22 ----
return re.sub(r"([^<]*)<([^>]*)>", r"\g<1>\\<\g<2>\\>", s)
+ if sys.version_info[0] >= 3:
+ # Python3 specific code
+ types.ClassType = type
+ Print = __builtins__.__dict__['print']
+ long = int
+ else:
+ # Python2 specific code
+ def Print(value, file=sys.stdout):
+ print >>file, value
+ def next(iter):
+ # Python3's global next() function
+ return iter.next()
+
class DocInfo:
def __init__(self, name, ob):
***************
*** 15,21 ****
def BuildArgInfos(ob):
ret = []
! vars = list(ob.func_code.co_varnames[:ob.func_code.co_argcount])
vars.reverse() # for easier default checking.
! defs = list(ob.func_defaults or [])
for i, n in enumerate(vars):
info = DocInfo(n, ob)
--- 28,34 ----
def BuildArgInfos(ob):
ret = []
! vars = list(ob.__code__.co_varnames[:ob.__code__.co_argcount])
vars.reverse() # for easier default checking.
! defs = list(ob.__defaults__ or [])
for i, n in enumerate(vars):
info = DocInfo(n, ob)
***************
*** 71,75 ****
return ""
g = gen_paras(desc)
! first = g.next()
chunks = [first[0]]
chunks.extend(["// " + l for l in first[1:]])
--- 84,88 ----
return ""
g = gen_paras(desc)
! first = next(g)
chunks = [first[0]]
chunks.extend(["// " + l for l in first[1:]])
***************
*** 102,109 ****
constants.append( (name, ob) )
info = BuildInfo(mod_name, mod)
! print >> fp, "// @module %s|%s" % (mod_name, format_desc(info.desc))
functions = [f for f in functions if should_build_function(f)]
for ob in functions:
! print >> fp, "// @pymeth %s|%s" % (ob.name, ob.short_desc)
for ob in classes:
# only classes with docstrings get printed.
--- 115,122 ----
constants.append( (name, ob) )
info = BuildInfo(mod_name, mod)
! Print("// @module %s|%s" % (mod_name, format_desc(info.desc)), file=fp)
functions = [f for f in functions if should_build_function(f)]
for ob in functions:
! Print("// @pymeth %s|%s" % (ob.name, ob.short_desc), file=fp)
for ob in classes:
# only classes with docstrings get printed.
***************
*** 111,119 ****
continue
ob_name = mod_name + "." + ob.name
! print >> fp, "// @pyclass %s|%s" % (ob.name, ob.short_desc)
for ob in functions:
! print >> fp, "// @pymethod |%s|%s|%s" % (mod_name, ob.name, format_desc(ob.desc))
for ai in BuildArgInfos(ob.ob):
! print >> fp, "// @pyparm |%s|%s|%s" % (ai.name, ai.default, ai.short_desc)
for ob in classes:
--- 124,132 ----
continue
ob_name = mod_name + "." + ob.name
! Print("// @pyclass %s|%s" % (ob.name, ob.short_desc), file=fp)
for ob in functions:
! Print("// @pymethod |%s|%s|%s" % (mod_name, ob.name, format_desc(ob.desc)), file=fp)
for ai in BuildArgInfos(ob.ob):
! Print("// @pyparm |%s|%s|%s" % (ai.name, ai.default, ai.short_desc), file=fp)
for ob in classes:
***************
*** 122,130 ****
continue
ob_name = mod_name + "." + ob.name
! print >> fp, "// @object %s|%s" % (ob_name, format_desc(ob.desc))
func_infos = []
# We need to iter the keys then to a getattr() so the funky descriptor
# things work.
! for n in ob.ob.__dict__.iterkeys():
o = getattr(ob.ob, n)
if isinstance(o, (types.FunctionType, types.MethodType)):
--- 135,143 ----
continue
ob_name = mod_name + "." + ob.name
! Print("// @object %s|%s" % (ob_name, format_desc(ob.desc)), file=fp)
func_infos = []
# We need to iter the keys then to a getattr() so the funky descriptor
# things work.
! for n in ob.ob.__dict__.keys():
o = getattr(ob.ob, n)
if isinstance(o, (types.FunctionType, types.MethodType)):
***************
*** 133,144 ****
func_infos.append(info)
for fi in func_infos:
! print >> fp, "// @pymeth %s|%s" % (fi.name, fi.short_desc)
for fi in func_infos:
! print >> fp, "// @pymethod |%s|%s|%s" % (ob_name, fi.name, format_desc(fi.desc))
if hasattr(fi.ob, 'im_self') and fi.ob.im_self is ob.ob:
! print >> fp, "// @comm This is a @classmethod."
! print >> fp, "// @pymethod |%s|%s|%s" % (ob_name, fi.name, format_desc(fi.desc))
for ai in BuildArgInfos(fi.ob):
! print >> fp, "// @pyparm |%s|%s|%s" % (ai.name, ai.default, ai.short_desc)
for (name, val) in constants:
--- 146,157 ----
func_infos.append(info)
for fi in func_infos:
! Print("// @pymeth %s|%s" % (fi.name, fi.short_desc), file=fp)
for fi in func_infos:
! Print("// @pymethod |%s|%s|%s" % (ob_name, fi.name, format_desc(fi.desc)), file=fp)
if hasattr(fi.ob, 'im_self') and fi.ob.im_self is ob.ob:
! Print("// @comm This is a @classmethod.", file=fp)
! Print("// @pymethod |%s|%s|%s" % (ob_name, fi.name, format_desc(fi.desc)), file=fp)
for ai in BuildArgInfos(fi.ob):
! Print("// @pyparm |%s|%s|%s" % (ai.name, ai.default, ai.short_desc), file=fp)
for (name, val) in constants:
***************
*** 146,156 ****
if type(val) in (int, long):
desc += " (0x%x)" % (val,)
! print >> fp, "// @const %s|%s|%s" % (mod_name, name, desc)
def main(fp, args):
! print >> fp, "// @doc"
for arg in args:
build_module(sys.stdout, arg)
!
if __name__=='__main__':
main(sys.stdout, sys.argv[1:])
--- 159,169 ----
if type(val) in (int, long):
desc += " (0x%x)" % (val,)
! Print("// @const %s|%s|%s" % (mod_name, name, desc), file=fp)
def main(fp, args):
! Print("// @doc", file=fp)
for arg in args:
build_module(sys.stdout, arg)
!
if __name__=='__main__':
main(sys.stdout, sys.argv[1:])
Index: makedfromi.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/makedfromi.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** makedfromi.py 11 Jul 2006 06:58:52 -0000 1.8
--- makedfromi.py 2 Dec 2009 10:49:35 -0000 1.9
***************
*** 7,25 ****
def GetComments(line, lineNo, lines):
# Get the comment from this and continuous lines, if they exist.
! data = string.split(line, "//", 2)
doc = ""
! if len(data)==2: doc=string.strip(data[1])
lineNo = lineNo + 1
while lineNo < len(lines):
line = lines[lineNo]
! data = string.split(line, "//", 2)
if len(data)!=2:
break
! if string.strip(data[0]):
break # Not a continutation!
if data[1].strip().startswith("@"):
# new command
break
! doc = doc + "\n// " + string.strip(data[1])
lineNo = lineNo + 1
# This line doesnt match - step back
--- 7,25 ----
def GetComments(line, lineNo, lines):
# Get the comment from this and continuous lines, if they exist.
! data = line.split("//", 2)
doc = ""
! if len(data)==2: doc=data[1].strip()
lineNo = lineNo + 1
while lineNo < len(lines):
line = lines[lineNo]
! data = line.split("//", 2)
if len(data)!=2:
break
! if data[0].strip():
break # Not a continutation!
if data[1].strip().startswith("@"):
# new command
break
! doc = doc + "\n// " + data[1].strip()
lineNo = lineNo + 1
# This line doesnt match - step back
***************
*** 45,55 ****
try:
if line[:7]=="%module":
! extra = string.split(line, "//")
if len(extra)>1:
! modName = string.strip(extra[0][7:])
modDoc, lineNo = GetComments(line, lineNo, lines)
lineNo += 1
elif line[:7]=="#define" and not bInRawBlock:
! cname = string.split(line)[1]
doc, lineNo = GetComments(line, lineNo, lines)
constants.append((cname, doc))
--- 45,55 ----
try:
if line[:7]=="%module":
! extra = line.split("//")
if len(extra)>1:
! modName = extra[0][7:].strip()
modDoc, lineNo = GetComments(line, lineNo, lines)
lineNo += 1
elif line[:7]=="#define" and not bInRawBlock:
! cname = line.split()[1]
doc, lineNo = GetComments(line, lineNo, lines)
constants.append((cname, doc))
***************
*** 80,84 ****
extra_tags.append("// " + doc + '\n')
except:
! print "Line %d is badly formed - %s" % (lineNo, str(sys.exc_value))
lineNo = lineNo + 1
--- 80,85 ----
extra_tags.append("// " + doc + '\n')
except:
! _, msg, _ = sys.exc_info()
! print("Line %d is badly formed - %s" % (lineNo, msg))
lineNo = lineNo + 1
***************
*** 107,113 ****
outFile.write("\n")
for (meth, extras) in these_methods:
! fields = string.split(meth,'|')
! if len(fields)<>3:
! print "**Error - %s does not have enough fields" % meth
else:
outFile.write("// @pymethod %s|%s|%s|%s\n" % (fields[0],thisModName,fields[1], fields[2]))
--- 108,114 ----
outFile.write("\n")
for (meth, extras) in these_methods:
! fields = meth.split('|')
! if len(fields)!=3:
! print("**Error - %s does not have enough fields" % meth)
else:
outFile.write("// @pymethod %s|%s|%s|%s\n" % (fields[0],thisModName,fields[1], fields[2]))
***************
*** 120,124 ****
outFile.write("\n// @module %s|%s\n" % (thisModName,modDoc))
for (meth, extras) in these_methods:
! fields = string.split(meth,'|')
outFile.write("// @pymeth %s|%s\n" % (fields[1], fields[2]))
chunk_number += 1
--- 121,125 ----
outFile.write("\n// @module %s|%s\n" % (thisModName,modDoc))
for (meth, extras) in these_methods:
! fields = meth.split('|')
outFile.write("// @pymeth %s|%s\n" % (fields[1], fields[2]))
chunk_number += 1
***************
*** 142,149 ****
elif o=='-o':
outName = a
! msg = string.join(args)
! except getopt.error, msg:
! print msg
! print "Usage: %s [-o output_name] [-p com_parent] filename" % sys.argv[0]
return
--- 143,151 ----
elif o=='-o':
outName = a
! msg = ' '.join(args)
! except getopt.error:
! _, msg, _ = sys.exc_info()
! print(msg)
! print("Usage: %s [-o output_name] [-p com_parent] filename" % sys.argv[0])
return
Index: Dump2HHC.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/Dump2HHC.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Dump2HHC.py 11 Sep 2004 07:39:43 -0000 1.6
--- Dump2HHC.py 2 Dec 2009 10:49:35 -0000 1.7
***************
*** 1,4 ****
import os
- import string
import sys
import pprint
--- 1,3 ----
***************
*** 32,36 ****
top.context = "html/" + oi.href
top.type = "topic"
! assert not d.has_key(top.name) and not self.overviewTopics.has_key(top.name), \
"Duplicate named topic detected: " + top.name
d[top.name] = top
--- 31,35 ----
top.context = "html/" + oi.href
top.type = "topic"
! assert not top.name in d and not top.name in self.overviewTopics, \
"Duplicate named topic detected: " + top.name
d[top.name] = top
***************
*** 58,61 ****
--- 57,62 ----
else:
return -1
+ def TopicKey(a):
+ return a.name
def parseCategories():
***************
*** 88,92 ****
# chop
line = line[:-1]
! fields = string.split(line, "\t")
while len(fields) > 0:
assert len(fields) == 3, fields
--- 89,93 ----
# chop
line = line[:-1]
! fields = line.split("\t")
while len(fields) > 0:
assert len(fields) == 3, fields
***************
*** 96,103 ****
line = input.readline()
if line == '':
! raise ValueError, "incomplete topic!"
# chop
line = line[:-1]
! fields = string.split(line, "\t")
assert len(fields) == 2
assert len(fields[0]) == 0
--- 97,104 ----
line = input.readline()
if line == '':
! raise ValueError("incomplete topic!")
# chop
line = line[:-1]
! fields = line.split("\t")
assert len(fields) == 2
assert len(fields[0]) == 0
***************
*** 107,114 ****
line = input.readline()
line = line[:-1]
! fields = string.split(line, "\t")
assert len(fields[0]) == 0 and len(fields[1]) == 0
if line == '':
! raise ValueError, "incomplete topic!"
# Loop over the rest of the properties,
# and add them appropriately. :)
--- 108,115 ----
line = input.readline()
line = line[:-1]
! fields = line.split("\t")
assert len(fields[0]) == 0 and len(fields[1]) == 0
if line == '':
! raise ValueError("incomplete topic!")
# Loop over the rest of the properties,
# and add them appropriately. :)
***************
*** 118,122 ****
# chop
line = line[:-1]
! fields = string.split(line, "\t")
while len(fields) > 0:
if len(fields[0]) > 0:
--- 119,123 ----
# chop
line = line[:-1]
! fields = line.split("\t")
while len(fields) > 0:
if len(fields[0]) > 0:
***************
*** 128,132 ****
# chop
line = line[:-1]
! fields = string.split(line, "\t")
else:
# add to modules or object
--- 129,133 ----
# chop
line = line[:-1]
! fields = line.split("\t")
else:
# add to modules or object
***************
*** 140,155 ****
d = cat.constants
else:
! raise RuntimeError, "What is '%s'" % (top.type,)
! if d.has_key(top.name):
! print "Duplicate named %s detected: %s" % (top.type, top.name)
# Skip the property fields line for module/object
line = input.readline()
line = line[:-1]
! fields = string.split(line, "\t")
assert len(fields[0]) == 0 and len(fields[1]) == 0, "%s, %s" %(fields, top.name)
if line == '':
! raise ValueError, "incomplete topic!"
# Loop over the rest of the properties,
--- 141,156 ----
d = cat.constants
else:
! raise RuntimeError("What is '%s'" % (top.type,))
! if top.name in d:
! print("Duplicate named %s detected: %s" % (top.type, top.name))
# Skip the property fields line for module/object
line = input.readline()
line = line[:-1]
! fields = line.split("\t")
assert len(fields[0]) == 0 and len(fields[1]) == 0, "%s, %s" %(fields, top.name)
if line == '':
! raise ValueError("incomplete topic!")
# Loop over the rest of the properties,
***************
*** 160,164 ****
# chop
line = line[:-1]
! fields = string.split(line, "\t")
while len(fields) > 0:
if len(fields[0]) > 0:
--- 161,165 ----
# chop
line = line[:-1]
! fields = line.split("\t")
while len(fields) > 0:
if len(fields[0]) > 0:
***************
*** 173,179 ****
line = input.readline()
if line == '':
! raise ValueError, "incomplete topic!"
line = line[:-1]
! fields = string.split(line, "\t")
assert len(fields[0]) == 0 and len(fields[1]) == 0, fields
if top2.type == "pymeth":
--- 174,180 ----
line = input.readline()
if line == '':
! raise ValueError("incomplete topic!")
line = line[:-1]
! fields = line.split("\t")
assert len(fields[0]) == 0 and len(fields[1]) == 0, fields
if top2.type == "pymeth":
***************
*** 190,194 ****
# chop
line = line[:-1]
! fields = string.split(line, "\t")
continue
# Add top2 into top
--- 191,195 ----
# chop
line = line[:-1]
! fields = line.split("\t")
continue
# Add top2 into top
***************
*** 201,205 ****
# chop
line = line[:-1]
! fields = string.split(line, "\t")
d[top.name] = top
--- 202,206 ----
# chop
line = line[:-1]
! fields = line.split("\t")
d[top.name] = top
***************
*** 216,220 ****
def _genCategoryHTMLFromDict(dict, output):
! keys = dict.keys()
keys.sort()
for key in keys:
--- 217,221 ----
def _genCategoryHTMLFromDict(dict, output):
! keys = list(dict.keys())
keys.sort()
for key in keys:
***************
*** 255,259 ****
def _genItemsFromDict(dict, cat, output, target, do_children = 1):
CHM = "mk:@MSITStore:%s.chm::/" % target
! keys = dict.keys()
keys.sort()
for k in keys:
--- 256,260 ----
def _genItemsFromDict(dict, cat, output, target, do_children = 1):
CHM = "mk:@MSITStore:%s.chm::/" % target
! keys = list(dict.keys())
keys.sort()
for k in keys:
***************
*** 272,276 ****
output.write("<UL>")
containees = copy.copy(dict[k].contains)
! containees.sort(TopicCmp)
for m in containees:
output.write('''
--- 273,277 ----
output.write("<UL>")
containees = copy.copy(dict[k].contains)
! containees.sort(key=TopicKey)
for m in containees:
output.write('''
Index: TOCToHHK.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/TOCToHHK.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TOCToHHK.py 24 Nov 1999 08:43:17 -0000 1.1
--- TOCToHHK.py 2 Dec 2009 10:49:35 -0000 1.2
***************
*** 2,6 ****
import os.path
import sys
- import string
"""
--- 2,5 ----
***************
*** 28,39 ****
# chop line
line = line[:-1]
! fields = string.split(line, "\t")
if "." in fields[1]:
! keyword = string.split(fields[1], ".")[-1]
else:
keyword = fields[1]
context = fields[0]
if " " in context:
! context = string.replace(context, " ", "_")
out.write(""" <LI><OBJECT type="text/sitemap">
<param name="Keyword" value="%s">
--- 27,38 ----
# chop line
line = line[:-1]
! fields = line.split("\t")
if "." in fields[1]:
! keyword = fields[1].split(".")[-1]
else:
keyword = fields[1]
context = fields[0]
if " " in context:
! context = context.replace(" ", "_")
out.write(""" <LI><OBJECT type="text/sitemap">
<param name="Keyword" value="%s">
Index: InsertExternalOverviews.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/InsertExternalOverviews.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** InsertExternalOverviews.py 31 May 2005 12:40:05 -0000 1.2
--- InsertExternalOverviews.py 2 Dec 2009 10:49:35 -0000 1.3
***************
*** 17,23 ****
if not line:
break
! line = string.replace(line, "<!--index:exlinks-->", extLinksHTML)
! line = string.replace(line, "<!--index:extopics-->", extTopicHTML)
! line = string.replace(line, "<!--index:eximportant-->", importantHTML)
out.write(line + "\n")
--- 17,23 ----
if not line:
break
! line = line.replace("<!--index:exlinks-->", extLinksHTML)
! line = line.replace("<!--index:extopics-->", extTopicHTML)
! line = line.replace("<!--index:eximportant-->", importantHTML)
out.write(line + "\n")
***************
*** 29,33 ****
for item in cat.overviewItems.items:
dict[item.name] = item.href
! keys = dict.keys()
keys.sort()
for k in keys:
--- 29,33 ----
for item in cat.overviewItems.items:
dict[item.name] = item.href
! keys = list(dict.keys())
keys.sort()
for k in keys:
***************
*** 45,49 ****
def main():
if len(sys.argv) != 2:
! print "Invalid args"
sys.exit(1)
file = sys.argv[1]
--- 45,49 ----
def main():
if len(sys.argv) != 2:
! print("Invalid args")
sys.exit(1)
file = sys.argv[1]
Index: document_object.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/document_object.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** document_object.py 26 Nov 2008 08:39:32 -0000 1.3
--- document_object.py 2 Dec 2009 10:49:35 -0000 1.4
***************
*** 68,80 ****
if __name__=='__main__':
doc = GetDocument()
! print "Important Notes"
for link in doc.important:
! print " ", link.name, link.href
! print "Doc links"
for link in doc.links:
! print " ", link.name, link.href
! print "Doc categories"
for c in doc:
! print " ", c.id, c.label
--- 68,80 ----
if __name__=='__main__':
doc = GetDocument()
! print("Important Notes")
for link in doc.important:
! print(" ", link.name, link.href)
! print("Doc links")
for link in doc.links:
! print(" ", link.name, link.href)
! print("Doc categories")
for c in doc:
! print(" ", c.id, c.label)
Index: BuildHHP.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/BuildHHP.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** BuildHHP.py 11 Sep 2004 07:40:22 -0000 1.9
--- BuildHHP.py 2 Dec 2009 10:49:35 -0000 1.10
***************
*** 40,44 ****
new = glob.glob(g)
if len(new)==0:
! print "The pattern '%s' yielded no files!" % (g,)
lFiles = lFiles + new
# lFiles is now the list of origin files.
--- 40,44 ----
new = glob.glob(g)
if len(new)==0:
! print("The pattern '%s' yielded no files!" % (g,))
lFiles = lFiles + new
# lFiles is now the list of origin files.
***************
*** 66,70 ****
# else we have a trailing slash - it means we _expect_ it to be a patch as-is.
assert os.path.isdir(sCommonPrefix) and sCommonPrefix[-1]=="\\", "commonprefix splitting aint gunna work!"
! print "sCommonPrefix=", sCommonPrefix
# Ok, now remove this common prefix from every file:
lRelativeFiles = []
--- 66,70 ----
# else we have a trailing slash - it means we _expect_ it to be a patch as-is.
assert os.path.isdir(sCommonPrefix) and sCommonPrefix[-1]=="\\", "commonprefix splitting aint gunna work!"
! print("sCommonPrefix=", sCommonPrefix)
# Ok, now remove this common prefix from every file:
lRelativeFiles = []
|