當前位置: 首頁>>代碼示例>>Python>>正文


Python StringIO.__init__方法代碼示例

本文整理匯總了Python中StringIO.StringIO.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python StringIO.__init__方法的具體用法?Python StringIO.__init__怎麽用?Python StringIO.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在StringIO.StringIO的用法示例。


在下文中一共展示了StringIO.__init__方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from StringIO import StringIO [as 別名]
# 或者: from StringIO.StringIO import __init__ [as 別名]
def __init__(self, xml_dir):
        unittest.TestResult.__init__(self)
        self.xml_dir = xml_dir

        # The module name of the first test ran
        self.module_name = None

        # All TestCases
        self.tests = []

        # Start time
        self.start = None

        self.old_stdout = sys.stdout
        self.old_stderr = sys.stderr
        sys.stdout = self.stdout = Tee(sys.stdout)
        sys.stderr = self.stderr = Tee(sys.stderr) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:19,代碼來源:junit_xml.py

示例2: __init__

# 需要導入模塊: from StringIO import StringIO [as 別名]
# 或者: from StringIO.StringIO import __init__ [as 別名]
def __init__(self,fp):
        self.fp = fp

        # this is nasty and needs to be fixed at some point
        # copy everything into a StringIO (compressed)
        compressed = StringIO()
        r = fp.read()
        while r:
            compressed.write(r)
            r = fp.read()
        # now, unzip (gz) the StringIO to a string
        compressed.seek(0,0)
        gz = GzipFile(fileobj = compressed)
        str = ''
        r = gz.read()
        while r:
            str += r
            r = gz.read()
        # close our utility files
        compressed.close()
        gz.close()
        # init our stringio selves with the string 
        StringIO.__init__(self, str)
        del str 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:26,代碼來源:zurllib.py

示例3: __init__

# 需要導入模塊: from StringIO import StringIO [as 別名]
# 或者: from StringIO.StringIO import __init__ [as 別名]
def __init__(self, fp):
        data = fp.read()
        StringIO.__init__(self, data) 
開發者ID:awslabs,項目名稱:mxnet-lambda,代碼行數:5,代碼來源:ImageFileIO.py

示例4: connect

# 需要導入模塊: from StringIO import StringIO [as 別名]
# 或者: from StringIO.StringIO import __init__ [as 別名]
def connect(self):
        """Connect to the host and port specified in __init__."""

        ident = thread.get_ident()
        # never, ever, ever call urlopen from any of these threads        
        assert ident not in unsafe_threads, "You may not use urllib from this thread!"

        msg = "getaddrinfo returns an empty list"
        for res in socket.getaddrinfo(self.host, self.port, 0,
                                      socket.SOCK_STREAM):
            af, socktype, proto, canonname, sa = res

            addr = sa[0]
            # the obvious multithreading problem is avoided by using locks.
            # the lock is only acquired during the function call, so there's
            # no danger of urllib blocking rawserver.
            rawserver.add_pending_connection(addr)
            try:
                self.sock = socket.socket(af, socktype, proto)
                self.sock.settimeout(url_socket_timeout)
                if http_bindaddr:
                    self.sock.bind((http_bindaddr, 0))
                if self.debuglevel > 0:
                    print "connect: (%s, %s)" % (self.host, self.port)
                self.sock.connect(sa)
            except socket.error, msg:
                if self.debuglevel > 0:
                    print 'connect fail:', (self.host, self.port)
                if self.sock:
                    self.sock.close()
                self.sock = None
            rawserver.remove_pending_connection(addr)

            if self.sock:
                break 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:37,代碼來源:zurllib.py


注:本文中的StringIO.StringIO.__init__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。