-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregexesv1.py
More file actions
32 lines (22 loc) · 886 Bytes
/
Copy pathregexesv1.py
File metadata and controls
32 lines (22 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# custom regexes
import re
REPLACE_REGEXES = (
# Replace this match with itself (but without backslash escaped characters)
# elasticsearch: -Djava.io.tmpdir=/tmp/elasticsearch-+
r'/tmp/elasticsearch-\d+\b',
)
def without_backslash_stuff(s):
return without_backslash_re.sub('', s)
without_backslash_re = re.compile(r'\\.')
REPLACE_CREGEXES = tuple(re.compile(i) for i in REPLACE_REGEXES)
REPLACE_RESULTS = tuple(without_backslash_stuff(i) for i in REPLACE_REGEXES)
class ProcessFormatterMixin(object):
def adjust(self, process):
super(ProcessFormatterMixin, self).adjust(process)
for idx, regex in enumerate(REPLACE_CREGEXES):
s = process.cmdline
m = regex.search(s)
if m:
process.cmdline = REPLACE_CREGEXES[idx].sub(
REPLACE_RESULTS[idx], s)
break