def main(): p=Path(sys.argv[1]) ctabel = CmdTable() out_filename= p.stem inputfile_list = {} if p.is_file(): outputfile = str(p.parent / (out_filename + ".asm")) inputfile_list[str(p)] = p.stem elif p.is_dir(): outputfile = p / (out_filename + ".asm") for pfile in p.glob('*.vm'): inputfile_list[str(pfile)] = pfile.stem fout = open(outputfile, mode='w') cw = CodeWriter(fout, ctabel) if p.is_dir(): cw.writeBoot() for inf, infname in inputfile_list.items(): write_vm1(inf, infname, ctabel, cw) fout.close()