mirror of https://github.com/jumpserver/jumpserver
perf: Regular command groups can be filled in with new lines
parent
e1b96e01eb
commit
36e01a316c
|
@ -34,16 +34,16 @@ class CommandGroup(JMSOrgBaseModel):
|
||||||
|
|
||||||
@lazyproperty
|
@lazyproperty
|
||||||
def pattern(self):
|
def pattern(self):
|
||||||
|
content = self.content.replace('\r\n', '\n')
|
||||||
if self.type == 'command':
|
if self.type == 'command':
|
||||||
s = self.construct_command_regex(self.content)
|
s = self.construct_command_regex(content)
|
||||||
else:
|
else:
|
||||||
s = r'{0}'.format(self.content)
|
s = r'{0}'.format(r'{}'.format('|'.join(content.split('\n'))))
|
||||||
return s
|
return s
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def construct_command_regex(cls, content):
|
def construct_command_regex(cls, content):
|
||||||
regex = []
|
regex = []
|
||||||
content = content.replace('\r\n', '\n')
|
|
||||||
for _cmd in content.split('\n'):
|
for _cmd in content.split('\n'):
|
||||||
cmd = re.sub(r'\s+', ' ', _cmd)
|
cmd = re.sub(r'\s+', ' ', _cmd)
|
||||||
cmd = re.escape(cmd)
|
cmd = re.escape(cmd)
|
||||||
|
|
Loading…
Reference in New Issue