Update of /cvsroot/happydoc/HappyDoc3/happydoclib
In directory usw-pr-cvs1:/tmp/cvs-serv25274/happydoclib
Modified Files:
scanner.py test_scanner.py
Log Message:
Add a separate canonical name to the package tree. This can be used
to determine the full input name of the tree, where the regular name
is used to determine the relative positional name of each node.
Index: scanner.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** scanner.py 17 Nov 2002 15:15:17 -0000 1.3
--- scanner.py 17 Nov 2002 16:19:59 -0000 1.4
***************
*** 80,86 ****
def __init__(self, parent, name):
UserDict.UserDict.__init__(self)
self.parent = parent
! self.name = name
return
--- 80,92 ----
def __init__(self, parent, name):
+ trace.into('PackageTree', '__init__',
+ parent=parent,
+ name=name,
+ )
UserDict.UserDict.__init__(self)
self.parent = parent
! self.name = os.path.basename(name)
! self.canonical_name = name
! trace.outof()
return
***************
*** 101,105 ****
return self.name
! def getPath(self):
"""Return the path from the root to this node.
--- 107,116 ----
return self.name
! def getCanonicalName(self):
! """Returns the canonical, full, name of the this tree node.
! """
! return self.canonical_name
!
! def getPath(self, useCanonicalName=0):
"""Return the path from the root to this node.
***************
*** 109,116 ****
parent = self.getParent()
if parent:
! parent_path = parent.getPath()
else:
parent_path = ()
! path = parent_path + (self.getName(),)
return path
--- 120,132 ----
parent = self.getParent()
if parent:
! parent_path = parent.getPath(useCanonicalName=useCanonicalName)
else:
parent_path = ()
!
! if useCanonicalName:
! name = self.getCanonicalName()
! else:
! name = self.getName()
! path = parent_path + (name,)
return path
***************
*** 189,193 ****
tree = parent.addSubNode(package_tree_name)
else:
! tree = PackageTree(parent, package_tree_name)
#
--- 205,209 ----
tree = parent.addSubNode(package_tree_name)
else:
! tree = PackageTree(parent, directoryName)
#
Index: test_scanner.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/test_scanner.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_scanner.py 17 Nov 2002 15:02:11 -0000 1.2
--- test_scanner.py 17 Nov 2002 16:19:59 -0000 1.3
***************
*** 165,168 ****
--- 165,189 ----
)
return
+
+ def testPackageTreePath(self):
+ import os
+ cwd = os.getcwd()
+ input_dir = os.path.join(cwd, 'TestCases/testScanner')
+ scanner = Scanner([input_dir])
+
+ trees = scanner.getPackageTrees()
+ expected_tree = trees[0]
+
+ module_two = expected_tree['levelOne']['levelTwo']['two.py']
+
+ module_two_path = module_two.getPath(1)
+ self.failUnlessEqual(module_two_path,
+ (input_dir,
+ 'levelOne',
+ 'levelTwo',
+ 'two.py',
+ ),
+ )
+ return
def testPackageTreeIgnore(self):
***************
*** 184,187 ****
--- 205,220 ----
tree = PackageTree(None, 'tree1')
self.failUnlessEqual('tree1', tree.getName(),
+ 'Names do not match.')
+ return
+
+ def testPackageTreeNameNotCanonical(self):
+ tree = PackageTree(None, '/full/path/to/tree1')
+ self.failUnlessEqual('tree1', tree.getName(),
+ 'Names do not match.')
+ return
+
+ def testPackageTreeNameCanonical(self):
+ tree = PackageTree(None, '/full/path/to/tree1')
+ self.failUnlessEqual('/full/path/to/tree1', tree.getCanonicalName(),
'Names do not match.')
return
|