def action(self, args): """Perform the action associated with this command. :type args: list of titus.inspector.parser.Ast :param args: arguments passed to the command :rtype: ``None`` :return: nothing; results must be printed to the screen """ if len(args) == 1 and args[0] == parser.Word("help"): print self.help else: if len(args) == 2 and isinstance(args[0], parser.Word): if args[0].text not in self.mode.pfaFiles: raise InspectorError( "no PFA document named \"{0}\" in memory (try 'load <file> as {1}')" .format(args[0].text, args[0].text)) node = self.mode.pfaFiles[args[0].text].obj elif len(args) == 2 and isinstance(args[0], parser.Extract): if args[0].text not in self.mode.pfaFiles: raise InspectorError( "no PFA document named \"{0}\" in memory (try 'load <file> as {1}')" .format(args[0].text, args[0].text)) node = self.mode.pfaFiles[args[0].text].obj items = args[0].items node = extaction(args[0], node, items) else: self.syntaxError() regex = args[-1].regex() print "{0} matches".format(t.count(regex, node))
def action(self, args): """Perform the action associated with this command. :type args: list of titus.inspector.parser.Ast :param args: arguments passed to the command :rtype: ``None`` :return: nothing; results must be printed to the screen """ if len(args) == 1 and args[0] == parser.Word("help"): print self.help else: if len(args) == 2 and isinstance(args[0], parser.Word): if args[0].text not in self.mode.pfaFiles: raise InspectorError("no PFA document named \"{0}\" in memory (try 'load <file> as {1}')".format(args[0].text, args[0].text)) node = self.mode.pfaFiles[args[0].text].obj elif len(args) == 2 and isinstance(args[0], parser.Extract): if args[0].text not in self.mode.pfaFiles: raise InspectorError("no PFA document named \"{0}\" in memory (try 'load <file> as {1}')".format(args[0].text, args[0].text)) node = self.mode.pfaFiles[args[0].text].obj items = args[0].items node = extaction(args[0], node, items) else: self.syntaxError() regex = args[-1].regex() print "{0} matches".format(t.count(regex, node))
def action(self, args): if len(args) == 1 and args[0] == parser.Word("help"): print self.help else: if len(args) == 2 and isinstance(args[0], parser.Word): if args[0].text not in self.mode.pfaFiles: raise InspectorError("no PFA document named \"{0}\" in memory (try 'load <file> as {1}')".format(args[0].text, args[0].text)) node = self.mode.pfaFiles[args[0].text].obj elif len(args) == 2 and isinstance(args[0], parser.Extract): if args[0].text not in self.mode.pfaFiles: raise InspectorError("no PFA document named \"{0}\" in memory (try 'load <file> as {1}')".format(args[0].text, args[0].text)) node = self.mode.pfaFiles[args[0].text].obj items = args[0].items node = extaction(args[0], node, items) else: self.syntaxError() regex = args[-1].regex() print "{0} matches".format(t.count(regex, node))