• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.file_ext函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mrjob.util.file_ext函数的典型用法代码示例。如果您正苦于以下问题:Python file_ext函数的具体用法?Python file_ext怎么用?Python file_ext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了file_ext函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _syslog_to_stderr_path

def _syslog_to_stderr_path(path):
    """Get the path/uri of the stderr log corresponding to the given syslog.

    If the syslog is gzipped (/path/to/syslog.gz), we'll expect
    stderr to be gzipped too (/path/to/stderr.gz).
    """
    stem, filename = posixpath.split(path)
    return posixpath.join(stem, 'stderr' + file_ext(filename))
开发者ID:Dean838,项目名称:mrjob,代码行数:8,代码来源:task.py


示例2: filter_path

 def filter_path(path):
     filename = os.path.basename(path)
     return not(file_ext(filename).lower() in ('.pyc', '.pyo') or
         # filter out emacs backup files
         filename.endswith('~') or
         # filter out emacs lock files
         filename.startswith('.#') or
         # filter out MacFuse resource forks
         filename.startswith('._'))
开发者ID:icio,项目名称:mrjob,代码行数:9,代码来源:runner.py


示例3: _unarchive_file

    def _unarchive_file(self, path, dest):
        path = os.path.abspath(path)
        
        # figure out how to unarchive the file, based on its extension
        unarchive_args = HOW_TO_UNARCHIVE.get(file_ext(path))

        if not unarchive_args:
            raise ValueError("Don't know how to unarchive %s" % path)

        log.debug('unarchiving %s -> %s' % (path, dest))
        self.mkdir(dest)
        check_call(unarchive_args + [path], cwd=dest)
开发者ID:atiw003,项目名称:mrjob,代码行数:12,代码来源:local.py


示例4: test_file_ext

 def test_file_ext(self):
     self.assertEqual(file_ext('foo.zip'), '.zip')
     self.assertEqual(file_ext('foo.Z'), '.Z')
     self.assertEqual(file_ext('foo.tar.gz'), '.tar.gz')
     self.assertEqual(file_ext('README'), '')
     self.assertEqual(file_ext('README,v'), '')
     self.assertEqual(file_ext('README.txt,v'), '.txt,v')
开发者ID:anirudhreddy92,项目名称:mrjob,代码行数:7,代码来源:test_util.py


示例5: test_file_ext

 def test_file_ext(self):
     self.assertEqual(file_ext("foo.zip"), ".zip")
     self.assertEqual(file_ext("foo.Z"), ".Z")
     self.assertEqual(file_ext("foo.tar.gz"), ".tar.gz")
     self.assertEqual(file_ext("README"), "")
     self.assertEqual(file_ext("README,v"), "")
     self.assertEqual(file_ext("README.txt,v"), ".txt,v")
开发者ID:bchess,项目名称:mrjob,代码行数:7,代码来源:test_util.py


示例6: filter_path

 def filter_path(path):
     filename = os.path.basename(path)
     return not (
         file_ext(filename).lower() in (".pyc", ".pyo")
         or
         # filter out emacs backup files
         filename.endswith("~")
         or
         # filter out emacs lock files
         filename.startswith(".#")
         or
         # filter out MacFuse resource forks
         filename.startswith("._")
     )
开发者ID:irskep,项目名称:mrjob,代码行数:14,代码来源:runner.py


示例7: _master_bootstrap_script_content

    def _master_bootstrap_script_content(self, bootstrap):
        """Return a list containing the lines of the master bootstrap script.
        (without trailing newlines)
        """
        out = []

        # shebang, precommands
        out.extend(self._start_of_sh_script())
        out.append('')

        # store $PWD
        out.append('# store $PWD')
        out.append('__mrjob_PWD=$PWD')
        out.append('')

        # special case for PWD being in /, which happens on Dataproc
        # (really we should cd to tmp or something)
        out.append('if [ $__mrjob_PWD = "/" ]; then')
        out.append('  __mrjob_PWD=""')
        out.append('fi')
        out.append('')

        # run commands in a block so we can redirect stdout to stderr
        # (e.g. to catch errors from compileall). See #370
        out.append('{')

        # download files
        out.append('  # download files and mark them executable')

        cp_to_local = self._cp_to_local_cmd()

        # TODO: why bother with $__mrjob_PWD here, since we're already in it?
        for name, path in sorted(
                self._bootstrap_dir_mgr.name_to_path('file').items()):
            uri = self._upload_mgr.uri(path)
            out.append('')
            out.append('  %s %s $__mrjob_PWD/%s' %
                       (cp_to_local, pipes.quote(uri), pipes.quote(name)))
            # imitate Hadoop Distributed Cache (see #1602)
            out.append('  chmod u+rx $__mrjob_PWD/%s' % pipes.quote(name))
        out.append('')

        # download and unarchive archives
        archive_names_and_paths = sorted(
            self._bootstrap_dir_mgr.name_to_path('archive').items())
        if archive_names_and_paths:
            # make tmp dir if needed
            out.append('  # download and unpack archives')
            out.append('  __mrjob_TMP=$(mktemp -d)')
            out.append('')

            for name, path in archive_names_and_paths:
                uri = self._upload_mgr.uri(path)
                ext = file_ext(basename(path))

                # copy file to tmp dir
                quoted_archive_path = '$__mrjob_TMP/%s' % pipes.quote(name)

                out.append('  %s %s %s' % (
                    cp_to_local, pipes.quote(uri), quoted_archive_path))

                # unarchive file
                if ext not in _EXT_TO_UNARCHIVE_CMD:
                    raise KeyError('unknown archive file extension: %s' % path)
                unarchive_cmd = _EXT_TO_UNARCHIVE_CMD[ext]

                out.append('  ' + unarchive_cmd % dict(
                    file=quoted_archive_path,
                    dir='$__mrjob_PWD/' + pipes.quote(name)))

                # imitate Hadoop Distributed Cache (see #1602)
                out.append(
                    '  chmod u+rx -R $__mrjob_PWD/%s' % pipes.quote(name))

                out.append('')

        # run bootstrap commands
        out.append('  # bootstrap commands')
        for cmd in bootstrap:
            # reconstruct the command line, substituting $__mrjob_PWD/<name>
            # for path dicts
            line = '  '
            for token in cmd:
                if isinstance(token, dict):
                    # it's a path dictionary
                    line += '$__mrjob_PWD/'
                    line += pipes.quote(self._bootstrap_dir_mgr.name(**token))
                else:
                    # it's raw script
                    line += token
            out.append(line)

        out.append('} 1>&2')  # stdout -> stderr for ease of error log parsing

        return out
开发者ID:okomestudio,项目名称:mrjob,代码行数:95,代码来源:cloud.py



注:本文中的mrjob.util.file_ext函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.log_to_stream函数代码示例发布时间:2022-05-27
下一篇:
Python util.expand_path函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap