当前位置: 首页>>代码示例>>Python>>正文


Python pipes.Template方法代码示例

本文整理汇总了Python中pipes.Template方法的典型用法代码示例。如果您正苦于以下问题:Python pipes.Template方法的具体用法?Python pipes.Template怎么用?Python pipes.Template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pipes的用法示例。


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

示例1: testSimplePipe1

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def testSimplePipe1(self):
        t = pipes.Template()
        t.append(s_command, pipes.STDIN_STDOUT)
        f = t.open(TESTFN, 'w')
        f.write('hello world #1')
        f.close()
        with open(TESTFN) as f:
            self.assertEqual(f.read(), 'HELLO WORLD #1') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_pipes.py

示例2: testSimplePipe2

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def testSimplePipe2(self):
        with open(TESTFN, 'w') as f:
            f.write('hello world #2')
        t = pipes.Template()
        t.append(s_command + ' < $IN > $OUT', pipes.FILEIN_FILEOUT)
        t.copy(TESTFN, TESTFN2)
        with open(TESTFN2) as f:
            self.assertEqual(f.read(), 'HELLO WORLD #2') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_pipes.py

示例3: testSimplePipe3

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def testSimplePipe3(self):
        with open(TESTFN, 'w') as f:
            f.write('hello world #2')
        t = pipes.Template()
        t.append(s_command + ' < $IN', pipes.FILEIN_STDOUT)
        with t.open(TESTFN, 'r') as f:
            self.assertEqual(f.read(), 'HELLO WORLD #2') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_pipes.py

示例4: testEmptyPipeline1

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def testEmptyPipeline1(self):
        # copy through empty pipe
        d = 'empty pipeline test COPY'
        with open(TESTFN, 'w') as f:
            f.write(d)
        with open(TESTFN2, 'w') as f:
            f.write('')
        t=pipes.Template()
        t.copy(TESTFN, TESTFN2)
        with open(TESTFN2) as f:
            self.assertEqual(f.read(), d) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_pipes.py

示例5: testEmptyPipeline2

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def testEmptyPipeline2(self):
        # read through empty pipe
        d = 'empty pipeline test READ'
        with open(TESTFN, 'w') as f:
            f.write(d)
        t=pipes.Template()
        with t.open(TESTFN, 'r') as f:
            self.assertEqual(f.read(), d) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_pipes.py

示例6: testRepr

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def testRepr(self):
        t = pipes.Template()
        self.assertEqual(repr(t), "<Template instance, steps=[]>")
        t.append('tr a-z A-Z', pipes.STDIN_STDOUT)
        self.assertEqual(repr(t),
                    "<Template instance, steps=[('tr a-z A-Z', '--')]>") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_pipes.py

示例7: testSetDebug

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def testSetDebug(self):
        t = pipes.Template()
        t.debug(False)
        self.assertEqual(t.debugging, False)
        t.debug(True)
        self.assertEqual(t.debugging, True) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_pipes.py

示例8: testReadOpenSink

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def testReadOpenSink(self):
        # check calling open('r') on a pipe ending with
        # a sink raises ValueError
        t = pipes.Template()
        t.append('boguscmd', pipes.SINK)
        self.assertRaises(ValueError, t.open, 'bogusfile', 'r') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_pipes.py

示例9: testWriteOpenSource

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def testWriteOpenSource(self):
        # check calling open('w') on a pipe ending with
        # a source raises ValueError
        t = pipes.Template()
        t.prepend('boguscmd', pipes.SOURCE)
        self.assertRaises(ValueError, t.open, 'bogusfile', 'w') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_pipes.py

示例10: testBadAppendOptions

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def testBadAppendOptions(self):
        t = pipes.Template()

        # try a non-string command
        self.assertRaises(TypeError, t.append, 7, pipes.STDIN_STDOUT)

        # try a type that isn't recognized
        self.assertRaises(ValueError, t.append, 'boguscmd', 'xx')

        # shouldn't be able to append a source
        self.assertRaises(ValueError, t.append, 'boguscmd', pipes.SOURCE)

        # check appending two sinks
        t = pipes.Template()
        t.append('boguscmd', pipes.SINK)
        self.assertRaises(ValueError, t.append, 'boguscmd', pipes.SINK)

        # command needing file input but with no $IN
        t = pipes.Template()
        self.assertRaises(ValueError, t.append, 'boguscmd $OUT',
                           pipes.FILEIN_FILEOUT)
        t = pipes.Template()
        self.assertRaises(ValueError, t.append, 'boguscmd',
                           pipes.FILEIN_STDOUT)

        # command needing file output but with no $OUT
        t = pipes.Template()
        self.assertRaises(ValueError, t.append, 'boguscmd $IN',
                           pipes.FILEIN_FILEOUT)
        t = pipes.Template()
        self.assertRaises(ValueError, t.append, 'boguscmd',
                           pipes.STDIN_FILEOUT) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:34,代码来源:test_pipes.py

示例11: testBadOpenMode

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def testBadOpenMode(self):
        t = pipes.Template()
        self.assertRaises(ValueError, t.open, 'bogusfile', 'x') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_pipes.py

示例12: testClone

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def testClone(self):
        t = pipes.Template()
        t.append('tr a-z A-Z', pipes.STDIN_STDOUT)

        u = t.clone()
        self.assertNotEqual(id(t), id(u))
        self.assertEqual(t.steps, u.steps)
        self.assertNotEqual(id(t.steps), id(u.steps))
        self.assertEqual(t.debugging, u.debugging) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_pipes.py

示例13: to_png_file

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def to_png_file(self, fname: str):
        """
        write a '.png' file.
        """
        cmd = pipes.Template()
        cmd.append('dot -Tpng > %s' % fname, '-.')
        with cmd.open('pipefile', 'w') as f:
            f.write(self.to_dot()) 
开发者ID:LionelAuroux,项目名称:pyrser,代码行数:10,代码来源:state.py

示例14: to_dot

# 需要导入模块: import pipes [as 别名]
# 或者: from pipes import Template [as 别名]
def to_dot(self) -> str:
        lscat = []
        for nsr in self.nsr:
            f = tempfile.NamedTemporaryFile(delete=False)
            f.close()
            lscat.append(f.name)
            nsr.to_dot_file(f.name)
        cmd = pipes.Template()
        cmd.prepend('gvpack 2>/dev/null -u ' + ' '.join(lscat), '.-')
        content = ""
        with cmd.open('pipefile', 'r') as f:
            content += f.read()
        for f in lscat:
            os.unlink(f)
        return content 
开发者ID:LionelAuroux,项目名称:pyrser,代码行数:17,代码来源:state.py


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