[py-svn] r41080 - in py/trunk/py: apigen test/rsession/webdata
guido at codespeak.net
guido at codespeak.net
Thu Mar 22 16:06:43 CET 2007
Author: guido
Date: Thu Mar 22 16:06:41 2007
New Revision: 41080
Modified:
py/trunk/py/apigen/apigen.py
py/trunk/py/apigen/htmlgen.py
py/trunk/py/test/rsession/webdata/index.html
Log:
Added support for filtering listdir() calls in the SourcePageBuilder, using it
to filter out hidden files and the 'build' subdir of greenlet.
Modified: py/trunk/py/apigen/apigen.py
==============================================================================
--- py/trunk/py/apigen/apigen.py (original)
+++ py/trunk/py/apigen/apigen.py Thu Mar 22 16:06:41 2007
@@ -31,6 +31,11 @@
Channel.__apigen_hide_from_nav__ = True
return pkgname, pkgdict
+def sourcedirfilter(p):
+ return ('.svn' not in str(p).split(p.sep) and
+ not p.basename.startswith('.') and
+ str(p).find('c-extension%sgreenlet%sbuild' % (p.sep, p.sep)) == -1)
+
def build(pkgdir, dsa, capture):
# create a linker (link database) for cross-linking
l = linker.TempLinker()
@@ -51,7 +56,7 @@
apb = htmlgen.ApiPageBuilder(targetdir, l, dsa, pkgdir, namespace_tree,
proj, capture, LayoutPage)
spb = htmlgen.SourcePageBuilder(targetdir, l, pkgdir, proj, capture,
- LayoutPage)
+ LayoutPage, dirfilter=sourcedirfilter)
apb.build_namespace_pages()
class_names = dsa.get_class_names()
Modified: py/trunk/py/apigen/htmlgen.py
==============================================================================
--- py/trunk/py/apigen/htmlgen.py (original)
+++ py/trunk/py/apigen/htmlgen.py Thu Mar 22 16:06:41 2007
@@ -81,7 +81,7 @@
return inspect.formatargspec(*inspect.getargspec(func))
# some helper functionality
-def source_dirs_files(fspath):
+def source_dirs_files(fspath, fil=None):
""" returns a tuple (dirs, files) for fspath
dirs are all the subdirs, files are the files which are interesting
@@ -93,7 +93,7 @@
"""
dirs = []
files = []
- for child in fspath.listdir():
+ for child in fspath.listdir(fil=fil):
if child.basename.startswith('.'):
continue
if child.check(dir=True):
@@ -203,13 +203,14 @@
class SourcePageBuilder(AbstractPageBuilder):
""" builds the html for a source docs page """
def __init__(self, base, linker, projroot, project, capture=None,
- pageclass=LayoutPage):
+ pageclass=LayoutPage, dirfilter=None):
self.base = base
self.linker = linker
self.projroot = projroot
self.project = project
self.capture = capture
self.pageclass = pageclass
+ self.dirfilter = dirfilter
def build_navigation(self, fspath):
nav = H.Navigation(class_='sidebar')
@@ -240,7 +241,7 @@
else:
# we're a file, build our parent's children only
dirpath = fspath.dirpath()
- diritems, fileitems = source_dirs_files(dirpath)
+ diritems, fileitems = source_dirs_files(dirpath, self.dirfilter)
for dir in diritems:
nav.append(H.NavigationItem(self.linker, dir.strpath, dir.basename,
indent, False))
@@ -265,7 +266,7 @@
return tag, nav
def build_dir_page(self, fspath):
- dirs, files = source_dirs_files(fspath)
+ dirs, files = source_dirs_files(fspath, self.dirfilter)
dirs = [(p.basename, self.linker.get_lazyhref(str(p))) for p in dirs]
files = [(p.basename, self.linker.get_lazyhref(str(p))) for p in files]
tag = H.DirList(dirs, files)
@@ -281,7 +282,15 @@
return tag, nav
def build_pages(self, base):
- for fspath in [base] + list(base.visit()):
+ def visit(p):
+ dirs, files = source_dirs_files(p, self.dirfilter)
+ for d in dirs:
+ yield d
+ for sp in visit(d):
+ yield sp
+ for f in files:
+ yield f
+ for fspath in [base] + list(visit(base)):
if fspath.ext in ['.pyc', '.pyo']:
continue
if self.capture:
Modified: py/trunk/py/test/rsession/webdata/index.html
==============================================================================
--- py/trunk/py/test/rsession/webdata/index.html (original)
+++ py/trunk/py/test/rsession/webdata/index.html Thu Mar 22 16:06:41 2007
@@ -62,10 +62,6 @@
border: 0px;
}
- #hosts {
- width: 100%;
- }
-
</style>
</head>
<body onload="main()">
@@ -114,12 +110,10 @@
</table>
<fieldset id="messagebox_fieldset">
<legend><b>Data [<a href="javascript:hide_messagebox()">hide</a>]:</b></legend>
- <a name="message">
- <div id="messagebox"></div>
- </a>
+ <a name="message"> </a>
+ <div id="messagebox"></div>
</fieldset>
- <a name="aftermessage">
- <div id="testmain"></div>
- </a>
+ <a name="aftermessage"> </a>
+ <div id="testmain"></div>
</body>
</html>
More information about the pytest-commit
mailing list