Example #1
0
 def __init__(self, file, auto_flush=False, queue=None):
     #super(TeeFile, self).__init__()
     StringIO.__init__(self)
     self.file = file
     self.auto_flush = auto_flush
     self.length = 0
     self.queue = queue
     self.queue_buffer = []
Example #2
0
    def __init__(self,
                 uri,
                 data='',
                 filename='',
                 mimeType='',
                 format='',
                 accept=''):
        self.uri = uri
        if data:
            self.data = data.decode()
        elif filename:
            if os.path.exists(filename):
                fh = open(filename)
                self.data = fh.read().decode()
                fh.close()
        else:
            # try to fetch uri
            try:
                req = urllib.request.Request(uri)
                if accept:
                    # add custom accept header
                    req.add_header('Accept', accept)
                else:
                    # otherwise add default
                    req.add_header('Accept', accept_header)
                fh = urllib.request.urlopen(req)
                self.data = fh.read().decode()
                self.info = fh.info().decode()
                mimeType = self.info.dict.get('content-type', mimeType)
                self.uri = fh.geturl().decode()
                fh.close()
            except:
                raise OreException(
                    'ReMDocument must either have data or filename')

            if not format:
                try:
                    mt = conneg.parse(mimeType)
                    if mt:
                        mimeType = mt[0].mimetype1 + '/' + mt[0].mimetype2
                except:
                    pass
                mimeHash = {
                    'application/atom+xml': 'atom',
                    'application/xhtml+xml': 'rdfa',
                    'application/rdf+xml': 'xml',
                    'text/plain': 'nt',  # yes, really
                    'text/rdf+n3': 'n3',
                    'application/x-turtle': 'turtle',
                    'application/rdf+nt': 'nt'
                }
                format = mimeHash.get(mimeType, '')

        self.mimeType = mimeType
        self.format = format
        StringIO.__init__(self, self.data)
 def __init__(self, data):
     StringIO.__init__(self)
     self.buffer = Testcommandline.Mystdin.bufferemulator()
     if(sys.hexversion > 0x03000000):
         if(isinstance(data, bytearray)):
             self.buffer.bytedata = data
         else:
             self.buffer.bytedata = bytearray([ord(x) for x in data])
     else:
         self.write(data)
         self.seek(0)
Example #4
0
 def __init__(self, buffer='', cc=None):
     """
     If ``cc`` is given and is a file-like object or an iterable of same,
     it/they will be written to whenever this StringIO instance is written
     to.
     """
     StringIO.__init__(self, buffer)
     if cc is None:
         cc = []
     elif hasattr(cc, 'write'):
         cc = [cc]
     self.cc = cc
Example #5
0
 def __init__(self, buffer='', cc=None):
     """
     If ``cc`` is given and is a file-like object or an iterable of same,
     it/they will be written to whenever this StringIO instance is written
     to.
     """
     StringIO.__init__(self, buffer)
     if cc is None:
         cc = []
     elif hasattr(cc, 'write'):
         cc = [cc]
     self.cc = cc
Example #6
0
 def __init__(self, *args):
     try:
         self.code = args[1]
     except IndexError:
         self.code = 200
         pass
     try:
         self.msg = args[2]
     except IndexError:
         self.msg = "OK"
         pass
     self.headers = {'content-type': 'text/plain; charset=utf-8'}
     StringIO.__init__(self, unicode(args[0]))
Example #7
0
    def __init__(self, filename):
        """
        constructor

        @param      filename        filename
        """
        StringIO.__init__(self)
        self.filename = filename
        if os.path.exists(filename):
            os.remove(filename)
        self.handle = None
        self.redirect = {}
        self.to = None
Example #8
0
 def __init__(self, *args):
     try:
         self.code = args[1]
     except IndexError:
         self.code = 200
         pass
     try:
         self.msg = args[2]
     except IndexError:
         self.msg = "OK"
         pass
     self.headers = {'content-type': 'text/plain; charset=utf-8'}
     StringIO.__init__(self, unicode(args[0]))
