def report(target, sources): '''Create report''' # Extract the Java Script and the CSS ntools.extract_pic_js_css(target) # Get the date date = datetime.datetime.now() # Process the index ntools.kiding(__name__, 'index.html', target) # Process the listing ntools.kiding(__name__, 'listing.html', target, sources=sources, date=date) # Process the abstract ntools.kiding(__name__, 'abstract.html', target, sources=sources, date=date) # Go threw the sources for entity in sources.listing(): # Try to process the package try: # Set the details of the errors ntools.kiding(__name__, 'detail.html', target, bn='%s-detail.html' % entity.full(), entity=entity, date=date) # Get the highlighted lines lines = ntools.highlight(ntools.load(entity.path())) # Process the code try: ntools.kiding(__name__, 'code.html', target, bn='%s-code.html' % entity.full(), entity=entity, lines=lines, date=date) # Unable to create source except: # Log the error logger.error(traceback.format_exc()) # Create the error page ntools.kiding(__name__, 'error.html', target, bn='%s-code.html' % entity.full(), entity=entity, error='Failed to highlight source code', date=date) # Unable to process the package except: logger.error(traceback.format_exc())
def report(target, sources): '''Create report''' # Extract the Java Script and the CSS ntools.extract_pic_js_css(target) # Get the date date = datetime.datetime.now() # Process the index ntools.kiding(__name__, 'index.html', target) # Process the listing ntools.kiding(__name__, 'listing.html', target, sources=sources, date=date) # Process the abstract ntools.kiding(__name__, 'abstract.html', target, sources=sources, date=date) # Get CSS class cls = { '>': 'covered', '!': 'uncovered', '-': 'skipped', ' ': 'no', } # Go threw the sources for entity in sources: # Try to process the package try: # Get the path of the coverage file path = os.path.join(target, '%s.py,cover' % entity.full()) # Check if has error if entity.has_err(): ntools.kiding(__name__, 'error.html', target, bn='%s-code.html' % entity.full(), entity=entity, error=entity.err(), date=date) # Coverage file doesn't exists elif not os.path.isfile(path): ntools.kiding(__name__, 'error.html', target, bn='%s-code.html' % entity.full(), entity=entity, error="Coverage file doesn't exists", date=date) # Got file to process else: # Store the source content content = [] # Store annotation data = [] # Go threw the lines to fill content and data for line in ntools.load(path).splitlines(): # Set data data.append(cls[line[0]]) # Get the content. If void, add a space if line[2:] == '': content.append(' ') # Else add the content else: content.append(line[2:]) # Get the text text = '%s' % ('\n'.join(content), ) # Get the highlighted lines lines = ntools.highlight(text) # Get complexity entity.cyclonize(text) # Set lines entity.linize(len(content)) # Fill data in case of file without content while len(data) < len(lines): data.append(' ') # Process the code try: ntools.kiding(__name__, 'code.html', target, bn='%s-code.html' % entity.full(), entity=entity, lines=lines, data=data, date=date) # Unable to create source except: # Log the error logger.error(traceback.format_exc()) # Create the error page ntools.kiding(__name__, 'error.html', target, bn='%s-code.html' % entity.full(), entity=entity, error='Failed to highlight source code', date=date) # Unable to process the package except: logger.error(traceback.format_exc()) # Create the COBERTURA and CLOVER reports for fn in [ 'cobertura.xml', 'clover.xml', ]: ntools.kiding(__name__, fn, target, output='xml', sources=sources, version=nosexunit.__version__, date='%d' % time.mktime(date.timetuple()))
def report(target, sources): """Create report""" # Extract the Java Script and the CSS ntools.extract_pic_js_css(target) # Get the date date = datetime.datetime.now() # Process the index ntools.kiding(__name__, "index.html", target) # Process the listing ntools.kiding(__name__, "listing.html", target, sources=sources, date=date) # Process the abstract ntools.kiding(__name__, "abstract.html", target, sources=sources, date=date) # Get CSS class cls = {">": "covered", "!": "uncovered", "-": "skipped", " ": "no"} # Go threw the sources for entity in sources: # Try to process the package try: # Get the path of the coverage file path = os.path.join(target, "%s.py,cover" % entity.full()) # Check if has error if entity.has_err(): ntools.kiding( __name__, "error.html", target, bn="%s-code.html" % entity.full(), entity=entity, error=entity.err(), date=date, ) # Coverage file doesn't exists elif not os.path.isfile(path): ntools.kiding( __name__, "error.html", target, bn="%s-code.html" % entity.full(), entity=entity, error="Coverage file doesn't exists", date=date, ) # Got file to process else: # Store the source content content = [] # Store annotation data = [] # Go threw the lines to fill content and data for line in ntools.load(path).splitlines(): # Set data data.append(cls[line[0]]) # Get the content. If void, add a space if line[2:] == "": content.append(" ") # Else add the content else: content.append(line[2:]) # Get the text text = "%s" % ("\n".join(content),) # Get the highlighted lines lines = ntools.highlight(text) # Get complexity entity.cyclonize(text) # Set lines entity.linize(len(content)) # Fill data in case of file without content while len(data) < len(lines): data.append(" ") # Process the code try: ntools.kiding( __name__, "code.html", target, bn="%s-code.html" % entity.full(), entity=entity, lines=lines, data=data, date=date, ) # Unable to create source except: # Log the error logger.error(traceback.format_exc()) # Create the error page ntools.kiding( __name__, "error.html", target, bn="%s-code.html" % entity.full(), entity=entity, error="Failed to highlight source code", date=date, ) # Unable to process the package except: logger.error(traceback.format_exc()) # Create the COBERTURA and CLOVER reports for fn in ["cobertura.xml", "clover.xml"]: ntools.kiding( __name__, fn, target, output="xml", sources=sources, version=nosexunit.__version__, date="%d" % time.mktime(date.timetuple()), )