diff options
-rwxr-xr-x | contrib/sort.py | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/contrib/sort.py b/contrib/sort.py index 9e5062c3c..c7325facb 100755 --- a/contrib/sort.py +++ b/contrib/sort.py | |||
@@ -35,43 +35,16 @@ def sort_alphabetical(raw_items): | |||
35 | 35 | ||
36 | def sort_protocol(protocols): | 36 | def sort_protocol(protocols): |
37 | """sort the given protocole into this scheme: unix,inet,inet6,netlink,packet,bluetooth""" | 37 | """sort the given protocole into this scheme: unix,inet,inet6,netlink,packet,bluetooth""" |
38 | |||
38 | # shortcut for common protocol lines | 39 | # shortcut for common protocol lines |
39 | if protocols in ("unix", "unix,inet,inet6"): | 40 | if protocols in ("unix", "unix,inet,inet6"): |
40 | return protocols | 41 | return protocols |
42 | |||
41 | fixed_protocols = "" | 43 | fixed_protocols = "" |
42 | present_protocols = { | 44 | for protocol in ("unix", "inet", "inet6", "netlink", "packet", "bluetooth"): |
43 | "unix": False, | 45 | for prefix in ("", "-", "+", "="): |
44 | "inet": False, | 46 | if f",{prefix}{protocol}," in f",{protocols},": |
45 | "inet6": False, | 47 | fixed_protocols += f"{prefix}{protocol}," |
46 | "netlink": False, | ||
47 | "packet": False, | ||
48 | "bluetooth": False, | ||
49 | } | ||
50 | for protocol in protocols.split(","): | ||
51 | if protocol == "unix": | ||
52 | present_protocols["unix"] = True | ||
53 | elif protocol == "inet": | ||
54 | present_protocols["inet"] = True | ||
55 | elif protocol == "inet6": | ||
56 | present_protocols["inet6"] = True | ||
57 | elif protocol == "netlink": | ||
58 | present_protocols["netlink"] = True | ||
59 | elif protocol == "packet": | ||
60 | present_protocols["packet"] = True | ||
61 | elif protocol == "bluetooth": | ||
62 | present_protocols["bluetooth"] = True | ||
63 | if present_protocols["unix"]: | ||
64 | fixed_protocols += "unix," | ||
65 | if present_protocols["inet"]: | ||
66 | fixed_protocols += "inet," | ||
67 | if present_protocols["inet6"]: | ||
68 | fixed_protocols += "inet6," | ||
69 | if present_protocols["netlink"]: | ||
70 | fixed_protocols += "netlink," | ||
71 | if present_protocols["packet"]: | ||
72 | fixed_protocols += "packet," | ||
73 | if present_protocols["bluetooth"]: | ||
74 | fixed_protocols += "bluetooth," | ||
75 | return fixed_protocols[:-1] | 48 | return fixed_protocols[:-1] |
76 | 49 | ||
77 | 50 | ||