diff options
author | 2022-10-18 03:15:40 -0300 | |
---|---|---|
committer | 2022-10-19 02:59:47 -0300 | |
commit | adff09c6dbec927374f9eabe999a43f17e730f8b (patch) | |
tree | 5a695315ca5daf98c1e05114e351c7227c194dd3 | |
parent | sort.py: rename protocols to original_protocols (diff) | |
download | firejail-adff09c6dbec927374f9eabe999a43f17e730f8b.tar.gz firejail-adff09c6dbec927374f9eabe999a43f17e730f8b.tar.zst firejail-adff09c6dbec927374f9eabe999a43f17e730f8b.zip |
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/
-rwxr-xr-x | contrib/sort.py | 28 |
1 files changed, 19 insertions, 9 deletions
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 @@ | |||
3 | # Copyright (C) 2014-2022 Firejail Authors | 3 | # Copyright (C) 2014-2022 Firejail Authors |
4 | # License GPL v2 | 4 | # License GPL v2 |
5 | """ | 5 | """ |
6 | Sort the items of multi-item options in profiles, the following options are supported: | 6 | Sort the arguments of commands in profiles. |
7 | private-bin, private-etc, private-lib, caps.drop, caps.keep, seccomp.drop, seccomp.drop, protocol | 7 | |
8 | Usage: ./sort.py [/path/to/profile ...] | ||
9 | |||
10 | The following commands are supported: | ||
11 | |||
12 | private-bin, private-etc, private-lib, caps.drop, caps.keep, seccomp.drop, | ||
13 | seccomp.drop, protocol | ||
14 | |||
15 | Note that this is only applicable to commands that support multiple arguments. | ||
8 | 16 | ||
9 | Usage: | ||
10 | $ ./sort.py /path/to/profile [ /path/to/profile2 /path/to/profile3 ... ] | ||
11 | Keep in mind that this will overwrite your profile(s). | 17 | Keep in mind that this will overwrite your profile(s). |
12 | 18 | ||
13 | Examples: | 19 | Examples: |
@@ -16,10 +22,10 @@ Examples: | |||
16 | $ ./sort.py ~/.config/firejail/*.{profile,inc,local} | 22 | $ ./sort.py ~/.config/firejail/*.{profile,inc,local} |
17 | $ sudo ./sort.py /etc/firejail/*.{profile,inc,local} | 23 | $ sudo ./sort.py /etc/firejail/*.{profile,inc,local} |
18 | 24 | ||
19 | Exit-Codes: | 25 | Exit Codes: |
20 | 0: No Error; No Profile Fixed. | 26 | 0: Success: No profiles needed fixing. |
21 | 1: Error, one or more profiles were not processed correctly. | 27 | 1: Error: One or more profiles could not be processed correctly. |
22 | 101: No Error; One or more profile were fixed. | 28 | 101: Info: One or more profiles were fixed. |
23 | """ | 29 | """ |
24 | 30 | ||
25 | # Requirements: | 31 | # Requirements: |
@@ -34,7 +40,11 @@ def sort_alphabetical(original_items): | |||
34 | 40 | ||
35 | 41 | ||
36 | def sort_protocol(original_protocols): | 42 | def sort_protocol(original_protocols): |
37 | """sort the given protocols into this scheme: unix,inet,inet6,netlink,packet,bluetooth""" | 43 | """ |
44 | Sort the given protocols into the following order: | ||
45 | |||
46 | unix,inet,inet6,netlink,packet,bluetooth | ||
47 | """ | ||
38 | 48 | ||
39 | # shortcut for common protocol lines | 49 | # shortcut for common protocol lines |
40 | if original_protocols in ("unix", "unix,inet,inet6"): | 50 | if original_protocols in ("unix", "unix,inet,inet6"): |