def write_story(self): #This is where we add the tags h = HTML() h.html() h.body() h.div(klass="Story", id=self.title) for (x, p) in enumerate(self.pages): # print x, p.text, p.choices # exit() h.div(klass="Page", value=str(x)) if isinstance(p.text, unicode): h += HTML(text=unicodedata.normalize('NFKD', p.text).encode( 'ascii', 'ignore')) else: h += HTML(text=p.text) for (k, choice) in enumerate(p.choices): if isinstance(choice, unicode): choice = unicodedata.normalize('NFKD', choice).encode( 'ascii', 'ignore') h.div(choice, klass="Choice", value=str(k)) h += HTML('/div') pass h += HTML('/div') h += HTML('/body') h += HTML('/html') soup = bs(str(h)) return soup.prettify()
def _sprite_proof(self, sprite_width, sprite_height, sprite_layout): """ Create a sprite proof showing how the image was cut. Should look like original. """ h = HTML('html') head = h.head() title = h.title('Sprite Proof') stylesheet = head.link(href="%s.css" % self.scale, rel="stylesheet", type="text/css") style = head.style(type="text/css") style.raw_text(""" .pc { position: absolute; text-indent: -999em; } .pc:hover { text-indent: 0; } """) body = h.body() for (k, v) in self.pieces.items(): x = v[0] y = v[1] el = body.div(klass='pc pc-%s-%s' % (self.scale, k), style="left:%spx;top:%spx;" % (x, y)) el.text(str(k)) f = open(os.path.join(self._mydir, 'sprite_proof.html'), 'w') f.write(str(h)) f.close()
def genHtmlHeader(project='', location='', csspath="css/data.css", js='js/data.js'): # created index object from HTML() class which should create open & close tags html = HTML('html') head = html.head() title = head.title('Data Status') meta = head.meta(charset="utf-8") css = head.link(rel="stylesheet", type="text/css", href=csspath) if js: js = head.script(type="text/javascript", src=js) js.text("") # end of if js: # created body tag body = html.body() b = body.div(name='body', klass='bodyCls') #load = body.p(id="loading", style = 'display:inline') #load.text("Loading . . .") b.br heading = b.div(name='heading', klass='headingCls') ifen = ' - ' if location else '' if project: heading.h1(project + ' Project Data Report Sheet' + ifen + location) else: heading.h1(' Project Index Data Report Sheet' + ifen + location) form = b.form() tdiv = form.div(id="contentdiv") return (html, b, tdiv, form)
from diagnosisutils.timeutils import TimeUtility # create time utility object timobj = TimeUtility() # created index object from HTML() class which should create open & close tags html = HTML('html') head = html.head() title = head.title('Model Diagnosis') css = head.link(rel="stylesheet", type="text/css", href="css/diagnosis.css") jq = head.script(type="text/javascript", src="js/jquery-1.7.min.js") jq.text("") js = head.script(type="text/javascript", src="js/diagnosis.js") js.text("") # created body tag body = html.body() b = body.div(name = 'body', klass = 'bodyCls') b.br heading = b.div(name = 'heading', klass = 'headingCls') heading.h1('Model Diagnosis Plots') flag = True count = 3 form = b.form() txt = form.div(id = "txtdiv") txt.p("Choose a model") # sphinx documentation link docdiv = form.div(name = 'docdiv') doclink = docdiv.a(id = 'docdivid', href = 'doc/index.html', target = '_blank', klass = '') doclink.text("Documentation")
output = open(datafile, 'wb') cPickle.dump(recipes, output) else: infile = open(datafile, 'rb') recipes = cPickle.load(infile) infile.close() return recipes gw2 = gw2spidy.Gw2Spidy() print "Content-type: text/html\n" page = HTML('html') body = page.body() populateScripts(body) body.ul.li("All prices in silver") body.ul.li("Instant profit = craft, sell to highest buyer") body.ul.li("Flip profit = buy at highest buyer, sell at lowest seller") body.ul.li("Craft profit = Craft, sell at lowest seller") form = body.form("Filter:", style="margin-left: 10px;") form.input(' ', type="text", name="filtrpt", onkeyup="filter2(this,'recipes')") tab = body.table(id="recipes", klass="tablesorter", border="1") thead = tab.thead() thead.th("Name") thead.th("Mat Cost") thead.th("Highest Buy") thead.th("Lowest Sell") thead.th("Instant Profit")
def produceVXReport(): agentHeader = {'User-agent': userAgent} h = HTML() head = h.head() head.link( rel='stylesheet', href= 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css' ) body = h.body() t = body.table(klass="table table-bordered", style="width: 100%;") thead = t.thead() r = thead.tr() r.th('Time') r.th('File Name') r.th('Type') r.th('Score') r.th('VT Percent') r.th('VX Family') r.th('ET Count') r.th('ET Alerts') r.th('Domain Count') r.th('Host Count') r.th('Report') try: logging.info('Fetching: {0}'.format(reportUrl)) request = requests.get(reportUrl, headers=agentHeader) if request.status_code == 200: report = json.loads(request.text) logging.info('Request OK. Parsing JSON...') items = report["data"] tbody = t.tbody() for item in items: r = tbody.tr if "analysis_start_time" in item: r.td(item["analysis_start_time"]) else: r.td('?') if "submitname" in item: r.td(item["submitname"], style="word-break:break-all;") else: r.td('?') if "type" in item: r.td(item["type"]) else: r.td('?') if "threatscore" in item: r.td('{0}/100'.format(item["threatscore"])) else: r.td('?') if "vt_detect" in item: vtScore = str(item["vt_detect"]) r.td('{0}%'.format(vtScore)) else: r.td('?') if "vxfamily" in item: r.td(item["vxfamily"]) else: r.td('?') if "et_alerts_total" in item: r.td(str(item["et_alerts_total"])) etAlerts = item["et_alerts"] lH = HTML() l = lH.ul() for etAlert in etAlerts: l.li(etAlert["action"]["description"]) r.td(l, escape=False) else: r.td('0') r.td('') if "domains" in item: r.td(str(len(item["domains"]))) else: r.td('0') if "hosts" in item: r.td(str(len(item["hosts"]))) else: r.td('0') fileHash = item["sha256"] link = '<a href="https://www.reverse.it/sample/{0}/?environmentId=100" rel="noopener noreferrer" target="_blank">www.reverse.it</a>'.format( fileHash) r.td(link, escape=False) return unicode(h).encode('utf8') else: logging.error("Request failed. Status code: {0}.".format( request.status_code)) sys.exit(1) except Exception as e: logging.error("Problem connecting.") logging.exception(sys.exc_info()) logging.exception(type(e)) logging.exception(e.args) logging.exception(e) sys.exit(1)
# Parse all the .robot files under the current directory and # generate a HTML table containing three columns, Test Suite, Test Case, Description import glob import re from html import HTML robotFiles = glob.glob('*.robot') doc = HTML().html() head = doc.head() head.title('Thunderdome Functional Test Cases in Recon') body = doc.body() intro = body.p intro.h1('Thunderdome Automated Functional Test cases') intro.text( 'Click on the Test Suite name for details on the test steps (Keywords) for each test in the suite.' ) tbl = body.table(border='1') row = tbl.tr( style= "text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;", valign="middle") row.th('Test Suite') row.th('Test Name') row.th('Description') for filename in robotFiles: if filename == 'core.robot': continue # print '\nDEBUG: Test Suite: %s' %filename