from depend import Depend class DependReport: def report(self, tree, indentlevel=0): text = "%s%s directly included lines(%d), all included lines(%d)\n" % (" "*indentlevel, tree.name(), tree.lines(), tree.totalLines()) for child in tree.children(): text += self.report(child, indentlevel+1) return text def reportStats(self, stats): report = "" files = stats.files() files.sort(key=lambda k:k.compiledLines()) for file in files: report += "%s lines in file(%d), all included lines(%d), places included from(%d)\n" % (file.file(), file.fileLines(), file.compiledLines(), file.includedFrom()) return report if __name__ == "__main__": import sys file = sys.argv[1] lines = open(file).readlines() depend = Depend() tree = depend.getTree(lines) reporter = DependReport() print reporter.report(tree)
def setUp(self): self.depend = Depend()
logger.info("adding depend %s on %s" % (self, on_layer)) # # Handle the depend any bullshit # if any_frame or depend_type == DependType.LayerOnAny: if isinstance(self, (LayerPreProcess, )): depend_type = DependType.LayerOnLayer else: depend_type = DependType.FrameByFrame any_frame = False for pre in self.get_preprocess_layers(): pre.depend_on(on_layer, DependType.LayerOnLayer, any_frame=True) depend = Depend(self, on_layer, depend_type, propigate, any_frame) self.__depends.append(depend) # Setup pre-process dependencies for my_preprocess in self.get_preprocess_layers(): for on_preprocess in on_layer.get_preprocess_layers(): # Depend on the layer's pre-process my_preprocess.depend_on(on_preprocess, DependType.LayerOnLayer) # # Handle depend propigation. # # Propigation occurs when a layer A depends on layer B, and # layer C depends on layer D, but Layer A also depends on Layer # C, which means layer D must now also depend on layer B. #
def setUp(self): self.depend = Depend() self.builder = self.mock() self.depend.builder = self.builder