def get_table_dependencies(self): """Returns dependencies of the pipeline as an HTML/XML table The dependencies are the python dependencies as returned by pkg_resource module. """ dependencies = easydev.get_dependencies(self.pkgname) # TODO: Could re-use new method in HTMLTable for adding href # but needs some extra work in the add_href method. names = [x.project_name for x in dependencies] versions = [x.version for x in dependencies] links = ["""https://pypi.python.org/pypi/%s""" % p for p in names] df = pd.DataFrame({ 'package': ["""<a href="%s">%s</a>""" % (links[i], p) for i, p in enumerate(names)], 'version': versions}) table = HTMLTable(df, name="dependencies", escape=False) table.sort('package') return table
def test_htmltable(): df = pd.DataFrame({'A': [1, 2, 10], 'B': [1, 10, 2]}) table = HTMLTable(df) table.add_bgcolor('A') table.sort('B') table.to_html() # use another mode df = pd.DataFrame({'A': [1, 2, 10], 'B': [1, 10, 2]}) table = HTMLTable(df) table.add_bgcolor('A', mode='max') # test collapse case (needs df>20) df = pd.DataFrame({'A': randn(30), 'B': randn(30)}) table = HTMLTable(df) table.to_html() # test add_bgcolor on empty datra df = pd.DataFrame({'A': []}) table = HTMLTable(df) table.add_bgcolor('A') table.to_html() # test url df = pd.DataFrame({'A': [1]}) html = HTMLTable(df) html.add_href("A", url="test") assert html.df.ix[0].values[0] == '<a alt="1" href="test1">1</a>' # test url / newtab df = pd.DataFrame({'A': [1]}) html = HTMLTable(df) html.add_href("A", url="test", newtab=True) # test url / no url html = HTMLTable(df) html.add_href("A") html = HTMLTable(df) html.add_href("A", newtab=True)
def test_htmltable(): df = pd.DataFrame({'A':[1,2,10], 'B':[1,10,2]}) table = HTMLTable(df) table.add_bgcolor('A') table.sort('B') table.to_html() # use another mode df = pd.DataFrame({'A':[1,2,10], 'B':[1,10,2]}) table = HTMLTable(df) table.add_bgcolor('A', mode='max') # test collapse case (needs df>20) df = pd.DataFrame({'A':randn(30), 'B':randn(30)}) table = HTMLTable(df) table.to_html() # test add_bgcolor on empty datra df = pd.DataFrame({'A':[]}) table = HTMLTable(df) table.add_bgcolor('A') table.to_html() # test url df = pd.DataFrame({'A':[1]}) html = HTMLTable(df) html.add_href("A", url="test") assert html.df.ix[0].values[0] == '<a alt="1" href="test1">1</a>' # test url / newtab df = pd.DataFrame({'A':[1]}) html = HTMLTable(df) html.add_href("A", url="test", newtab=True) # test url / no url html = HTMLTable(df) html.add_href("A") html = HTMLTable(df) html.add_href("A", newtab=True)
def get_table_dependencies(self): """Returns dependencies of the pipeline as an HTML/XML table The dependencies are the python dependencies as returned by pkg_resource module. """ dependencies = easydev.get_dependencies(self.pkgname) # TODO: Could re-use new method in HTMLTable for adding href # but needs some extra work in the add_href method. names = [x.project_name for x in dependencies] versions = [x.version for x in dependencies] links = ["""https://pypi.python.org/pypi/%s""" % p for p in names] df = pd.DataFrame({ 'package': [ """<a href="%s">%s</a>""" % (links[i], p) for i, p in enumerate(names) ], 'version': versions }) table = HTMLTable(df, name="dependencies", escape=False) table.sort('package') return table