本文整理汇总了Python中mrjob.inline.InlineMRJobRunner._create_dir_archive方法的典型用法代码示例。如果您正苦于以下问题:Python InlineMRJobRunner._create_dir_archive方法的具体用法?Python InlineMRJobRunner._create_dir_archive怎么用?Python InlineMRJobRunner._create_dir_archive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mrjob.inline.InlineMRJobRunner
的用法示例。
在下文中一共展示了InlineMRJobRunner._create_dir_archive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_empty_dir
# 需要导入模块: from mrjob.inline import InlineMRJobRunner [as 别名]
# 或者: from mrjob.inline.InlineMRJobRunner import _create_dir_archive [as 别名]
def test_empty_dir(self):
runner = InlineMRJobRunner()
empty_dir = self.makedirs('empty')
tar_gz_path = runner._dir_archive_path(empty_dir)
self.assertEqual(os.path.basename(tar_gz_path), 'empty.tar.gz')
runner._create_dir_archive(empty_dir)
with tarfile.open(tar_gz_path, 'r:gz') as tar_gz:
self.assertEqual(sorted(tar_gz.getnames()), [])
示例2: test_only_create_archive_once
# 需要导入模块: from mrjob.inline import InlineMRJobRunner [as 别名]
# 或者: from mrjob.inline.InlineMRJobRunner import _create_dir_archive [as 别名]
def test_only_create_archive_once(self):
runner = InlineMRJobRunner()
tar_gz_path = runner._dir_archive_path(self._to_archive)
runner._create_dir_archive(self._to_archive)
mtime_1 = os.stat(tar_gz_path).st_mtime
sleep(1)
runner._create_dir_archive(self._to_archive)
mtime_2 = os.stat(tar_gz_path).st_mtime
self.assertEqual(mtime_1, mtime_2)
示例3: test_archive
# 需要导入模块: from mrjob.inline import InlineMRJobRunner [as 别名]
# 或者: from mrjob.inline.InlineMRJobRunner import _create_dir_archive [as 别名]
def test_archive(self):
runner = InlineMRJobRunner()
tar_gz_path = runner._dir_archive_path(self._to_archive)
self.assertEqual(os.path.basename(tar_gz_path), 'archive.tar.gz')
runner._create_dir_archive(self._to_archive)
tar_gz = tarfile.open(tar_gz_path, 'r:gz')
try:
self.assertEqual(sorted(tar_gz.getnames()),
[os.path.join('bar', 'baz'), 'foo'])
finally:
tar_gz.close()