我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用distutils.errors.DistutilsTemplateError()。
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)
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)
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"