本文整理汇总了Python中MAST.utility.MASTFile.get_segment方法的典型用法代码示例。如果您正苦于以下问题:Python MASTFile.get_segment方法的具体用法?Python MASTFile.get_segment怎么用?Python MASTFile.get_segment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MAST.utility.MASTFile
的用法示例。
在下文中一共展示了MASTFile.get_segment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from MAST.utility import MASTFile [as 别名]
# 或者: from MAST.utility.MASTFile import get_segment [as 别名]
newfile.data.append("testdir = os.path.join(os.getenv(\"MAST_INSTALL_PATH\"),\'test\',testname)\n")
newfile.data.append("\n")
newfile.data.append("class Test"+ basename.title() + "(unittest.TestCase):" + "\n")
newfile.data.append("\n")
newfile.data.append(" def setUp(self):" + '\n')
newfile.data.append(" os.chdir(testdir)\n")
newfile.data.append("\n")
newfile.data.append(" def tearDown(self):" + '\n')
newfile.data.append(" pass" + '\n')
newfile.data.append("\n")
for line in myfile.data:
if "def " in line.strip()[0:4]:
defline = line
print defline
if not "self" in defline:
partone = myfile.get_segment(defline,"def ","(").strip()
parttwo = myfile.get_segment(defline,"(",":")
parttwo.strip()
newfile.data.append(" def test_" + partone + "(self):" + '\n')
newfile.data.append(" raise SkipTest\n")
newfile.data.append(" #self.testclass." + partone + "(" + parttwo+'\n')
newfile.data.append("\n")
else:
partone = myfile.get_segment(defline,"def ","(self").strip()
parttwo = myfile.get_segment(defline,"self,",":")
if parttwo == None:
parttwo = myfile.get_segment(defline,"self",":")
parttwo.strip()