本文整理汇总了Python中pyparsing.Group.searchString方法的典型用法代码示例。如果您正苦于以下问题:Python Group.searchString方法的具体用法?Python Group.searchString怎么用?Python Group.searchString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyparsing.Group
的用法示例。
在下文中一共展示了Group.searchString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Parser
# 需要导入模块: from pyparsing import Group [as 别名]
# 或者: from pyparsing.Group import searchString [as 别名]
#.........这里部分代码省略.........
**Vector**
::
import trappy
from trappy.stats.grammar import Parser
trace = trappy.FTrace("path/to/trace/file")
parser = Parser(trace)
parser.solve("trappy.thermal.Thermal:temp * 2")
**Scalar**
::
import trappy
from trappy.stats.grammar import Parser
trace = trappy.FTrace("path/to/trace/file")
parser = Parser(trace)
parser.solve("numpy.mean(trappy.thermal.Thermal:temp)")
**Vector Mask**
::
import trappy
from trappy.stats.grammar import Parser
trace = trappy.FTrace("path/to/trace/file")
parser = Parser(trace)
parser.solve("trappy.thermal.Thermal:temp > 65000")
"""
# Pre-process accessors for indexing
self._accessor.searchString(expr)
return self._parse_expr.parseString(expr)[0]
"""
# Pre-process accessors for indexing
self._accessor.searchString(expr)
return self._parse_expr.parseString(expr)[0]
"""
# Pre-process accessors for indexing
self._accessor.searchString(expr)
return self._parse_expr.parseString(expr)[0]
def _pivot(self, cls, column):
"""Pivot Data for concatenation"""
data_frame = self._get_data_frame(cls)
data_frame = handle_duplicate_index(data_frame)
new_index = self._agg_df.index.union(data_frame.index)
if hasattr(cls, "pivot") and cls.pivot:
pivot = cls.pivot
pivot_vals = list(np.unique(data_frame[pivot].values))
data = {}
for val in pivot_vals:
data[val] = data_frame[data_frame[pivot] == val][[column]]
if len(self._agg_df):
示例2: check_equals_true
# 需要导入模块: from pyparsing import Group [as 别名]
# 或者: from pyparsing.Group import searchString [as 别名]
def check_equals_true(self, code):
keyword = Literal("true") | Literal("false")
statement_parser = Group("==" + keyword) | Group(keyword + "==")
if len(statement_parser.searchString(code)):
self.add_error(label="EQUALS_TRUE")
示例3: check_equals_true
# 需要导入模块: from pyparsing import Group [as 别名]
# 或者: from pyparsing.Group import searchString [as 别名]
def check_equals_true(self, code):
variable = Word(alphanums)
keyword = Literal("true") | Literal("false")
statement_parser = Group(variable + "==" + keyword) | Group(keyword + "==" + variable)
if len(statement_parser.searchString(code)):
self.add_error("EQUALS_TRUE")