File: split_sort_compare.py

package info (click to toggle)
babeltrace2 2.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 42,660 kB
  • sloc: cpp: 106,162; ansic: 78,276; python: 27,115; sh: 9,053; makefile: 1,807; xml: 46
file content (24 lines) | stat: -rw-r--r-- 514 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>

import re
import sys


def main():
    expected = sys.argv[1]
    actual = sys.argv[2]
    sorted_expected = "".join(sorted(re.findall(r"\w+|\W+", expected.strip())))
    sorted_actual = "".join(sorted(re.findall(r"\w+|\W+", actual.strip())))

    if sorted_expected == sorted_actual:
        status = 0
    else:
        status = 1

    sys.exit(status)


if __name__ == "__main__":
    main()