Spaces Data
Minimal test - lines (24, 81)
path: .spaces[1].metrics.loc.cloc
old: 21.0
new: 22.0
path: .spaces[1].metrics.loc.sloc
old: 57.0
new: 58.0
path: .spaces[1].metrics.mi.mi_sei
old: 61.777972087108054
new: 61.774274543908355
path: .spaces[1].metrics.mi.mi_visual_studio
old: 38.778085852455135
new: 38.61332197413217
path: .spaces[1].metrics.mi.mi_original
old: 66.31052680769828
new: 66.028780575766
Code
class BasicFormat:
"""Base class. A Format manages all the conversions and location
transformations (e.g. subdirectory for all tests in that format)
associated with a test suite format.
The base class implementation performs no conversions or
format-specific location transformations."""
formatDirName = None
indexExt = '.htm'
convert = True # XXX hack to supress format conversion in support dirs, need to clean up output code to make this cleaner
def __init__(self, destroot, sourceTree, extMap=None, outputDirName=None):
"""Creates format root of the output tree. `destroot` is the root path
of the output tree.
extMap provides a file extension mapping, e.g. {'.xht' : '.htm'}
"""
self.root = join(destroot, outputDirName) if outputDirName else destroot
self.sourceTree = sourceTree
self.formatDirName = outputDirName
if not exists(self.root):
os.makedirs(self.root)
self.extMap = ExtensionMap(extMap or {})
self.subdir = None
def setSubDir(self, name=None):
"""Sets format to write into group subdirectory `name`.
"""
self.subdir = name
def destDir(self):
return join(self.root, self.subdir) if self.subdir else self.root
def dest(self, relpath):
"""Returns final destination of relpath in this format and ensures that the
parent directory exists."""
# Translate path
if (self.convert):
relpath = self.extMap.translate(relpath)
if (self.sourceTree.isReferenceAnywhere(relpath)):
relpath = join('reference', basename(relpath))
# XXX when forcing support files into support path, need to account for support/support
dest = join(self.root, self.subdir, relpath) if self.subdir \
else join(self.root, relpath)
# Ensure parent
parent = dirname(dest)
if not exists(parent):
os.makedirs(parent)
return dest
def write(self, source):
"""Write FileSource to destination, following all necessary
conversion methods."""
source.write(self, source)
testTransform = False
# def testTransform(self, outputString, source) if needed