Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/download-arm64-libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

VERSION = "{}.{}.{}".format(*sys.version_info[:3])
if sys.version_info.releaselevel == "alpha":
VERSION += "-a{}".format(sys.version_info.serial)
VERSION += f"-a{sys.version_info.serial}"
if sys.version_info.releaselevel == "beta":
VERSION += "-b{}".format(sys.version_info.serial)
VERSION += f"-b{sys.version_info.serial}"
if sys.version_info.releaselevel == "candidate":
VERSION += "-rc{}".format(sys.version_info.serial)
VERSION += f"-rc{sys.version_info.serial}"

URL = f"https://www.nuget.org/api/v2/package/pythonarm64/{VERSION}"
PATH = dest / f"pythonarm64.{VERSION}.zip"
Expand Down
8 changes: 4 additions & 4 deletions AutoDuck/BuildHHP.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def handle_globs(lGlobs):
for g in lGlobs:
new = glob.glob(g)
if len(new) == 0:
print("The pattern '%s' yielded no files!" % (g,))
print(f"The pattern '{g}' yielded no files!")
lFiles = lFiles + new
# lFiles is now the list of origin files.
# Normalize all of the paths:
Expand Down Expand Up @@ -111,12 +111,12 @@ def main():
shutil.copyfile(lSrcFiles[i], file)

for file in lDestFiles:
html_files = html_files + "%s\\%s\n" % (html_dir, file)
html_files = html_files + f"{html_dir}\\{file}\n"

for cat in doc:
html_files = html_files + "%s\\%s.html\n" % (output_dir, cat.id)
html_files = html_files + f"{output_dir}\\{cat.id}.html\n"
for suffix in "_overview _modules _objects _constants".split():
html_files = html_files + "%s\\%s%s.html\n" % (output_dir, cat.id, suffix)
html_files = html_files + f"{output_dir}\\{cat.id}{suffix}.html\n"

f.write(sHHPFormat % {"output": output, "target": target, "html_files": html_files})
f.close()
Expand Down
85 changes: 41 additions & 44 deletions AutoDuck/Dump2HHC.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,16 @@ def parseTopics(cat, input):
elif top.type == "const":
d = cat.constants
else:
raise RuntimeError("What is '%s'" % (top.type,))
raise RuntimeError(f"What is '{top.type}'")

if top.name in d:
print("Duplicate named %s detected: %s" % (top.type, top.name))
print(f"Duplicate named {top.type} detected: {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,
)
assert len(fields[0]) == 0 and len(fields[1]) == 0, f"{fields}, {top.name}"
if line == "":
raise ValueError("incomplete topic!")

Expand Down Expand Up @@ -197,16 +194,10 @@ def parseTopics(cat, input):
assert len(fields[0]) == 0 and len(fields[1]) == 0, fields
if top2.type == "pymeth":
top2.name = fields[2]
top2.context = "%s__%s_meth.html" % (
_urlescape(top.name),
top2.name,
)
top2.context = f"{_urlescape(top.name)}__{top2.name}_meth.html"
elif top2.type == "prop":
top2.name = fields[3]
top2.context = "%s__%s_prop.html" % (
_urlescape(top.name),
top2.name,
)
top2.context = f"{_urlescape(top.name)}__{top2.name}_prop.html"
else:
# and loop....
line = input.readline()
Expand Down Expand Up @@ -244,7 +235,7 @@ def _genCategoryHTMLFromDict(dict, output):
keys.sort()
for key in keys:
topic = dict[key]
output.write('<LI><A HREF="%s">%s</A>\n' % (topic.context, topic.name))
output.write(f'<LI><A HREF="{topic.context}">{topic.name}</A>\n')


def _genOneCategoryHTML(output_dir, cat, title, suffix, *dicts):
Expand All @@ -271,7 +262,7 @@ def _genCategoryTopic(output_dir, cat, title):
("Modules", "_modules"),
("Objects", "_objects"),
):
output.write('<LI><A HREF="%s%s.html">%s</A>\n' % (cat.id, suffix, subtitle))
output.write(f'<LI><A HREF="{cat.id}{suffix}.html">{subtitle}</A>\n')
output.write("</BODY></HTML>\n")
output.close()

