MCPcopy Create free account
hub / github.com/RoganDawes/P4wnP1 / extract_command

Method extract_command

hidtools/mouse/MouseScriptParser.py:38–70  ·  view source on GitHub ↗
(self, line)

Source from the content-addressed store, hash-verified

36 self.mouse = hid_mouse(False, devfile)
37
38 def extract_command(self, line):
39 # try to split into command + args
40
41# print "line: " + line
42 line = line.strip() # remove trailing and leading spaces
43 line = line.replace("\t", " ") # replace tabs by single space
44 first_word = line.split(" ", 1)[0]
45 if first_word.upper() in self.valid_commands:
46 # remove linebreaks
47 line = line.replace("\r\n","").replace("\n","")
48 # remove comments
49 line = line.split("#")[0]
50 line = line.split("//")[0]
51 # trim down spaces
52 line = line.strip()
53
54 # split command from args
55 argv = []
56 parts = line.split(" ")
57
58# print "Parts {0}".format(parts)
59
60 # store command uppercase
61 cmd = parts[0].strip().upper()
62 # if command includes args, trim down each arg (avoid interpreting multi-space as arguments)
63 for part in parts[1:]:
64 part = part.strip()
65 if len(part) > 0:
66 argv.append(part)
67
68 return cmd, argv
69 else:
70 return None
71
72
73 def dispatch_command(self, cmd, argv):

Callers 1

executeScriptMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected