From: Petr Lautrbach <plautrba@redhat.com>
To: selinux@vger.kernel.org
Subject: Re: [PATCH v2 3/3] python/sepolicy: Simplify generation of man pages
Date: Thu, 17 Nov 2022 13:46:26 +0100 [thread overview]
Message-ID: <87k03t21gd.fsf@redhat.com> (raw)
In-Reply-To: <20221115194552.338640-3-plautrba@redhat.com>
Petr Lautrbach <plautrba@redhat.com> writes:
> From: Petr Lautrbach <lautrbach@redhat.com>
>
> And do not hardcode Fedora and RHEL versions.
>
> Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
> ---
> python/sepolicy/sepolicy/manpage.py | 71 ++++-------------------------
> 1 file changed, 8 insertions(+), 63 deletions(-)
>
> diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py
> index de72cb6cda5f..d9973170f3c3 100755
> --- a/python/sepolicy/sepolicy/manpage.py
> +++ b/python/sepolicy/sepolicy/manpage.py
> @@ -147,9 +147,6 @@ def _gen_types():
> def prettyprint(f, trim):
> return " ".join(f[:-len(trim)].split("_"))
>
> -fedora_releases = ["Fedora17", "Fedora18"]
> -rhel_releases = ["RHEL6", "RHEL7"]
> -
>
> def get_alphabet_manpages(manpage_list):
> alphabet_manpages = dict.fromkeys(string.ascii_letters, [])
> @@ -180,7 +177,7 @@ def convert_manpage_to_html(html_manpage, manpage):
> class HTMLManPages:
>
> """
> - Generate a HHTML Manpages on an given SELinux domains
> + Generate a HTML Manpages on an given SELinux domains
> """
>
> def __init__(self, manpage_roles, manpage_domains, path, os_version):
> @@ -188,18 +185,12 @@ class HTMLManPages:
> self.manpage_domains = get_alphabet_manpages(manpage_domains)
> self.os_version = os_version
> self.old_path = path + "/"
> - self.new_path = self.old_path + self.os_version + "/"
> -
> - if self.os_version in fedora_releases or self.os_version in rhel_releases:
> - self.__gen_html_manpages()
> - else:
> - print("SELinux HTML man pages can not be generated for this %s" % os_version)
> - exit(1)
> + self.new_path = self.old_path
> + self.__gen_html_manpages()
>
> def __gen_html_manpages(self):
> self._write_html_manpage()
> self._gen_index()
> - self._gen_body()
> self._gen_css()
>
> def _write_html_manpage(self):
> @@ -217,67 +208,21 @@ class HTMLManPages:
> convert_manpage_to_html((self.new_path + r.rsplit("_selinux", 1)[0] + ".html"), self.old_path + r)
>
> def _gen_index(self):
> - index = self.old_path + "index.html"
> - fd = open(index, 'w')
> - fd.write("""
> -<html>
> -<head>
> - <link rel=stylesheet type="text/css" href="style.css" title="style">
> - <title>SELinux man pages online</title>
It should be just "SELinux man pages", without "online"
> -</head>
> -<body>
> -<h1>SELinux man pages</h1>
> -<br></br>
> -Fedora or Red Hat Enterprise Linux Man Pages.</h2>
> -<br></br>
> -<hr>
> -<h3>Fedora</h3>
> -<table><tr>
> -<td valign="middle">
> -</td>
> -</tr></table>
> -<pre>
> -""")
> - for f in fedora_releases:
> - fd.write("""
> -<a href=%s/%s.html>%s</a> - SELinux man pages for %s """ % (f, f, f, f))
> -
> - fd.write("""
> -</pre>
> -<hr>
> -<h3>RHEL</h3>
> -<table><tr>
> -<td valign="middle">
> -</td>
> -</tr></table>
> -<pre>
> -""")
> - for r in rhel_releases:
> - fd.write("""
> -<a href=%s/%s.html>%s</a> - SELinux man pages for %s """ % (r, r, r, r))
> -
> - fd.write("""
> -</pre>
> - """)
> - fd.close()
> - print("%s has been created" % index)
> -
> - def _gen_body(self):
> - html = self.new_path + self.os_version + ".html"
> + html = self.new_path + "index.html"
> fd = open(html, 'w')
> fd.write("""
> <html>
> <head>
> - <link rel=stylesheet type="text/css" href="../style.css" title="style">
> - <title>Linux man-pages online for Fedora18</title>
> + <link rel=stylesheet type="text/css" href="style.css" title="style">
> + <title>SELinux man pages online</title>
> </head>
> <body>
> -<h1>SELinux man pages for Fedora18</h1>
> +<h1>SELinux man pages for %s</h1>
> <hr>
> <table><tr>
> <td valign="middle">
> <h3>SELinux roles</h3>
> -""")
> +""" % self.os_version)
> for letter in self.manpage_roles:
> if len(self.manpage_roles[letter]):
> fd.write("""
> --
> 2.38.1
next prev parent reply other threads:[~2022-11-17 12:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 19:45 [PATCH v2 1/3] python/sepolicy: Fix sepolicy manpage -w Petr Lautrbach
2022-11-15 19:45 ` [PATCH v2 2/3] python/sepolicy: Use distro module to get os version Petr Lautrbach
2022-11-15 19:45 ` [PATCH v2 3/3] python/sepolicy: Simplify generation of man pages Petr Lautrbach
2022-11-17 12:46 ` Petr Lautrbach [this message]
2022-11-16 21:50 ` [PATCH v2 1/3] python/sepolicy: Fix sepolicy manpage -w James Carter
2022-11-17 12:39 ` Petr Lautrbach
2022-11-17 18:36 ` James Carter
2022-11-17 18:37 ` James Carter
2022-11-18 8:34 ` Ondrej Mosnacek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k03t21gd.fsf@redhat.com \
--to=plautrba@redhat.com \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.