Expand Down Expand Up @@ -302,12 +293,13 @@ def _genItemsFromDict(dict, cat, output, target, do_children=1):
output.write(
"""
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="%(name)s">
<param name="Name" value="{name}">
<param name="ImageNumber" value="1">
<param name="Local" value="%(CHM)s%(context)s">
<param name="Local" value="{CHM}{context}">
</OBJECT>
"""
% locals()
""".format(
**locals()
)
)
if not do_children:
continue
Expand All @@ -317,13 +309,12 @@ def _genItemsFromDict(dict, cat, output, target, do_children=1):
containees.sort(key=TopicKey)
for m in containees:
output.write(
"""
f"""
<LI><OBJECT type="text/sitemap">
<param name="Name" value="%s">
<param name="Name" value="{m.name}">
<param name="ImageNumber" value="11">
<param name="Local" value="%s%s">
<param name="Local" value="{CHM}{m.context}">
</OBJECT>"""
% (m.name, CHM, m.context)
)
if len(dict[k].contains) > 0:
output.write(
Expand All @@ -347,13 +338,14 @@ def genTOC(cats, output, title, target):
</OBJECT>
<UL>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="%(title)s">
<param name="Name" value="{title}">
<param name="ImageNumber" value="1">
<param name="Local" value="%(CHM)s%(target)s.html">
<param name="Local" value="{CHM}{target}.html">
</OBJECT>
<UL>
"""
% locals()
""".format(
**locals()
)
)

