当前位置: 首页>>代码示例>>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;未经允许,请勿转载。