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


Python _datasource.open方法代碼示例

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


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

示例1: test_Bz2File_text_mode_warning

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_Bz2File_text_mode_warning(self):
        try:
            import bz2
        except ImportError:
            # We don't have the bz2 capabilities to test.
            pytest.skip()
        # Test datasource's internal file_opener for BZip2 files.
        filepath = os.path.join(self.tmpdir, 'foobar.txt.bz2')
        fp = bz2.BZ2File(filepath, 'w')
        fp.write(magic_line)
        fp.close()
        with assert_warns(RuntimeWarning):
            fp = self.ds.open(filepath, 'rt')
            result = fp.readline()
            fp.close()
        assert_equal(magic_line, result) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:18,代碼來源:test__datasource.py

示例2: test_ValidGzipFile

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_ValidGzipFile(self):
        try:
            import gzip
        except ImportError:
            # We don't have the gzip capabilities to test.
            import nose
            raise nose.SkipTest
        # Test datasource's internal file_opener for Gzip files.
        filepath = os.path.join(self.tmpdir, 'foobar.txt.gz')
        fp = gzip.open(filepath, 'w')
        fp.write(magic_line)
        fp.close()
        fp = self.ds.open(filepath)
        result = fp.readline()
        fp.close()
        self.assertEqual(magic_line, result) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:test__datasource.py

示例3: test_Bz2File_text_mode_warning

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_Bz2File_text_mode_warning(self):
        try:
            import bz2
        except ImportError:
            # We don't have the bz2 capabilities to test.
            raise SkipTest
        # Test datasource's internal file_opener for BZip2 files.
        filepath = os.path.join(self.tmpdir, 'foobar.txt.bz2')
        fp = bz2.BZ2File(filepath, 'w')
        fp.write(magic_line)
        fp.close()
        with assert_warns(RuntimeWarning):
            fp = self.ds.open(filepath, 'rt')
            result = fp.readline()
            fp.close()
        assert_equal(magic_line, result) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:18,代碼來源:test__datasource.py

示例4: test_ValidHTTP

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_ValidHTTP(self):
        fh = self.ds.open(valid_httpurl())
        assert_(fh)
        fh.close() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:6,代碼來源:test__datasource.py

示例5: test_InvalidHTTP

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_InvalidHTTP(self):
        url = invalid_httpurl()
        assert_raises(IOError, self.ds.open, url)
        try:
            self.ds.open(url)
        except IOError as e:
            # Regression test for bug fixed in r4342.
            assert_(e.errno is None) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:10,代碼來源:test__datasource.py

示例6: test_ValidFile

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_ValidFile(self):
        local_file = valid_textfile(self.tmpdir)
        fh = self.ds.open(local_file)
        assert_(fh)
        fh.close() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:7,代碼來源:test__datasource.py

示例7: test_InvalidFile

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_InvalidFile(self):
        invalid_file = invalid_textfile(self.tmpdir)
        assert_raises(IOError, self.ds.open, invalid_file) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:5,代碼來源:test__datasource.py

示例8: test_ValidGzipFile

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_ValidGzipFile(self):
        try:
            import gzip
        except ImportError:
            # We don't have the gzip capabilities to test.
            pytest.skip()
        # Test datasource's internal file_opener for Gzip files.
        filepath = os.path.join(self.tmpdir, 'foobar.txt.gz')
        fp = gzip.open(filepath, 'w')
        fp.write(magic_line)
        fp.close()
        fp = self.ds.open(filepath)
        result = fp.readline()
        fp.close()
        assert_equal(magic_line, result) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:17,代碼來源:test__datasource.py

示例9: test_CachedHTTPFile

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_CachedHTTPFile(self):
        localfile = valid_httpurl()
        # Create a locally cached temp file with an URL based
        # directory structure.  This is similar to what Repository.open
        # would do.
        scheme, netloc, upath, pms, qry, frg = urlparse(localfile)
        local_path = os.path.join(self.repos._destpath, netloc)
        os.mkdir(local_path, 0o0700)
        tmpfile = valid_textfile(local_path)
        assert_(self.repos.exists(tmpfile)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:12,代碼來源:test__datasource.py

示例10: test_DataSourceOpen

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_DataSourceOpen(self):
        local_file = valid_textfile(self.tmpdir)
        # Test case where destpath is passed in
        fp = datasource.open(local_file, destpath=self.tmpdir)
        assert_(fp)
        fp.close()
        # Test case where default destpath is used
        fp = datasource.open(local_file)
        assert_(fp)
        fp.close() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:12,代碼來源:test__datasource.py

示例11: test_InvalidHTTP

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_InvalidHTTP(self):
        url = invalid_httpurl()
        self.assertRaises(IOError, self.ds.open, url)
        try:
            self.ds.open(url)
        except IOError as e:
            # Regression test for bug fixed in r4342.
            assert_(e.errno is None) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:10,代碼來源:test__datasource.py

示例12: test_InvalidFile

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_InvalidFile(self):
        invalid_file = invalid_textfile(self.tmpdir)
        self.assertRaises(IOError, self.ds.open, invalid_file) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:5,代碼來源:test__datasource.py

示例13: test_ValidGzipFile

# 需要導入模塊: from numpy.lib import _datasource [as 別名]
# 或者: from numpy.lib._datasource import open [as 別名]
def test_ValidGzipFile(self):
        try:
            import gzip
        except ImportError:
            # We don't have the gzip capabilities to test.
            raise SkipTest
        # Test datasource's internal file_opener for Gzip files.
        filepath = os.path.join(self.tmpdir, 'foobar.txt.gz')
        fp = gzip.open(filepath, 'w')
        fp.write(magic_line)
        fp.close()
        fp = self.ds.open(filepath)
        result = fp.readline()
        fp.close()
        self.assertEqual(magic_line, result) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:17,代碼來源:test__datasource.py


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