]>
git.proxmox.com Git - mirror_ovs.git/blob - tests/uuidfilt.py
7 def lookup_uuid(uuids
, match
):
8 return "<%s>" % uuids
.setdefault(match
.group(0), len(uuids
))
11 int_re
= re
.compile(r
'\d+')
16 uuids
= sorted([int(x
) for x
in int_re
.findall(s
)])
17 return '["set",[' + ','.join('["uuid","<%s>"]' % x
for x
in uuids
) + ']]'
21 uuid_re
= re
.compile(r
'%s{8}-%s{4}-%s{4}-%s{4}-%s{12}' % ((u
,) * 5))
22 set_re
= re
.compile(r
'(\["set",\[(,?\["uuid","<\d+>"\])+\]\])')
25 def filter_uuids(src
, dst
):
29 return lookup_uuid(uuids
, match
)
35 line
= uuid_re
.sub(lf
, line
)
37 # Sort sets like this:
38 # [["uuid","<1>"],["uuid","<0>"]]
40 # [["uuid","<0>"],["uuid","<1>"]]
41 line
= set_re
.sub(sort_set
, line
)
45 if __name__
== '__main__':
47 for src
in sys
.argv
[1:]:
48 filter_uuids(open(src
), sys
.stdout
)
50 filter_uuids(sys
.stdin
, sys
.stdout
)