Skip to content

Instantly share code, notes, and snippets.

@bolthar
Created July 2, 2010 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bolthar/461046 to your computer and use it in GitHub Desktop.
Save bolthar/461046 to your computer and use it in GitHub Desktop.
class CLF(object):
#snip
def handle_cl(self):
#snip
if params and params[0]:
self.__input_stream = FileStream(params[0], 'r')
else:
self.__input_stream = IOStream(sys.stdin)
if self.outfile:
self.__output_stream = FileStream(self.outfile, self.output_mode)
else:
self.__output_stream = IOStream(sys.stdout)
#snip
def setup(self):
#snip
self.infile = self.__input_stream.get_stream()
self.outfile = self.__output_stream.get_stream()
class FileStream(object):
def __init__(self, filename, mode):
self.__filename = filename
self.__mode = mode
def get_stream(self):
return open(self.__filename, self.__mode)
class IOStream(object):
def __init__(self, stream):
self.__stream = stream
def get_stream(self):
return self.__stream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment