def display_message(self, msg, n_chars, punct, bgcol, txtcol): buffer_out = pretty_output("REVERSE", bgcol, txtcol) msg_out = pretty_output("REVERSE", "BOLD", bgcol) half = (n_chars/2) + 1 if str(self.message_buffer)=='True' and str(self.message)=='True': # weird i have to specify ==True buffer_out.write(punct.join([""] * half)) msg_out.write(msg) buffer_out.write(punct.join([""] * half)) elif str(self.message)=='True' and str(self.message_buffer)=='False': msg_out.write(msg) elif str(self.message_buffer)=='True' and str(self.message)=='False': buffer_out.write(punct.join([""] * half)) buffer_out.write(punct.join([""] * half))
def display(self, list_title): try: list = self.wunderlist.lists[list_title] except KeyError: print("That list does not exist.") exit() with colors.pretty_output(colors.BOLD, colors.UNDERSCORE) as out: out.write(list_title) for task_title, info in list["tasks"].iteritems(): pretty_print_task(task_title, info)
def overview(self): for title, list in self.wunderlist.lists.iteritems(): tasks = list["tasks"] with colors.pretty_output(colors.BOLD, colors.UNDERSCORE) as out: out.write(title) task_count = 0 for task_title, info in tasks.iteritems(): if task_count <= 4: pretty_print_task(task_title, info) task_count += 1 else: break print("")
def welcome(self): with pretty_output("BOLD", "FG_MAGENTA") as start: start.write(logo)
variPos = 1 elif vh == "H": posRow = raw_input("In which row would you like to place your ship (Between 1 and " + str(size) + "): ") posCol = raw_input( "In which column would you like to place the left side your ship (Between 1 and " + str(size - 1) + "): " ) clear() while int(posRow) > size or int(posCol) > size - 1 or int(posCol) < 1 or int(posRow) < 1: posRow = raw_input("In which row would you like to place your ship (Between 1 and " + str(size) + "): ") posCol = raw_input( "In which column would you like to place your ship (Between 1 and " + str(size - 1) + "): " ) clear() variPos = 1 else: with colors.pretty_output(colors.BOLD, colors.FG_RED) as out: out.write("You didn't type V or H!") variPos = 0 ship_row = int(posRow) - 1 ship_col = int(posCol) - 1 if vh == "V": pship_row = ship_row + 1 pship_col = ship_col else: pship_row = ship_row pship_col = ship_col + 1 def guessCol(min, max): return randint(min, max)
def printseq(samples, ref_seq, srange=[], width=100, htmlflag=False, dtype='tot'): locus = {} freqs = {} seq = {} if len(srange) == 1: srange = [0,srange] if len(srange) == 0: srange = [0,len(ref_seq)] out_name = 'Mito_SNP_%d_%d' % (srange[0], srange[1]) cseq = '' if htmlflag: cseq +='<html>\n<body>\n<pre>\n' for sname in natsorted(samples.keys()): sample = samples[sname] sname = sname.rsplit('_',4)[0] freqs1, locus1 = sample.mt.get_snps(min_freq, min_cov, dtype) locus1 = locus1.flatten() snps1 = sample.mt.snps[dtype][locus1,0] seq1 = np.copy(ref_seq) seq1[locus1] = snps1 locus.update({sname: locus1}) freqs.update({sname: freqs1}) seq.update({sname: seq1}) nline = int((srange[1]-srange[0])/width) nends = (srange[1]-srange[0]) - width*nline for i in range(nline): cseq += ('%-10.10s' % '') + ('%-10d' % (srange[0]+i*width)) + (repr((srange[0]+(i+1)*width)).rjust(width-10)) + '\n' for sname in natsorted(samples.keys()): sname = sname.rsplit('_',4)[0] locus1 = locus[sname] - srange[0] - i*width freqs1 = freqs[sname] seq1 = seq[sname][(srange[0]+i*width):(srange[0]+(i+1)*width)] if htmlflag: cseq += ('%-10.10s' % sname) + colorseqhtml(seq1, locus1, freqs1) + '\n' else: cseq += ('%-10.10s' % sname) + colorseq(seq1, locus1, freqs1) + '\n' cseq += '....................\n' if nends>0: if nends>20: cseq += ('%-10.10s' % '') + ('%-10d' % (srange[0]+nline*width)) + (repr(srange[1]).rjust(nends-10)) + '\n' else: cseq += ('%-10.10s' % '') + (repr(srange[1]).rjust(nends)) + '\n' for sname in natsorted(samples.keys()): sname = sname.rsplit('_',4)[0] locus1 = locus[sname] - srange[0] - nline*width freqs1 = freqs[sname] seq1 = seq[sname][(srange[0]+nline*width):srange[1]] if htmlflag: cseq += ('%-10.10s' % sname) + colorseqhtml(seq1, locus1, freqs1) + '\n' else: cseq += ('%-10.10s' % sname) + colorseq(seq1, locus1, freqs1) + '\n' if htmlflag: cseq +='</pre>\n</body>\n</html>\n' htmfile = open(save_dir+out_name+'.html', 'w') htmfile.write(cseq) htmfile.close() #p1 = subprocess.Popen(['echo', cseq], stdout=subprocess.PIPE) #p2 = subprocess.Popen(['aha > '+out_name+'.htm'], stdin=p1.stdout, stdout=subprocess.PIPE, shell=True) #pdfkit.from_file(out_name+'.htm', out_name+'.pdf') #print p2.communicate() #subprocess.call(cmd) else: with clr.pretty_output() as out: out.write(cseq)