From adff09c6dbec927374f9eabe999a43f17e730f8b Mon Sep 17 00:00:00 2001 From: "Kelvin M. Klann" Date: Tue, 18 Oct 2022 03:15:40 -0300 Subject: sort.py: line-wrap and improve comments Changes: * Line-wrap comments at 79 characters * Make comments clearer * Make main docstring more similar to a command "usage" output See the result with the following command, which generates a man-page-like output and opens it in the man pager (such as in `less`): $ pydoc ./contrib/sort.py See also PEP-257, "Docstring Conventions"[1]. [1] https://peps.python.org/pep-0257/ --- contrib/sort.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'contrib') diff --git a/contrib/sort.py b/contrib/sort.py index 69af99d6e..b4e06d345 100755 --- a/contrib/sort.py +++ b/contrib/sort.py @@ -3,11 +3,17 @@ # Copyright (C) 2014-2022 Firejail Authors # License GPL v2 """ -Sort the items of multi-item options in profiles, the following options are supported: - private-bin, private-etc, private-lib, caps.drop, caps.keep, seccomp.drop, seccomp.drop, protocol +Sort the arguments of commands in profiles. + +Usage: ./sort.py [/path/to/profile ...] + +The following commands are supported: + + private-bin, private-etc, private-lib, caps.drop, caps.keep, seccomp.drop, + seccomp.drop, protocol + +Note that this is only applicable to commands that support multiple arguments. -Usage: - $ ./sort.py /path/to/profile [ /path/to/profile2 /path/to/profile3 ... ] Keep in mind that this will overwrite your profile(s). Examples: @@ -16,10 +22,10 @@ Examples: $ ./sort.py ~/.config/firejail/*.{profile,inc,local} $ sudo ./sort.py /etc/firejail/*.{profile,inc,local} -Exit-Codes: - 0: No Error; No Profile Fixed. - 1: Error, one or more profiles were not processed correctly. - 101: No Error; One or more profile were fixed. +Exit Codes: + 0: Success: No profiles needed fixing. + 1: Error: One or more profiles could not be processed correctly. + 101: Info: One or more profiles were fixed. """ # Requirements: @@ -34,7 +40,11 @@ def sort_alphabetical(original_items): def sort_protocol(original_protocols): - """sort the given protocols into this scheme: unix,inet,inet6,netlink,packet,bluetooth""" + """ + Sort the given protocols into the following order: + + unix,inet,inet6,netlink,packet,bluetooth + """ # shortcut for common protocol lines if original_protocols in ("unix", "unix,inet,inet6"): -- cgit v1.2.3-70-g09d2