MCPcopy
hub / github.com/USArmyResearchLab/Dshell / premodule

Method premodule

dshell/plugins/misc/search.py:40–59  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

38
39
40 def premodule(self):
41 # make sure the user actually provided an expression to search for
42 if not self.expression:
43 self.error("Must define an expression to search for using --search_expression")
44 sys.exit(1)
45
46 # define the regex flags, based on arguments
47 re_flags = 0
48 if self.ignorecase:
49 re_flags = re_flags | re.IGNORECASE
50
51 # Create the regular expression
52 try:
53 # convert expression to bytes so it can accurately compare to
54 # the connection data (which is also of type bytes)
55 byte_expression = bytes(self.expression, 'utf-8')
56 self.regex = re.compile(byte_expression, re_flags)
57 except Exception as e:
58 self.error("Could not compile regex ({0})".format(e))
59 sys.exit(1)
60
61
62

Callers

nothing calls this directly

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected