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


Python errors.DistutilsTemplateError方法代碼示例

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


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

示例1: _parse_template_line

# 需要導入模塊: from distutils import errors [as 別名]
# 或者: from distutils.errors import DistutilsTemplateError [as 別名]
def _parse_template_line(self, line):
        words = line.split()
        action = words[0]

        patterns = dir = dir_pattern = None

        if action in ('include', 'exclude',
                      'global-include', 'global-exclude'):
            if len(words) < 2:
                raise DistutilsTemplateError, \
                      "'%s' expects <pattern1> <pattern2> ..." % action

            patterns = map(convert_path, words[1:])

        elif action in ('recursive-include', 'recursive-exclude'):
            if len(words) < 3:
                raise DistutilsTemplateError, \
                      "'%s' expects <dir> <pattern1> <pattern2> ..." % action

            dir = convert_path(words[1])
            patterns = map(convert_path, words[2:])

        elif action in ('graft', 'prune'):
            if len(words) != 2:
                raise DistutilsTemplateError, \
                     "'%s' expects a single <dir_pattern>" % action

            dir_pattern = convert_path(words[1])

        else:
            raise DistutilsTemplateError, "unknown action '%s'" % action

        return (action, patterns, dir, dir_pattern) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:35,代碼來源:filelist.py

示例2: _parse_template_line

# 需要導入模塊: from distutils import errors [as 別名]
# 或者: from distutils.errors import DistutilsTemplateError [as 別名]
def _parse_template_line(self, line):
        words = line.split()
        action = words[0]

        patterns = dir = dir_pattern = None

        if action in ('include', 'exclude',
                      'global-include', 'global-exclude'):
            if len(words) < 2:
                raise DistutilsTemplateError(
                      "'%s' expects <pattern1> <pattern2> ..." % action)
            patterns = [convert_path(w) for w in words[1:]]
        elif action in ('recursive-include', 'recursive-exclude'):
            if len(words) < 3:
                raise DistutilsTemplateError(
                      "'%s' expects <dir> <pattern1> <pattern2> ..." % action)
            dir = convert_path(words[1])
            patterns = [convert_path(w) for w in words[2:]]
        elif action in ('graft', 'prune'):
            if len(words) != 2:
                raise DistutilsTemplateError(
                      "'%s' expects a single <dir_pattern>" % action)
            dir_pattern = convert_path(words[1])
        else:
            raise DistutilsTemplateError("unknown action '%s'" % action)

        return (action, patterns, dir, dir_pattern) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:29,代碼來源:filelist.py

示例3: read_template

# 需要導入模塊: from distutils import errors [as 別名]
# 或者: from distutils.errors import DistutilsTemplateError [as 別名]
def read_template(self):
        """Read and parse manifest template file named by self.template.

        (usually "MANIFEST.in") The parsing and processing is done by
        'self.filelist', which updates itself accordingly.
        """
        log.info("reading manifest template '%s'", self.template)
        template = TextFile(self.template, strip_comments=1, skip_blanks=1,
                            join_lines=1, lstrip_ws=1, rstrip_ws=1,
                            collapse_join=1)

        try:
            while True:
                line = template.readline()
                if line is None:            # end of file
                    break

                try:
                    self.filelist.process_template_line(line)
                # the call above can raise a DistutilsTemplateError for
                # malformed lines, or a ValueError from the lower-level
                # convert_path function
                except (DistutilsTemplateError, ValueError) as msg:
                    self.warn("%s, line %d: %s" % (template.filename,
                                                   template.current_line,
                                                   msg))
        finally:
            template.close() 
開發者ID:CedricGuillemet,項目名稱:Imogen,代碼行數:30,代碼來源:sdist.py

示例4: test_process_template_line_invalid

# 需要導入模塊: from distutils import errors [as 別名]
# 或者: from distutils.errors import DistutilsTemplateError [as 別名]
def test_process_template_line_invalid(self):
        # invalid lines
        file_list = FileList()
        for action in ('include', 'exclude', 'global-include',
                       'global-exclude', 'recursive-include',
                       'recursive-exclude', 'graft', 'prune', 'blarg'):
            try:
                file_list.process_template_line(action)
            except DistutilsTemplateError:
                pass
            except Exception:
                assert False, "Incorrect error thrown"
            else:
                assert False, "Should have thrown an error" 
開發者ID:pypa,項目名稱:setuptools,代碼行數:16,代碼來源:test_manifest.py

示例5: _parse_template_line

# 需要導入模塊: from distutils import errors [as 別名]
# 或者: from distutils.errors import DistutilsTemplateError [as 別名]
def _parse_template_line (self, line):
        words = string.split(line)
        action = words[0]

        patterns = dir = dir_pattern = None

        if action in ('include', 'exclude',
                      'global-include', 'global-exclude'):
            if len(words) < 2:
                raise DistutilsTemplateError, \
                      "'%s' expects <pattern1> <pattern2> ..." % action

            patterns = map(convert_path, words[1:])

        elif action in ('recursive-include', 'recursive-exclude'):
            if len(words) < 3:
                raise DistutilsTemplateError, \
                      "'%s' expects <dir> <pattern1> <pattern2> ..." % action

            dir = convert_path(words[1])
            patterns = map(convert_path, words[2:])

        elif action in ('graft', 'prune'):
            if len(words) != 2:
                raise DistutilsTemplateError, \
                     "'%s' expects a single <dir_pattern>" % action

            dir_pattern = convert_path(words[1])

        else:
            raise DistutilsTemplateError, "unknown action '%s'" % action

        return (action, patterns, dir, dir_pattern)

    # _parse_template_line () 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:37,代碼來源:filelist.py


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