Example #9
0
    def __init__(self, buffer="", writers=None):
        """Init CCStringIO

        If ``writers`` is given and is a file-like object or an
        iterable of same, it/they will be written to whenever this
        StringIO instance is written to.
        """
        StringIO.__init__(self, buffer)
        if writers is None:
            writers = []
        elif hasattr(writers, "write"):
            writers = [writers]
        self.writers = writers
Example #10
0
    def __init__(self, *args, **kwargs):
        if 'dispStdout' in kwargs:
            self.dispStdout = kwargs['dispStdout']
            del kwargs['dispStdout']
        else:
            self.dispStdout = True
        StringIO.__init__(self, *args, **kwargs)

        self.matcher = (
            (self.reAttached, 'attached', True),
            # ( self.reAttached,      'running',      True ),
            # ( self.reNotRunning,    'running',      False),
            (self.reDetached, 'attached', False),
            (self.reBreakonexitOn, 'breakonexit', True),
            (self.reBreakonexitOff, 'breakonexit', False),
            (self.reWaitingOnBp, 'waitingOnBp', True),
            (self.reNotWaitingOnBp, 'waitingOnBp', False),
        )

        for m in self.matcher:
            setattr(self, m[1], False)

        self.lineCount = 0
Example #11
0
 def __init__(self, value=None, path=None):
     init = lambda x: StringIO.__init__(self, x)
     if value is None:
         init("")
         ftype = 'dir'
         size = 4096
     else:
         init(value)
         ftype = 'file'
         size = len(value)
     attr = ssh.SFTPAttributes()
     attr.st_mode = {'file': stat.S_IFREG, 'dir': stat.S_IFDIR}[ftype]
     attr.st_size = size
     attr.filename = os.path.basename(path)
     self.attributes = attr
Example #12
0
 def __init__(self, value=None, path=None):
     init = lambda x: StringIO.__init__(self, x)
     if value is None:
         init("")
         ftype = 'dir'
         size = 4096
     else:
         init(value)
         ftype = 'file'
         size = len(value)
     attr = ssh.SFTPAttributes()
     attr.st_mode = {'file': stat.S_IFREG, 'dir': stat.S_IFDIR}[ftype]
     attr.st_size = size
     attr.filename = os.path.basename(path)
     self.attributes = attr
Example #13
0
 def __init__(self, arg):
     StringIO.__init__(self, arg)
Example #14
0
 def __init__(self, stream):
     StringIO.__init__(self)
     self.stream = stream
Example #15
0
 def __init__(self, logger, log_level, fileno=0, *args, **kwargs):
     self.logger = logger
     self.log_level = log_level
     self.__fileno = fileno
     StringIO.__init__(self, *args, **kwargs)
Example #16
0
 def __init__(self, parent=None, buf=''):
     StringIO.__init__(self, buf)
     self.parent = parent
     self.dialog = None
     self.ignore = ['\x1b[?25l', '\x1b[?25h', '']
     self.clearln = '\r\x1b[K'
Example #17
0
 def __init__(self, stdout):
     self.__stdout = stdout
     StringIO.__init__(self)
Example #18
0
 def __init__(self, filename, mode, encoding=None):
     self.filename = filename
     StringIO.__init__(self)
Example #19
0
 def __init__(self, out=None, buf=""):
     self._out=out
     StringIO.__init__(self,buf)
Example #20
0
 def __init__(self, filename=None, mode=None):
     StringIO.__init__(self, '')
Example #21
0
 def __init__(self, channel='stdout'):
     StringIO.__init__(self)
     self.channel = channel
Example #22
0
 def __init__(self, *args, **kwargs):
     StringIO.__init__(self, *args, **kwargs)
     self._indent = 0
Example #23
0
 def __init__(self, initial_data=None, encoding='utf-8', errors='strict'):
     StringIO.__init__(self)
     self._encoding_for_bytes = encoding
     self._errors = errors
     if initial_data is not None:
         self.write(initial_data)
