def main(): """ Creates an instance of the formatter and asks it to process the lines for us. """ # Fun stuff to parse args parser = OptionParser() parser.add_option("-s", "--strict", action="store_true", default=False, help="Throw exceptions on when encountering bad input.") (options, args) = parser.parse_args() # If we are in verbose we need to ignore the first arg. if options.strict is True: formatter = seng265_formatter( [line for line in fileinput.input(sys.argv[2:])], strict=True) else: formatter = seng265_formatter([line for line in fileinput.input()]) lines = formatter.get_lines() if lines != []: print "".join(lines), else: return
def main(): s = """?pgwdth 50 ?mrgn 15 Call me Ishmael. Some years ago--never mind how long precisely--having little or no money in my purse, and nothing particular to interest me on ?mrgn +5 shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; ?mrgn +5 whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up ?mrgn +5 the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to ?mrgn +5 prevent me from deliberately stepping into the street, and methodically knocking people's hats off--then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a ?mrgn +5 philosophical flourish Cato throws himself upon his sword; I quietly ?mrgn +5 take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me. There now is your insular city of the Manhattoes, belted round by ?mrgn +5 wharves as Indian isles by coral reefs--commerce surrounds it with her surf. Right and left, the streets take you waterward. Its extreme downtown is the battery, where that noble mole is washed by waves, and ?mrgn +5 cooled by breezes, which a few hours previous were out of sight of land. Look at the crowds of water-gazers there.""" fp_exist = 0 #variable for checking if tempwrite.txt exists fp = "" if(len(sys.argv)>1): fp = sys.argv[1] if(re.match(r"\.txt$",fp)): pass else: process_stdin() fp_exist = 1 fp = "tempwrite.txt" if(check_if_empty(fp)): fp = s.splitlines() fp_exist = 0 f = seng265_formatter(fp) f = f.get_lines() for x in f: print x, if(fp_exist!=0): os.remove("tempwrite.txt") fp_exist=0
def main(): """ Creates an instance of the formatter and asks it to process the lines for us. """ # Fun stuff to parse args parser = OptionParser() parser.add_option("-s", "--strict", action="store_true", default=False, help="Throw exceptions on when encountering bad input.") (options, args) = parser.parse_args() # If we are in verbose we need to ignore the first arg. if options.strict is True: formatter = seng265_formatter( [line for line in fileinput.input(sys.argv[2:])], strict=True ) else: formatter = seng265_formatter( [line for line in fileinput.input()] ) lines = formatter.get_lines() if lines != []: print "".join(lines), else: return
def main(): s = """?pgwdth 50 ?mrgn 15 Call me Ishmael. Some years ago--never mind how long precisely--having little or no money in my purse, and nothing particular to interest me on ?mrgn +5 shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; ?mrgn +5 whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up ?mrgn +5 the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to ?mrgn +5 prevent me from deliberately stepping into the street, and methodically knocking people's hats off--then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a ?mrgn +5 philosophical flourish Cato throws himself upon his sword; I quietly ?mrgn +5 take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me. There now is your insular city of the Manhattoes, belted round by ?mrgn +5 wharves as Indian isles by coral reefs--commerce surrounds it with her surf. Right and left, the streets take you waterward. Its extreme downtown is the battery, where that noble mole is washed by waves, and ?mrgn +5 cooled by breezes, which a few hours previous were out of sight of land. Look at the crowds of water-gazers there.""" lines = s.splitlines() f = seng265_formatter(inputlines=lines) lines = f.get_lines() for l in lines: print l