def make_slide(slide_number, markdown_file_name, slide_count): content_file_name = 'content.html' convert.main(markdown_file_name, content_file_name) template_file_name = 'template.html' slide_file_name = make_slide_file_name(slide_number) next_slide_number = slide_number + 1 if slide_number < slide_count else 1 next_slide_file_name = make_slide_file_name(next_slide_number) previous_slide_number = slide_number - 1 if slide_number > 1 else slide_count previous_slide_file_name = make_slide_file_name(previous_slide_number) title = parse_slide_title(markdown_file_name) template.main(template_file_name, slide_file_name, title, next_slide_file_name, previous_slide_file_name)
def makePage(paths, date): sys.path.append(paths["pydir"]) fil = __import__(paths["fname"]) firsts = "" seconds = "" try: try: for lang in fil.contents.iterkeys(): output = template.main({"title":fil.title[lang], "contents":fil.contents[lang], \ "style":fil.style, "time":date, "first":firsts, "second":seconds}) #print(fil.title filesNeeded = fil.filesNeeded for f in filesNeeded: src = paths["filesNeeded"] + f out = paths["output"] + f if not updateFiles.copy(src, out): print("%s was not copied" % src) mkdir.makeDir(paths["output"] % (os.sep + lang + os.sep)) write( str(output), paths["output"] % (os.sep + lang + os.sep) + paths["fname"] + ".html") except AttributeError: #this page is not multi-lingual yet - hence is english output = template.main({"title":fil.title, "contents":fil.contents, \ "style":fil.style, "time":date, "first":firsts, "second":seconds}) #print(fil.title filesNeeded = fil.filesNeeded for f in filesNeeded: src = paths["filesNeeded"] + f out = paths["output"] + f if not updateFiles.copy(src, out): print("%s was not copied" % src) mkdir.makeDir(paths["output"] % (os.sep + "en" + os.sep)) write( str(output), paths["output"] % (os.sep + "en" + os.sep) + paths["fname"] + ".html") return True except Exception as e: print(sys.exc_info()[0]) print(e) #print([fil.title, fil.contents, fil.style, date, firsts, seconds] print("GAH", paths["pydir"], paths["fname"], "s", "GAH") return False
def test_app (capsys): # variável com a letra do arquivo de testes number = 1 while True: try: # abre um arquivo de entrada e lê o conteúdo with open('input-{}'.format(number), 'r') as f: input_values = f.read().split('\n') # abre um arquivo de entrada e lê o conteúdo with open('output-{}'.format(number), 'r') as f: expected_output = f.read() + '\n' # função que substitui o input do código def mock_input(s = ''): if s: print(s) # transforma IndexError em EOFError try: return input_values.pop(0) except IndexError: raise EOFError('EOF when reading a line') app.input = mock_input # executa o código e verifica a saída app.main() output, error = capsys.readouterr() # analisa se a saída foi igual à esperada assert output == expected_output assert error == '' # procura a próxima entrada de teste number += 1 # para o loop se não encontrar um arquivo de testes except FileNotFoundError: break
action = "store", help = ("Systematics type to be loaded: jes, pileup, " "matching, scaling")) return parser def main(): try: options, args = parser().parse_args() import comparator app = comparator.Comparator(options, args) app.run() except RuntimeError as error: # print error traceback for debug import traceback traceback.print_tb(sys.exc_info()[2]) print(error, file = sys.stderr) return 1 else: return 0 if "__main__" == __name__: sys.exit(main())
sep = "/" seconds = [[t+sep.join(x[1].split(sep)[2:]), x[-1]] for x in fList2 if sep.join(x[1].split(sep)[:-2]) == sep.join(i[1].split(sep)[:-2])] seconds = seconds + [[t + sep.join(x[1].split(sep)[2:]), x[-1]] for x in fList2 if sep.join(x[1].split(sep)[:-2]) == sep.join(i[1].split(sep)[:-3])] sep = os.sep #print i[-1] #for j in seconds: print j[0], j[1] #print #print firsts = htmlList(firsts) seconds = htmlList(seconds) firsts = "" seconds = "" try: output = template.main({"title":fil.title, "contents":fil.contents, \ "style":fil.style, "time":date, "first":firsts, "second":seconds}) #print fil.title filesNeeded = fil.filesNeeded for f in filesNeeded: src = i[2] + f out = i[1] + f if not updateFiles.copy(src, out): print "%s was not copied" % src mkdir.makeDir(i[1]) write(str(output), i[1]+i[3]+".html") except Exception, e: print sys.exc_info()[0] print e #print [fil.title, fil.contents, fil.style, date, firsts, seconds] print "GAH", i[0], i[3], "s", "GAH" """
import template as t t.main( t.login('grohk'), # r 'grohk', # qui 'test', # sub t.misspellchk, # fun t.defaultfooter, # footer {"grohk_cash":00.00}, # jsonbackup, misc r"(?i)\b(?:ghroc?k|grog?c?k|grochk|grokh|ghroh?c|grog?hc|groghk|grhock|grhoc?k?|groh?nh?k?c?)\b", "grohk" )
import template as t t.main(t.login('maeve'), 'maeve', 'test', t.misspellchk, t.defaultfooter, {"maeve_cash": 00.00}, r"(?i)(?:me?ai?y?u?ve|mayve?)", "maeve")
if __name__ == "__main__": from template import fibo, main main()
def write(info, filename): f = open(filename, "w") f.write(info) f.close() updated = [] i = sys.argv[1] i = i.split()[0] k = i.split("/") i = k.pop() i = i.split(".")[0] path = toRemove for h in k: path += h path += "/" sys.path.append(path) j = __import__(i) output = template.main({ "title": j.title, "contents": j.contents, "style": j.style }) write(str(output), path + i + ".html") updated.append(i + ".html") for i in updated: #print i + " has been updated." pass