diff options
author | Paul Holzinger <pholzing@redhat.com> | 2022-08-04 10:26:18 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2022-08-04 10:26:18 +0200 |
commit | 031b7dec711fa43f5d94dde59960f4fe2ad7380c (patch) | |
tree | 14dedb4a79012f264b27b5bf12cb19b987db7ef8 /hack | |
parent | ea7c9796476428b7ef0201082185221a8213511d (diff) | |
download | podman-031b7dec711fa43f5d94dde59960f4fe2ad7380c.tar.gz podman-031b7dec711fa43f5d94dde59960f4fe2ad7380c.tar.bz2 podman-031b7dec711fa43f5d94dde59960f4fe2ad7380c.zip |
fix hack/markdown-preprocess to support older python versions
str.removeprefix() and str.removesuffix() is python 3.9+ only but we need to
support older versions for the OSX cross task.
This fixes broken CI on main.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'hack')
-rwxr-xr-x | hack/markdown-preprocess | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/hack/markdown-preprocess b/hack/markdown-preprocess index ec641b6b8..578615845 100755 --- a/hack/markdown-preprocess +++ b/hack/markdown-preprocess @@ -29,7 +29,7 @@ def process(infile): pod_or_container = 'pod' # Sometimes a man page includes the subcommand. - subcommand = infile.removeprefix("podman-").removesuffix(".1.md.in").replace("-", " ") + subcommand = removesuffix(removeprefix(infile,"podman-"),".1.md.in").replace("-", " ") # foo.md.in -> foo.md -- but always write to a tmpfile outfile = os.path.splitext(infile)[0] @@ -64,5 +64,21 @@ def process(infile): os.chmod(outfile_tmp, 0o444) os.rename(outfile_tmp, outfile) +# str.removeprefix() is python 3.9+, we need to support older versions on mac +def removeprefix(string: str, prefix: str) -> str: + if string.startswith(prefix): + return string[len(prefix):] + else: + return string[:] + +# str.removesuffix() is python 3.9+, we need to support older versions on mac +def removesuffix(string: str, suffix: str) -> str: + # suffix='' should not call self[:-0]. + if suffix and string.endswith(suffix): + return string[:-len(suffix)] + else: + return string[:] + + if __name__ == "__main__": main() |