Skip to content

Commit

Permalink
Merge pull request #15188 from Luap99/docs
Browse files Browse the repository at this point in the history
fix hack/markdown-preprocess to support older python versions
  • Loading branch information
openshift-ci[bot] authored Aug 4, 2022
2 parents ea7c979 + 031b7de commit 8f3f683
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion hack/markdown-preprocess
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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()

0 comments on commit 8f3f683

Please sign in to comment.