本文整理汇总了Python中sos.utilities.grep函数的典型用法代码示例。如果您正苦于以下问题:Python grep函数的具体用法?Python grep怎么用?Python grep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了grep函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_module_loaded
def is_module_loaded(self, module_name):
"""Return whether specified moudle as module_name is loaded or not"""
if len(grep("^" + module_name + " ", "/proc/modules")) == 0:
return None
else:
return True
示例2: file_grep
def file_grep(self, regexp, *fnames):
"""Returns lines matched in fnames, where fnames can either be
pathnames to files to grep through or open file objects to grep through
line by line.
"""
return grep(regexp, *fnames)
示例3: test_grep_multiple_files
def test_grep_multiple_files(self):
matches = grep(".*unittest$", __file__.replace(".pyc", ".py"), "does_not_exist.txt")
self.assertEquals(matches, ['import unittest\n'])
示例4: test_open_file
def test_open_file(self):
matches = grep(".*unittest$", open(__file__.replace(".pyc", ".py")))
self.assertEquals(matches, ['import unittest\n'])
示例5: test_file_obj
def test_file_obj(self):
test_s = "\n".join(['this is only a test', 'there are only two lines'])
test_fo = StringIO(test_s)
matches = grep(".*test$", test_fo)
self.assertEquals(matches, ['this is only a test\n'])
示例6: test_real_file
def test_real_file(self):
matches = grep(".*unittest$", __file__.replace(".pyc", ".py"))
self.assertEquals(matches, ["import unittest\n"])