Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import argparse
- import sys
- class Config(object):
- def __init__(self, fileLoc):
- self.configFile = open(fileLoc, 'r')
- def __iter__(self):
- return self
- def next(self):
- # throws StopIteration exception
- line = self.configFile.next()
- # TODO: change line here
- return line
- def main(fileLoc):
- config = Config(fileLoc)
- for line in config:
- sys.stdout.write(line)
- if __name__ == '__main__':
- parser = argparse.ArgumentParser(description='parse a file')
- parser.add_argument('file', help='file to parse')
- args = parser.parse_args()
- main(args.file)
Advertisement
Add Comment
Please, Sign In to add comment