def FileInputStream(filename, real_filename=None, **args):
 assert isinstance(filename, unicode)
 if (not real_filename):
  real_filename = filename
 try:
  inputio = open(real_filename, 'rb')
 except IOError as err:
  charset = getTerminalCharset()
  errmsg = unicode(str(err), charset)
  raise InputStreamError((_('Unable to open file %s: %s') % (filename, errmsg)))
 source = ('file:' + filename)
 offset = args.pop('offset', 0)
 size = args.pop('size', None)
 if (offset or size):
  if size:
   size = (8 * size)
  stream = InputIOStream(inputio, source=source, **args)
  return InputSubStream(stream, (8 * offset), size, **args)
 else:
  args.setdefault('tags', []).append(('filename', filename))
  return InputIOStream(inputio, source=source, **args)

def FileInputStream ( filename , real_filename = None , ** args ) : assert isinstance ( filename , unicode ) if ( not real_filename ) : real_filename = filename try : inputio = open ( real_filename , 'rb' ) except IOError as err : charset = getTerminalCharset ( ) errmsg = unicode ( str ( err ) , charset ) raise InputStreamError ( ( _ ( 'Unable to open file %s: %s' ) % ( filename , errmsg ) ) ) source = ( 'file:' + filename ) offset = args . pop ( 'offset' , 0 ) size = args . pop ( 'size' , None ) if ( offset or size ) : if size : size = ( 8 * size ) stream = InputIOStream ( inputio , source = source , ** args ) return InputSubStream ( stream , ( 8 * offset ) , size , ** args ) else : args . setdefault ( 'tags' , [ ] ) . append ( ( 'filename' , filename ) ) return InputIOStream ( inputio , source = source , ** args )
create an input stream of a file .