Example #24
0
	def __init__(self, orig):
		StringIO.__init__(self)
		self.thread = threading.current_thread()
		self.orig = orig
 def __init__(self):
     StringIO.__init__(self)
     self.buffer = Testcommandline.Mystdout.bufferemulator()
Example #26
0
 def __init__(self,stream):
   StringIO.__init__(self)
   self.stream = stream
Example #27
0
 def __init__(self, fp):
     data = fp.read()
     StringIO.__init__(self, data)
Example #28
0
 def __init__(self):
     StringIO.__init__(self)  # can't use super() since StringIO is an old-style class
     self.last_sleep = 0
Example #29
0
 def __init__(self, pipeout):
     self.pipeout = pipeout
     StringIO.__init__(self, "", pipeout.encoding)
Example #30
0
 def __init__(self, buf=''):
     StringIO.__init__(self, universal_newlines(buf))
Example #31
0
 def __init__(self, buf=""):
     self.stop = False
     StringIO.__init__(self, buf)
Example #32
0
 def __init__(self, initial_data=None, encoding='utf-8', errors='strict'):
     StringIO.__init__(self)
     self._encoding_for_bytes = encoding
     self._errors = errors
     if initial_data is not None:
         self.write(initial_data)
Example #33
0
 def __init__(self, *args, **kwargs): StringIO.__init__(self, *args, **kwargs)
 def eof(self): return self.tell() >= self.len  # return true if next read will cause EOFError
Example #34
0
 def __init__(self, string):
     StringIO.__init__(self, string)
Example #35
0
 def __init__(self, out=None, buf=""):
     self._out=out
     StringIO.__init__(self,buf)
Example #36
0
 def __init__(self) -> None:
     StringIO.__init__(self)
     self.stdout = sys.stdout
     self.logger = logging.getLogger("root")
     sys.stdout = self
 def __init__(self, done):
     StringIO.__init__(self)
     self.done = done
Example #38
0
 def __init__(self):
     StringIO.__init__(self)
Example #39
0
 def __init__(self):
     self._init_params = None
     StringIO.__init__(self)
     self._closed = False
Example #40
0
 def __init__(self, buffer, bits=ELFCLASS.ELFCLASS32, endianness=ELFDATA.ELFDATA2LSB, addr_size=4):
     StringIO.__init__(self, buffer)
     self.set_bits(bits)
     self.set_endianness(endianness)
     DwarfStream.__init__(self, addr_size)
Example #41
0
 def __init__(self, *args, **kwargs):
     StringIO.__init__(self, *args, **kwargs)
     self._indent = 0
Example #42
0
 def __init__(self, *args, **kwargs):
     StringIO.__init__(self, *args, **kwargs)
     self._stack = [self.new_block()]
Example #43
0
 def __init__(self):
   StringIO.__init__(self)
   self.scope = 0
Example #44
0
 def __init__(self, val):
     StringIO.__init__(self, val)
     self.name = "image.png"
Example #45
0
 def __init__(self, buf, url):
     string_io.__init__(self, buf)
     self.url = url
 def __init__(self, value=''):
     self.close_called = False
     StringIO.__init__(self, value)
Example #47
0
 def __init__(self, fp):
     data = fp.read()
     StringIO.__init__(self, data)
 def __init__(self):
     StringIO.__init__(self)
     self.buffer = Testformating.Mystdout.bufferemulator()
Example #49
0
 def __init__(self, parent=None, buf=''):
     StringIO.__init__(self, buf)
     self.parent = parent
     self.dialog = None
     self.ignore = ['\x1b[?25l', '\x1b[?25h', '']
     self.clearln = '\r\x1b[K'
Example #50
0
 def __init__(self, filename, mode):
     self.filename = filename
     StringIO.__init__(self)
Example #51
0
 def __init__(self, filename, mode, encoding=None):
     self.filename = filename
     StringIO.__init__(self)
Example #52
0
 def __init__(self, parent, stderr):
     self._match = re.compile('\s*(\d*\.?\d*)')
     self.__stderr = stderr
     self._parent = parent
     self._line = ""
     StringIO.__init__(self)