for cat in cats:
Expand All @@ -362,25 +354,27 @@ def genTOC(cats, output, title, target):
output.write(
"""\
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="%(cat_name)s">
<param name="Name" value="{cat_name}">
<param name="ImageNumber" value="1">
<param name="Local" value="%(CHM)s%(cat_id)s.html">
<param name="Local" value="{CHM}{cat_id}.html">
</OBJECT>
<UL>
"""
% locals()
""".format(
**locals()
)
)
# Next write the overviews for this category
output.write(
"""\
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Overviews">
<param name="ImageNumber" value="1">
<param name="Local" value="%(CHM)s%(cat_id)s_overview.html">
<param name="Local" value="{CHM}{cat_id}_overview.html">
</OBJECT>
<UL>
"""
% locals()
""".format(
**locals()
)
)
_genItemsFromDict(cat.overviewTopics, cat, output, target)
_genItemsFromDict(cat.extOverviewTopics, cat, output, target)
Expand All @@ -394,11 +388,12 @@ def genTOC(cats, output, title, target):
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Modules">
<param name="ImageNumber" value="1">
<param name="Local" value="%(CHM)s%(cat_id)s_modules.html">
<param name="Local" value="{CHM}{cat_id}_modules.html">
</OBJECT>
<UL>
"""
% locals()
""".format(
**locals()
)
)
_genItemsFromDict(cat.modules, cat, output, target)
output.write(
Expand All @@ -411,10 +406,11 @@ def genTOC(cats, output, title, target):
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Objects">
<param name="ImageNumber" value="1">
<param name="Local" value="%(CHM)s%(cat_id)s_objects.html">
<param name="Local" value="{CHM}{cat_id}_objects.html">
</OBJECT>
<UL>"""
% locals()
<UL>""".format(
**locals()
)
)
# Dont show 'children' for objects - params etc don't need their own child nodes!
_genItemsFromDict(cat.objects, cat, output, target, do_children=0)
Expand All @@ -428,11 +424,12 @@ def genTOC(cats, output, title, target):
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Constants">
<param name="ImageNumber" value="1">
<param name="Local" value="%(CHM)s%(cat_id)s_constants.html">
<param name="Local" value="{CHM}{cat_id}_constants.html">
</OBJECT>
<UL>
"""
% locals()
""".format(
**locals()
)
)
_genItemsFromDict(cat.constants, cat, output, target)
output.write(
Expand Down
6 changes: 3 additions & 3 deletions AutoDuck/InsertExternalOverviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ def processFile(input, out, extLinksHTML, extTopicHTML, importantHTML):
def genHTML(doc):
s = ""
for cat in doc:
s = s + "<H3>%s</H3>\n" % (cat.label,)
s = s + f"<H3>{cat.label}</H3>\n"
dict = {}
for item in cat.overviewItems.items:
dict[item.name] = item.href
keys = list(dict.keys())
keys.sort()
for k in keys:
s = s + '<LI><A HREF="html/%s">%s</A>\n' % (dict[k], k)
s = s + f'<LI><A HREF="html/{dict[k]}">{k}</A>\n'
return s


def genLinksHTML(links):
s = ""
for link in links:
s = s + '<LI><A HREF="%s">%s</A>\n' % (link.href, link.name)
s = s + f'<LI><A HREF="{link.href}">{link.name}</A>\n'
return s


Expand Down
9 changes: 4 additions & 5 deletions AutoDuck/TOCToHHK.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ def main():
if " " in context:
context = context.replace(" ", "_")
out.write(
""" <LI><OBJECT type="text/sitemap">
<param name="Keyword" value="%s">
<param name="Name" value="%s">
<param name="Local" value="%s.html">
f""" <LI><OBJECT type="text/sitemap">
<param name="Keyword" value="{keyword}">
<param name="Name" value="{fields[1]}">
<param name="Local" value="{context}.html">
</OBJECT>
"""
% (keyword, fields[1], context)
)
line = input.readline()
out.write(
Expand Down
2 changes: 1 addition & 1 deletion AutoDuck/document_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def startElement(self, name, attrs):
category = self.document.categories[-1]
assert (
category.overviewItems is None
), "category %r already has overviews" % (category,)
), f"category {category!r} already has overviews"
category.overviewItems = OverviewItems(attrs)
elif name == "item":
item = Item(attrs)
Expand Down
11 changes: 5 additions & 6 deletions AutoDuck/makedfromi.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,26 @@ def make_doc_summary(inFile, outFile):
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])
f"// @pymethod {fields[0]}|{thisModName}|{fields[1]}|{fields[2]}\n"
)
for extra in extras:
outFile.write(extra)
if g_com_parent:
outFile.write("\n// @object %s|%s" % (thisModName, modDoc))
outFile.write(f"\n// @object {thisModName}|{modDoc}")
outFile.write("\n// <nl>Derived from <o %s>\n" % (g_com_parent))
else:
outFile.write("\n// @module %s|%s\n" % (thisModName, modDoc))
outFile.write(f"\n// @module {thisModName}|{modDoc}\n")
for meth, extras in these_methods:
fields = meth.split("|")
outFile.write("// @pymeth %s|%s\n" % (fields[1], fields[2]))
outFile.write(f"// @pymeth {fields[1]}|{fields[2]}\n")
chunk_number += 1
method_num += max_methods

outFile.write("\n")
for extra in extra_tags:
outFile.write("%s\n" % (extra))
for cname, doc in constants:
outFile.write("// @const %s|%s|%s\n" % (modName, cname, doc))
outFile.write(f"// @const {modName}|{cname}|{doc}\n")


def doit():
Expand Down
28 changes: 13 additions & 15 deletions AutoDuck/py2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,32 +112,30 @@ def build_module(fp, mod_name):
elif name.upper() == name and isinstance(ob, (int, str)):
constants.append((name, ob))
info = BuildInfo(mod_name, mod)
Print("// @module %s|%s" % (mod_name, format_desc(info.desc)), file=fp)
Print(f"// @module {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)
Print(f"// @pymeth {ob.name}|{ob.short_desc}", file=fp)
for ob in classes:
# only classes with docstrings get printed.
if not ob.ob.__doc__:
continue
ob_name = mod_name + "." + ob.name
Print("// @pyclass %s|%s" % (ob.name, ob.short_desc), file=fp)
Print(f"// @pyclass {ob.name}|{ob.short_desc}", file=fp)
for ob in functions:
Print(
"// @pymethod |%s|%s|%s" % (mod_name, ob.name, format_desc(ob.desc)),
f"// @pymethod |{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
)
Print(f"// @pyparm |{ai.name}|{ai.default}|{ai.short_desc}", file=fp)

for ob in classes:
# only classes with docstrings get printed.
if not ob.ob.__doc__:
continue
ob_name = mod_name + "." + ob.name
Print("// @object %s|%s" % (ob_name, format_desc(ob.desc)), file=fp)
Print(f"// @object {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.
Expand All @@ -148,29 +146,29 @@ def build_module(fp, mod_name):
if should_build_function(info):
func_infos.append(info)
for fi in func_infos:
Print("// @pymeth %s|%s" % (fi.name, fi.short_desc), file=fp)
Print(f"// @pymeth {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)),
f"// @pymethod |{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)),
f"// @pymethod |{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),
f"// @pyparm |{ai.name}|{ai.default}|{ai.short_desc}",
file=fp,
)

for name, val in constants:
desc = "%s = %r" % (name, val)
desc = f"{name} = {val!r}"
if isinstance(val, int):
desc += " (0x%x)" % (val,)
Print("// @const %s|%s|%s" % (mod_name, name, desc), file=fp)
desc += f" (0x{val:x})"
Print(f"// @const {mod_name}|{name}|{desc}", file=fp)


def main(fp, args):
Expand Down
Loading